Browse Source

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>
v4.x
Rich Trott 9 years ago
committed by Myles Borins
parent
commit
b64828d8df
  1. 1
      test/parallel/parallel.status
  2. 22
      test/parallel/test-stdio-closed.js

1
test/parallel/parallel.status

@ -34,7 +34,6 @@ test-fs-watch-enoent : FAIL, PASS
# Disable so we don't get failures now that AIX has been # Disable so we don't get failures now that AIX has been
# added to regular CI runs # added to regular CI runs
test-regress-GH-1899 : FAIL, PASS test-regress-GH-1899 : FAIL, PASS
test-stdio-closed : FAIL, PASS
# Flaky until https://github.com/nodejs/build/issues/415 is resolved. # Flaky until https://github.com/nodejs/build/issues/415 is resolved.
# On some of the buildbots, AAAA queries for localhost don't resolve # On some of the buildbots, AAAA queries for localhost don't resolve

22
test/parallel/test-stdio-closed.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var common = require('../common'); const common = require('../common');
var assert = require('assert'); const assert = require('assert');
var spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
if (common.isWindows) { if (common.isWindows) {
common.skip('platform not supported.'); common.skip('platform not supported.');
@ -9,18 +9,28 @@ if (common.isWindows) {
} }
if (process.argv[2] === 'child') { if (process.argv[2] === 'child') {
try {
process.stdout.write('stdout', function() { process.stdout.write('stdout', function() {
try {
process.stderr.write('stderr', function() { process.stderr.write('stderr', function() {
process.exit(42); 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; return;
} }
// Run the script in a shell but close stdout and stderr. // Run the script in a shell but close stdout and stderr.
var cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
var proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
proc.on('exit', common.mustCall(function(exitCode) { proc.on('exit', common.mustCall(function(exitCode) {
assert.equal(exitCode, 42); assert.strictEqual(exitCode, common.isAix ? 126 : 42);
})); }));

Loading…
Cancel
Save