From eeb57022e6bada13955a19b15232a9ee4fe9b465 Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 21 Mar 2018 01:02:49 +0530 Subject: [PATCH] test: rename regression tests more expressively PR-URL: https://github.com/nodejs/node/pull/19495 Refs: https://github.com/nodejs/node/issues/19105 Reviewed-By: Gireesh Punathil Reviewed-By: Rich Trott Reviewed-By: James M Snell --- ...s => test-arm-math-illegal-instruction.js} | 5 +- ....js => test-buffer-tostring-rangeerror.js} | 7 ++- ...js => test-dgram-send-invalid-msg-type.js} | 7 ++- ...070.js => test-dns-resolvens-typeerror.js} | 33 ++++++----- ...test-http-agent-maxsockets-regress-4050.js | 41 -------------- .../test-http-agent-maxsockets-respected.js | 56 +++++++++++++++++++ 6 files changed, 90 insertions(+), 59 deletions(-) rename test/parallel/{test-arm-math-exp-regress-1376.js => test-arm-math-illegal-instruction.js} (81%) rename test/parallel/{test-buffer-regression-649.js => test-buffer-tostring-rangeerror.js} (86%) rename test/parallel/{test-dgram-regress-4496.js => test-dgram-send-invalid-msg-type.js} (89%) rename test/parallel/{test-dns-regress-7070.js => test-dns-resolvens-typeerror.js} (71%) delete mode 100644 test/parallel/test-http-agent-maxsockets-regress-4050.js create mode 100644 test/parallel/test-http-agent-maxsockets-respected.js diff --git a/test/parallel/test-arm-math-exp-regress-1376.js b/test/parallel/test-arm-math-illegal-instruction.js similarity index 81% rename from test/parallel/test-arm-math-exp-regress-1376.js rename to test/parallel/test-arm-math-illegal-instruction.js index c947208bd4..2c4cdd2630 100644 --- a/test/parallel/test-arm-math-exp-regress-1376.js +++ b/test/parallel/test-arm-math-illegal-instruction.js @@ -1,8 +1,11 @@ 'use strict'; +require('../common'); + +// This test ensures Math functions don't fail with an "illegal instruction" +// error on ARM devices (primarily on the Raspberry Pi 1) // See https://github.com/nodejs/node/issues/1376 // and https://code.google.com/p/v8/issues/detail?id=4019 -require('../common'); Math.abs(-0.5); Math.acos(-0.5); Math.acosh(-0.5); diff --git a/test/parallel/test-buffer-regression-649.js b/test/parallel/test-buffer-tostring-rangeerror.js similarity index 86% rename from test/parallel/test-buffer-regression-649.js rename to test/parallel/test-buffer-tostring-rangeerror.js index f02e769fa2..ccfb40bee7 100644 --- a/test/parallel/test-buffer-regression-649.js +++ b/test/parallel/test-buffer-tostring-rangeerror.js @@ -1,10 +1,13 @@ 'use strict'; - const common = require('../common'); + +// This test ensures that Node.js throws a RangeError when trying to convert a +// gigantic buffer into a string. +// Regression test for https://github.com/nodejs/node/issues/649. + const assert = require('assert'); const SlowBuffer = require('buffer').SlowBuffer; -// Regression test for https://github.com/nodejs/node/issues/649. const len = 1422561062959; const message = common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', diff --git a/test/parallel/test-dgram-regress-4496.js b/test/parallel/test-dgram-send-invalid-msg-type.js similarity index 89% rename from test/parallel/test-dgram-regress-4496.js rename to test/parallel/test-dgram-send-invalid-msg-type.js index 72c43635e3..7a85455ce9 100644 --- a/test/parallel/test-dgram-regress-4496.js +++ b/test/parallel/test-dgram-send-invalid-msg-type.js @@ -20,9 +20,12 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// Remove this test once we support sending strings. - require('../common'); + +// This test ensures that a TypeError is raised when the argument to `send()` +// or `sendto()` is anything but a Buffer. +// https://github.com/nodejs/node-v0.x-archive/issues/4496 + const assert = require('assert'); const dgram = require('dgram'); diff --git a/test/parallel/test-dns-regress-7070.js b/test/parallel/test-dns-resolvens-typeerror.js similarity index 71% rename from test/parallel/test-dns-regress-7070.js rename to test/parallel/test-dns-resolvens-typeerror.js index ada5bf2d91..8da7d3a489 100644 --- a/test/parallel/test-dns-regress-7070.js +++ b/test/parallel/test-dns-resolvens-typeerror.js @@ -21,18 +21,25 @@ 'use strict'; const common = require('../common'); + +// This test ensures `dns.resolveNs()` does not raise a C++-land assertion error +// and throw a JavaScript TypeError instead. +// Issue https://github.com/nodejs/node-v0.x-archive/issues/7070 + const dns = require('dns'); -// Should not raise assertion error. -// Issue https://github.com/nodejs/node-v0.x-archive/issues/7070 -common.expectsError(() => dns.resolveNs([]), // bad name - { - code: 'ERR_INVALID_ARG_TYPE', - type: TypeError, - message: /^The "name" argument must be of type string/ - }); -common.expectsError(() => dns.resolveNs(''), // bad callback - { - code: 'ERR_INVALID_CALLBACK', - type: TypeError - }); +common.expectsError( + () => dns.resolveNs([]), // bad name + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError, + message: /^The "name" argument must be of type string/ + } +); +common.expectsError( + () => dns.resolveNs(''), // bad callback + { + code: 'ERR_INVALID_CALLBACK', + type: TypeError + } +); diff --git a/test/parallel/test-http-agent-maxsockets-regress-4050.js b/test/parallel/test-http-agent-maxsockets-regress-4050.js deleted file mode 100644 index eb1c95d520..0000000000 --- a/test/parallel/test-http-agent-maxsockets-regress-4050.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const http = require('http'); -const Countdown = require('../common/countdown'); - -const MAX_SOCKETS = 2; - -const agent = new http.Agent({ - keepAlive: true, - keepAliveMsecs: 1000, - maxSockets: MAX_SOCKETS, - maxFreeSockets: 2 -}); - -const server = http.createServer(common.mustCall((req, res) => { - res.end('hello world'); -}, 6)); - -const countdown = new Countdown(6, () => server.close()); - -function get(path, callback) { - return http.get({ - host: 'localhost', - port: server.address().port, - agent: agent, - path: path - }, callback); -} - -server.listen(0, common.mustCall(() => { - for (let i = 0; i < 6; i++) { - const request = get('/1', common.mustCall()); - request.on('response', common.mustCall(() => { - request.abort(); - const sockets = agent.sockets[Object.keys(agent.sockets)[0]]; - assert(sockets.length <= MAX_SOCKETS); - countdown.dec(); - })); - } -})); diff --git a/test/parallel/test-http-agent-maxsockets-respected.js b/test/parallel/test-http-agent-maxsockets-respected.js new file mode 100644 index 0000000000..51db7e2f49 --- /dev/null +++ b/test/parallel/test-http-agent-maxsockets-respected.js @@ -0,0 +1,56 @@ +'use strict'; +const common = require('../common'); +const Countdown = require('../common/countdown'); + +// This test ensures that the `maxSockets` value for `http.Agent` is respected. +// https://github.com/nodejs/node/issues/4050 + +const assert = require('assert'); +const http = require('http'); + +const MAX_SOCKETS = 2; + +const agent = new http.Agent({ + keepAlive: true, + keepAliveMsecs: 1000, + maxSockets: MAX_SOCKETS, + maxFreeSockets: 2 +}); + +const server = http.createServer( + common.mustCall((req, res) => { + res.end('hello world'); + }, 6) +); + +const countdown = new Countdown(6, () => server.close()); + +function get(path, callback) { + return http.get( + { + host: 'localhost', + port: server.address().port, + agent: agent, + path: path + }, + callback + ); +} + +server.listen( + 0, + common.mustCall(() => { + for (let i = 0; i < 6; i++) { + const request = get('/1', common.mustCall()); + request.on( + 'response', + common.mustCall(() => { + request.abort(); + const sockets = agent.sockets[Object.keys(agent.sockets)[0]]; + assert(sockets.length <= MAX_SOCKETS); + countdown.dec(); + }) + ); + } + }) +);