Skip to content

Commit

Permalink
test: accept expected AIX result test-stdio-closed
Browse files Browse the repository at this point in the history
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: #8375
PR-URL: #8755
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
  • Loading branch information
Trott authored and rvagg committed Oct 18, 2016
1 parent 28f4784 commit 47ada06
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ test-fs-watch-enoent : FAIL, PASS
# Disable so we don't get failures now that AIX has been
# added to regular CI runs
test-regress-GH-1899 : FAIL, PASS
test-stdio-closed : FAIL, PASS

# Flaky until https://github.com/nodejs/build/issues/415 is resolved.
# On some of the buildbots, AAAA queries for localhost don't resolve
Expand Down
30 changes: 20 additions & 10 deletions test/parallel/test-stdio-closed.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
'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.');
return;
}

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);
}));

0 comments on commit 47ada06

Please sign in to comment.