diff options
author | Rich Trott <rtrott@gmail.com> | 2017-12-19 22:13:40 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-12-21 10:11:42 -0800 |
commit | 40bab30067aaa464a03150529f652b853f58b024 (patch) | |
tree | 402e19d7c82d5c67788cf9398a0f62effc94ec86 /test/parallel/test-http2-respond-file-fd-invalid.js | |
parent | ddf3655f2bd2199fa187c56c0bcee419b5a1e1f0 (diff) | |
download | android-node-v8-40bab30067aaa464a03150529f652b853f58b024.tar.gz android-node-v8-40bab30067aaa464a03150529f652b853f58b024.tar.bz2 android-node-v8-40bab30067aaa464a03150529f652b853f58b024.zip |
test: move firstInvalidFD() out of common module
common.firstInvalidFD() is used in only one test. Move it out of the
common module and into the one test that uses it.
PR-URL: https://github.com/nodejs/node/pull/17781
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-http2-respond-file-fd-invalid.js')
-rw-r--r-- | test/parallel/test-http2-respond-file-fd-invalid.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/parallel/test-http2-respond-file-fd-invalid.js b/test/parallel/test-http2-respond-file-fd-invalid.js index 77a4d3df00..5dbb42e478 100644 --- a/test/parallel/test-http2-respond-file-fd-invalid.js +++ b/test/parallel/test-http2-respond-file-fd-invalid.js @@ -3,8 +3,10 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -const http2 = require('http2'); + const assert = require('assert'); +const fs = require('fs'); +const http2 = require('http2'); const { NGHTTP2_INTERNAL_ERROR @@ -18,7 +20,16 @@ const errorCheck = common.expectsError({ const server = http2.createServer(); server.on('stream', (stream) => { - stream.respondWithFD(common.firstInvalidFD()); + let fd = 2; + + // Get first known bad file descriptor. + try { + while (fs.fstatSync(++fd)); + } catch (e) { + // do nothing; we now have an invalid fd + } + + stream.respondWithFD(fd); stream.on('error', common.mustCall(errorCheck)); }); server.listen(0, () => { |