diff options
author | Anna Henningsen <sqrt@entless.org> | 2016-03-29 23:02:47 +0200 |
---|---|---|
committer | Myles Borins <mborins@us.ibm.com> | 2016-04-11 12:10:59 -0400 |
commit | 1994ac09122967b5fbd3a9ec8bd4908a4cb9f074 (patch) | |
tree | 3d63e8feac0898e578c9d53a6a13f6216b3a549b | |
parent | c33a23fd1efd7e9e160f0886adfa328d4d6e5f1d (diff) | |
download | nodejs-1994ac09122967b5fbd3a9ec8bd4908a4cb9f074.tar.gz nodejs-1994ac09122967b5fbd3a9ec8bd4908a4cb9f074.tar.bz2 nodejs-1994ac09122967b5fbd3a9ec8bd4908a4cb9f074.zip |
test: add test for piping large input from stdin
Check that piping a large chunk of data from `process.stdin`
into `process.stdout` does not lose any data by verifying that
the output has the same size as the input.
This is a regression test for #5927 and fails for the commits
in the range [ace100945..89abe8680).
PR-URL: https://github.com/nodejs/node/pull/5949
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
-rw-r--r-- | test/parallel/test-stdin-pipe-large.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/parallel/test-stdin-pipe-large.js b/test/parallel/test-stdin-pipe-large.js new file mode 100644 index 000000000..428bbb043 --- /dev/null +++ b/test/parallel/test-stdin-pipe-large.js @@ -0,0 +1,23 @@ +'use strict'; +// See https://github.com/nodejs/node/issues/5927 + +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; + +if (process.argv[2] === 'child') { + process.stdin.pipe(process.stdout); + return; +} + +const child = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' }); + +const expectedBytes = 1024 * 1024; +let readBytes = 0; + +child.stdin.end(Buffer(expectedBytes)); + +child.stdout.on('data', (chunk) => readBytes += chunk.length); +child.stdout.on('end', common.mustCall(() => { + assert.strictEqual(readBytes, expectedBytes); +})); |