FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: only check fd 0,1,2 are used and not their access modes by jBarz · Pull Request #10339 · nodejs/node · GitHub

/ node Public

test: only check fd 0,1,2 are used and not their access modes - #10339

Closed
jBarz wants to merge 1 commit into
nodejs:masterfrom
jBarz:aix-stdio-closed.2
Closed

test: only check fd 0,1,2 are used and not their access modes#10339
jBarz wants to merge 1 commit into
nodejs:masterfrom
jBarz:aix-stdio-closed.2

Conversation

jBarz commented Dec 19, 2016
edited by gibfahn
Loading

Copy link
Copy Markdown
Contributor

Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only access by the user.
What this test needs to only ensure is that they are used at startup.

Checklist
  • make -j4 test (UNIX)
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

test

Description of change

Fixes: #10234

nodejs-github-bot added test Issues and PRs related to the tests. lts-watch-v6.x labels Dec 19, 2016

sam-github left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks like a good approach to me.

Comment thread test/parallel/test-stdio-closed.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should check 0 as well (the original didn't, possibly because its hard to do if input is unavailable).

jBarz force-pushed the aix-stdio-closed.2 branch from dbd9df8 to 3c49228 Compare December 19, 2016 16:03
jBarz force-pushed the aix-stdio-closed.2 branch from 3c49228 to 76773e2 Compare December 19, 2016 16:04
jBarz changed the title test: only check that fd 1,2 are used and not their access modes test: only check fd 0,1,2 are used and not their access modes Dec 19, 2016
mscdex added the child_process Issues and PRs related to the child_process subsystem. label Dec 19, 2016

gibfahn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could you make the first line of the commit message <50 chars?

While you're at it, you can add this to the commit:

Fixes: https://github.com/nodejs/node/issues/10234

jBarz commented Dec 19, 2016

Copy link
Copy Markdown
Contributor Author

Fixed first line of commit message and added following
Fixes #10234

gibfahn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copy link
Copy Markdown
Contributor

Is the original behavior good to preserve for non-AIX platforms in a different test case?

I think this follows the test name but has fundamentally different behavior.

jBarz commented Dec 19, 2016

Copy link
Copy Markdown
Contributor Author

IMO, we don't need to preserve the original behavior because on any system, fd=1 doesn't have to be writable. So the original test-case was making an incorrect assumption.

Copy link
Copy Markdown
Contributor

The original test was asserting things that b5f25a9 did not in fact guarantee. What b5f25a9 did do is described as

Check that stdin, stdout and stderr map to open file descriptors

However, the test checked that stdout and stderr were writeable (something the c++ code does not check), and didn't do any check at all for stdin. This version of the test asserts that 0,1,2 map to open fds, which is exactly what is intended, and does it using fstat(), which is exactly what the code-under-test does:

node/src/node.cc

Line 4058 in 5d14602

if (fstat(fd, &ignored) == 0)

Seems perfect to me.

Comment thread test/parallel/test-stdio-closed.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If this is being rewritten anyway, rather than try-catch could it instead be using assert.doesNotThrow? I'm also personally not a fan of the magic process exit values (42 and 126) -- Doesn't an uncaught assertion failure cause a non-zero exit code which we can check in the parent?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

it does, status is 1 on uncaught exception

gibfahn commented Dec 19, 2016

Copy link
Copy Markdown
Member

cc/ @sxa555 @Trott @nodejs/platform-aix for review

Comment thread test/parallel/test-stdio-closed.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The 0 is unnecessary here.

gibfahn self-assigned this Jan 23, 2017

gibfahn commented Jan 23, 2017

Copy link
Copy Markdown
Member

Another CI just to confirm: https://ci.nodejs.org/job/node-test-commit/7423/

Comment thread test/parallel/test-stdio-closed.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Extremely minor nit... this can be much more succinctly written...

[0,1,2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i)));

But not necessary to land :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Will land. I like succinctness :-)

Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. What this test needs to only ensure is that
they are used at startup.
This fixes nodejs#10234

gibfahn commented Jan 23, 2017
edited
Loading

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-commit/7430/

EDIT: Windows job is hanging, looks like a machine issue, otherwise good.

gibfahn commented Jan 23, 2017

Copy link
Copy Markdown
Member

Landed in 106d09a

gibfahn closed this Jan 23, 2017
gibfahn pushed a commit that referenced this pull request Jan 23, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: #10339
Fixes: #10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
jBarz deleted the aix-stdio-closed.2 branch January 23, 2017 20:04
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 25, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: nodejs#10339
Fixes: nodejs#10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 27, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: nodejs#10339
Fixes: nodejs#10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas mentioned this pull request Jan 29, 2017
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: nodejs#10339
Fixes: nodejs#10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 30, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: nodejs#10339
Fixes: nodejs#10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 8, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: #10339
Fixes: #10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 8, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: #10339
Fixes: #10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: #10339
Fixes: #10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins mentioned this pull request Mar 9, 2017
MylesBorins pushed a commit that referenced this pull request Mar 9, 2017
Don't do a write on stdout/stderr because that checks for their
writability. But fd=1 could legitimately be opened with read-only
access by the user. All this test needs to ensure is that
they are used at startup.

PR-URL: #10339
Fixes: #10234
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins mentioned this pull request Mar 9, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

child_process Issues and PRs related to the child_process subsystem. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-stdio-closed failing on some AIX environments

Back | FazBrowse Home | New Git URL