diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2017-11-20 17:18:40 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-11-28 02:50:54 +0100 |
commit | b44efded8481877c1ec782112b9ae4c4fec37463 (patch) | |
tree | 7c967e36bc1d718c513965b619f65e7f4f9da95a /test/async-hooks/test-pipeconnectwrap.js | |
parent | 91d131210c2d7887d8625d34c1008a3d423cf86b (diff) | |
download | android-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.tar.gz android-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.tar.bz2 android-node-v8-b44efded8481877c1ec782112b9ae4c4fec37463.zip |
async_wrap: add provider types for net server
Adds `TCPSERVERWRAP` and `PIPESERVERWRAP` as provider types. This
makes it possible to distinguish servers from connections.
PR-URL: https://github.com/nodejs/node/pull/17157
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/async-hooks/test-pipeconnectwrap.js')
-rw-r--r-- | test/async-hooks/test-pipeconnectwrap.js | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/test/async-hooks/test-pipeconnectwrap.js b/test/async-hooks/test-pipeconnectwrap.js index bcab601d05..81a5abd42a 100644 --- a/test/async-hooks/test-pipeconnectwrap.js +++ b/test/async-hooks/test-pipeconnectwrap.js @@ -12,7 +12,8 @@ common.refreshTmpDir(); const hooks = initHooks(); hooks.enable(); -let pipe1, pipe2, pipe3; +let pipe1, pipe2; +let pipeserver; let pipeconnect; net.createServer(common.mustCall(function(c) { @@ -22,27 +23,27 @@ net.createServer(common.mustCall(function(c) { })).listen(common.PIPE, common.mustCall(onlisten)); function onlisten() { - let pipes = hooks.activitiesOfTypes('PIPEWRAP'); + const pipeservers = hooks.activitiesOfTypes('PIPESERVERWRAP'); let pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP'); - assert.strictEqual(pipes.length, 1); + assert.strictEqual(pipeservers.length, 1); assert.strictEqual(pipeconnects.length, 0); net.connect(common.PIPE, common.mustCall(maybeOnconnect.bind(null, 'client'))); - pipes = hooks.activitiesOfTypes('PIPEWRAP'); + const pipes = hooks.activitiesOfTypes('PIPEWRAP'); pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP'); - assert.strictEqual(pipes.length, 2); + assert.strictEqual(pipes.length, 1); assert.strictEqual(pipeconnects.length, 1); + pipeserver = pipeservers[0]; pipe1 = pipes[0]; - pipe2 = pipes[1]; pipeconnect = pipeconnects[0]; + assert.strictEqual(pipeserver.type, 'PIPESERVERWRAP'); assert.strictEqual(pipe1.type, 'PIPEWRAP'); - assert.strictEqual(pipe2.type, 'PIPEWRAP'); assert.strictEqual(pipeconnect.type, 'PIPECONNECTWRAP'); - for (const a of [ pipe1, pipe2, pipeconnect ]) { + for (const a of [ pipeserver, pipe1, pipeconnect ]) { assert.strictEqual(typeof a.uid, 'number'); assert.strictEqual(typeof a.triggerAsyncId, 'number'); checkInvocations(a, { init: 1 }, 'after net.connect'); @@ -60,18 +61,18 @@ function maybeOnconnect(source) { const pipes = hooks.activitiesOfTypes('PIPEWRAP'); const pipeconnects = hooks.activitiesOfTypes('PIPECONNECTWRAP'); - assert.strictEqual(pipes.length, 3); + assert.strictEqual(pipes.length, 2); assert.strictEqual(pipeconnects.length, 1); - pipe3 = pipes[2]; - assert.strictEqual(typeof pipe3.uid, 'number'); - assert.strictEqual(typeof pipe3.triggerAsyncId, 'number'); + pipe2 = pipes[1]; + assert.strictEqual(typeof pipe2.uid, 'number'); + assert.strictEqual(typeof pipe2.triggerAsyncId, 'number'); - checkInvocations(pipe1, { init: 1, before: 1, after: 1 }, - 'pipe1, client connected'); - checkInvocations(pipe2, { init: 1 }, 'pipe2, client connected'); + checkInvocations(pipeserver, { init: 1, before: 1, after: 1 }, + 'pipeserver, client connected'); + checkInvocations(pipe1, { init: 1 }, 'pipe1, client connected'); checkInvocations(pipeconnect, { init: 1, before: 1 }, 'pipeconnect, client connected'); - checkInvocations(pipe3, { init: 1 }, 'pipe3, client connected'); + checkInvocations(pipe2, { init: 1 }, 'pipe2, client connected'); tick(5); } @@ -80,14 +81,15 @@ process.on('exit', onexit); function onexit() { hooks.disable(); hooks.sanityCheck('PIPEWRAP'); + hooks.sanityCheck('PIPESERVERWRAP'); hooks.sanityCheck('PIPECONNECTWRAP'); // TODO(thlorenz) why have some of those 'before' and 'after' called twice - checkInvocations(pipe1, { init: 1, before: 1, after: 1, destroy: 1 }, + checkInvocations(pipeserver, { init: 1, before: 1, after: 1, destroy: 1 }, + 'pipeserver, process exiting'); + checkInvocations(pipe1, { init: 1, before: 2, after: 2, destroy: 1 }, 'pipe1, process exiting'); - checkInvocations(pipe2, { init: 1, before: 2, after: 2, destroy: 1 }, - 'pipe2, process exiting'); checkInvocations(pipeconnect, { init: 1, before: 1, after: 1, destroy: 1 }, 'pipeconnect, process exiting'); - checkInvocations(pipe3, { init: 1, before: 2, after: 2, destroy: 1 }, - 'pipe3, process exiting'); + checkInvocations(pipe2, { init: 1, before: 2, after: 2, destroy: 1 }, + 'pipe2, process exiting'); } |