mirror of https://github.com/lukechilds/node.git
Browse Source
AsyncWrap will be going through many changes, and the old API will no longer be used. So remove those tests that will no longer be useful. They may be added back later using the new API, once fully implemented. PR-URL: https://github.com/nodejs/node/pull/12892 Ref: https://github.com/nodejs/node/pull/11883 Ref: https://github.com/nodejs/node/pull/8531 Reviewed-By: Andreas Madsen <amwebdk@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>v6
committed by
Anna Henningsen
7 changed files with 0 additions and 412 deletions
@ -1,122 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
if (!common.hasCrypto) { |
|||
common.skip('missing crypto'); |
|||
return; |
|||
} |
|||
|
|||
const assert = require('assert'); |
|||
const crypto = require('crypto'); |
|||
const dgram = require('dgram'); |
|||
const dns = require('dns'); |
|||
const fs = require('fs'); |
|||
const net = require('net'); |
|||
const tls = require('tls'); |
|||
const zlib = require('zlib'); |
|||
const ChildProcess = require('child_process').ChildProcess; |
|||
const StreamWrap = require('_stream_wrap').StreamWrap; |
|||
const HTTPParser = process.binding('http_parser').HTTPParser; |
|||
const async_wrap = process.binding('async_wrap'); |
|||
const pkeys = Object.keys(async_wrap.Providers); |
|||
|
|||
let keyList = pkeys.slice(); |
|||
// Drop NONE
|
|||
keyList.splice(0, 1); |
|||
|
|||
// fs-watch currently needs special configuration on AIX and we
|
|||
// want to improve under https://github.com/nodejs/node/issues/5085.
|
|||
// strip out fs watch related parts for now
|
|||
if (common.isAix) { |
|||
for (let i = 0; i < keyList.length; i++) { |
|||
if ((keyList[i] === 'FSEVENTWRAP') || (keyList[i] === 'STATWATCHER')) { |
|||
keyList.splice(i, 1); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function init(id, provider) { |
|||
keyList = keyList.filter((e) => e !== pkeys[provider]); |
|||
} |
|||
|
|||
async_wrap.setupHooks({ init }); |
|||
|
|||
async_wrap.enable(); |
|||
|
|||
|
|||
setTimeout(common.noop, 1); |
|||
|
|||
fs.stat(__filename, common.noop); |
|||
|
|||
if (!common.isAix) { |
|||
// fs-watch currently needs special configuration on AIX and we
|
|||
// want to improve under https://github.com/nodejs/node/issues/5085.
|
|||
// strip out fs watch related parts for now
|
|||
fs.watchFile(__filename, common.noop); |
|||
fs.unwatchFile(__filename); |
|||
fs.watch(__filename).close(); |
|||
} |
|||
|
|||
dns.lookup('localhost', common.noop); |
|||
dns.lookupService('::', 0, common.noop); |
|||
dns.resolve('localhost', common.noop); |
|||
|
|||
new StreamWrap(new net.Socket()); |
|||
|
|||
new (process.binding('tty_wrap').TTY)(); |
|||
|
|||
crypto.randomBytes(1, common.noop); |
|||
|
|||
common.refreshTmpDir(); |
|||
|
|||
net.createServer(function(c) { |
|||
c.end(); |
|||
this.close(); |
|||
}).listen(common.PIPE, function() { |
|||
net.connect(common.PIPE, common.noop); |
|||
}); |
|||
|
|||
net.createServer(function(c) { |
|||
c.end(); |
|||
this.close(checkTLS); |
|||
}).listen(0, function() { |
|||
net.connect(this.address().port, common.noop); |
|||
}); |
|||
|
|||
dgram.createSocket('udp4').bind(0, function() { |
|||
this.send(Buffer.allocUnsafe(2), 0, 2, this.address().port, '::', () => { |
|||
this.close(); |
|||
}); |
|||
}); |
|||
|
|||
process.on('SIGINT', () => process.exit()); |
|||
|
|||
// Run from closed net server above.
|
|||
function checkTLS() { |
|||
const options = { |
|||
key: fs.readFileSync(`${common.fixturesDir}/keys/ec-key.pem`), |
|||
cert: fs.readFileSync(`${common.fixturesDir}/keys/ec-cert.pem`) |
|||
}; |
|||
const server = tls.createServer(options, common.noop) |
|||
.listen(0, function() { |
|||
const connectOpts = { rejectUnauthorized: false }; |
|||
tls.connect(this.address().port, connectOpts, function() { |
|||
this.destroy(); |
|||
server.close(); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
zlib.createGzip(); |
|||
|
|||
new ChildProcess(); |
|||
|
|||
new HTTPParser(HTTPParser.REQUEST); |
|||
|
|||
process.on('exit', function() { |
|||
if (keyList.length !== 0) { |
|||
process._rawDebug('Not all keys have been used:'); |
|||
process._rawDebug(keyList); |
|||
assert.strictEqual(keyList.length, 0); |
|||
} |
|||
}); |
@ -1,50 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const net = require('net'); |
|||
const async_wrap = process.binding('async_wrap'); |
|||
const providers = Object.keys(async_wrap.Providers); |
|||
|
|||
const uidSymbol = Symbol('uid'); |
|||
|
|||
let cntr = 0; |
|||
let client; |
|||
|
|||
function init(uid, type, parentUid, parentHandle) { |
|||
this[uidSymbol] = uid; |
|||
|
|||
if (parentHandle) { |
|||
cntr++; |
|||
// Cannot assert in init callback or will abort.
|
|||
process.nextTick(() => { |
|||
assert.strictEqual(providers[type], 'TCPWRAP'); |
|||
assert.strictEqual(parentUid, server._handle[uidSymbol], |
|||
'server uid doesn\'t match parent uid'); |
|||
assert.strictEqual(parentHandle, server._handle, |
|||
'server handle doesn\'t match parent handle'); |
|||
assert.strictEqual(this, client._handle, 'client doesn\'t match context'); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
async_wrap.setupHooks({ init }); |
|||
async_wrap.enable(); |
|||
|
|||
const server = net.createServer(function(c) { |
|||
client = c; |
|||
// Allow init callback to run before closing.
|
|||
setImmediate(() => { |
|||
c.end(); |
|||
this.close(); |
|||
}); |
|||
}).listen(0, function() { |
|||
net.connect(this.address().port, common.noop); |
|||
}); |
|||
|
|||
async_wrap.disable(); |
|||
|
|||
process.on('exit', function() { |
|||
// init should have only been called once with a parent.
|
|||
assert.strictEqual(cntr, 1); |
|||
}); |
@ -1,39 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
if (!common.hasCrypto) { |
|||
common.skip('missing crypto'); |
|||
return; |
|||
} |
|||
|
|||
const assert = require('assert'); |
|||
const async_wrap = process.binding('async_wrap'); |
|||
let asyncThrows = 0; |
|||
let uncaughtExceptionCount = 0; |
|||
|
|||
process.on('uncaughtException', (e) => { |
|||
assert.strictEqual(e.message, 'oh noes!', 'error messages do not match'); |
|||
}); |
|||
|
|||
process.on('exit', () => { |
|||
process.removeAllListeners('uncaughtException'); |
|||
assert.strictEqual(uncaughtExceptionCount, 1); |
|||
assert.strictEqual(uncaughtExceptionCount, asyncThrows); |
|||
}); |
|||
|
|||
function init() { } |
|||
function post(id, threw) { |
|||
if (threw) |
|||
uncaughtExceptionCount++; |
|||
} |
|||
|
|||
async_wrap.setupHooks({ init, post }); |
|||
async_wrap.enable(); |
|||
|
|||
// Timers still aren't supported, so use crypto API.
|
|||
// It's also important that the callback not happen in a nextTick, like many
|
|||
// error events in core.
|
|||
require('crypto').randomBytes(0, () => { |
|||
asyncThrows++; |
|||
throw new Error('oh noes!'); |
|||
}); |
@ -1,49 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const net = require('net'); |
|||
const async_wrap = process.binding('async_wrap'); |
|||
const providers = Object.keys(async_wrap.Providers); |
|||
|
|||
const uidSymbol = Symbol('uid'); |
|||
|
|||
let cntr = 0; |
|||
let client; |
|||
|
|||
function init(uid, type, parentUid, parentHandle) { |
|||
this[uidSymbol] = uid; |
|||
|
|||
if (parentHandle) { |
|||
cntr++; |
|||
// Cannot assert in init callback or will abort.
|
|||
process.nextTick(() => { |
|||
assert.strictEqual(providers[type], 'TCPWRAP'); |
|||
assert.strictEqual(parentUid, server._handle[uidSymbol], |
|||
'server uid doesn\'t match parent uid'); |
|||
assert.strictEqual(parentHandle, server._handle, |
|||
'server handle doesn\'t match parent handle'); |
|||
assert.strictEqual(this, client._handle, 'client doesn\'t match context'); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
async_wrap.setupHooks({ init }); |
|||
async_wrap.enable(); |
|||
|
|||
const server = net.createServer(function(c) { |
|||
client = c; |
|||
// Allow init callback to run before closing.
|
|||
setImmediate(() => { |
|||
c.end(); |
|||
this.close(); |
|||
}); |
|||
}).listen(0, function() { |
|||
net.connect(this.address().port, common.noop); |
|||
}); |
|||
|
|||
|
|||
process.on('exit', function() { |
|||
// init should have only been called once with a parent.
|
|||
assert.strictEqual(cntr, 1); |
|||
}); |
@ -1,25 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
const async_wrap = process.binding('async_wrap'); |
|||
|
|||
assert.throws(function() { |
|||
async_wrap.setupHooks(null); |
|||
}, /first argument must be an object/); |
|||
|
|||
assert.throws(function() { |
|||
async_wrap.setupHooks({}); |
|||
}, /init callback must be a function/); |
|||
|
|||
assert.throws(function() { |
|||
async_wrap.enable(); |
|||
}, /init callback is not assigned to a function/); |
|||
|
|||
// Should not throw
|
|||
async_wrap.setupHooks({ init: common.noop }); |
|||
async_wrap.enable(); |
|||
|
|||
assert.throws(function() { |
|||
async_wrap.setupHooks(common.noop); |
|||
}, /hooks should not be set while also enabled/); |
@ -1,63 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
const fs = require('fs'); |
|||
const assert = require('assert'); |
|||
const async_wrap = process.binding('async_wrap'); |
|||
|
|||
// Give the event loop time to clear out the final uv_close().
|
|||
let si_cntr = 3; |
|||
process.on('beforeExit', () => { |
|||
if (--si_cntr > 0) setImmediate(common.noop); |
|||
}); |
|||
|
|||
const storage = new Map(); |
|||
async_wrap.setupHooks({ init, pre, post, destroy }); |
|||
async_wrap.enable(); |
|||
|
|||
function init(uid) { |
|||
storage.set(uid, { |
|||
init: true, |
|||
pre: false, |
|||
post: false, |
|||
destroy: false, |
|||
}); |
|||
} |
|||
|
|||
function pre(uid) { |
|||
storage.get(uid).pre = true; |
|||
} |
|||
|
|||
function post(uid) { |
|||
storage.get(uid).post = true; |
|||
} |
|||
|
|||
function destroy(uid) { |
|||
storage.get(uid).destroy = true; |
|||
} |
|||
|
|||
fs.access(__filename, function(err) { |
|||
assert.ifError(err); |
|||
}); |
|||
|
|||
fs.access(__filename, function(err) { |
|||
assert.ifError(err); |
|||
}); |
|||
|
|||
async_wrap.disable(); |
|||
|
|||
process.once('exit', function() { |
|||
assert.strictEqual(storage.size, 2); |
|||
|
|||
for (const item of storage) { |
|||
const uid = item[0]; |
|||
const value = item[1]; |
|||
assert.strictEqual(typeof uid, 'number'); |
|||
assert.deepStrictEqual(value, { |
|||
init: true, |
|||
pre: true, |
|||
post: true, |
|||
destroy: true, |
|||
}); |
|||
} |
|||
}); |
@ -1,64 +0,0 @@ |
|||
'use strict'; |
|||
|
|||
const common = require('../common'); |
|||
if (!common.hasCrypto) { |
|||
common.skip('missing crypto'); |
|||
return; |
|||
} |
|||
|
|||
const async_wrap = process.binding('async_wrap'); |
|||
const uv = process.binding('uv'); |
|||
const assert = require('assert'); |
|||
const dgram = require('dgram'); |
|||
const fs = require('fs'); |
|||
const net = require('net'); |
|||
const tls = require('tls'); |
|||
const providers = Object.keys(async_wrap.Providers); |
|||
let flags = 0; |
|||
|
|||
// Make sure all asserts have run at least once.
|
|||
process.on('exit', () => assert.strictEqual(flags, 0b111)); |
|||
|
|||
function init(id, provider) { |
|||
this._external; // Test will abort if nullptr isn't properly checked.
|
|||
switch (providers[provider]) { |
|||
case 'TCPWRAP': |
|||
assert.strictEqual(this.fd, uv.UV_EINVAL); |
|||
flags |= 0b1; |
|||
break; |
|||
case 'TLSWRAP': |
|||
assert.strictEqual(this.fd, uv.UV_EINVAL); |
|||
flags |= 0b10; |
|||
break; |
|||
case 'UDPWRAP': |
|||
assert.strictEqual(this.fd, uv.UV_EBADF); |
|||
flags |= 0b100; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
async_wrap.setupHooks({ init }); |
|||
async_wrap.enable(); |
|||
|
|||
const checkTLS = common.mustCall(function checkTLS() { |
|||
const options = { |
|||
key: fs.readFileSync(`${common.fixturesDir}/keys/ec-key.pem`), |
|||
cert: fs.readFileSync(`${common.fixturesDir}/keys/ec-cert.pem`) |
|||
}; |
|||
const server = tls.createServer(options, common.noop) |
|||
.listen(0, function() { |
|||
const connectOpts = { rejectUnauthorized: false }; |
|||
tls.connect(this.address().port, connectOpts, function() { |
|||
this.destroy(); |
|||
server.close(); |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
const checkTCP = common.mustCall(function checkTCP() { |
|||
net.createServer(common.noop).listen(0, function() { |
|||
this.close(checkTLS); |
|||
}); |
|||
}); |
|||
|
|||
dgram.createSocket('udp4').close(checkTCP); |
Loading…
Reference in new issue