aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-stdio-closed.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2016-09-23 16:41:21 -0700
committerJames M Snell <jasnell@gmail.com>2016-09-26 07:55:44 -0700
commite65a2d7ddcf30077b14cc07d54c7953fb0028155 (patch)
tree97f2d701d6e109fcf56c9a7c20bc1bed30e323da /test/parallel/test-stdio-closed.js
parent8de92cd6f374175ee822dc7677264fd4be1b0e7a (diff)
downloadandroid-node-v8-e65a2d7ddcf30077b14cc07d54c7953fb0028155.tar.gz
android-node-v8-e65a2d7ddcf30077b14cc07d54c7953fb0028155.tar.bz2
android-node-v8-e65a2d7ddcf30077b14cc07d54c7953fb0028155.zip
test: accept expected AIX result test-stdio-closed
AIX handles closed stdio differently (but still compliant with spec as far as I can tell) than other POSIX variants we test. Test results are different than Linux and others because AIX takes measures to not re-use the file descriptors for stdio if one of the stdio streams is closed. Fixes: https://github.com/nodejs/node/issues/8375 PR-URL: https://github.com/nodejs/node/pull/8755 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Diffstat (limited to 'test/parallel/test-stdio-closed.js')
-rw-r--r--test/parallel/test-stdio-closed.js30
1 files changed, 20 insertions, 10 deletions
diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js
index 0f94289ee9..a85467f76a 100644
--- a/test/parallel/test-stdio-closed.js
+++ b/test/parallel/test-stdio-closed.js
@@ -1,7 +1,7 @@
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var spawn = require('child_process').spawn;
+const common = require('../common');
+const assert = require('assert');
+const spawn = require('child_process').spawn;
if (common.isWindows) {
common.skip('platform not supported.');
@@ -9,18 +9,28 @@ if (common.isWindows) {
}
if (process.argv[2] === 'child') {
- process.stdout.write('stdout', function() {
- process.stderr.write('stderr', function() {
- process.exit(42);
+ try {
+ process.stdout.write('stdout', function() {
+ try {
+ process.stderr.write('stderr', function() {
+ process.exit(42);
+ });
+ } catch (e) {
+ process.exit(84);
+ }
});
- });
+ } catch (e) {
+ assert.strictEqual(e.code, 'EBADF');
+ assert.strictEqual(e.message, 'EBADF: bad file descriptor, write');
+ process.exit(126);
+ }
return;
}
// Run the script in a shell but close stdout and stderr.
-var cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
-var proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
+const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
+const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
proc.on('exit', common.mustCall(function(exitCode) {
- assert.equal(exitCode, 42);
+ assert.strictEqual(exitCode, common.isAix ? 126 : 42);
}));