Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added input validation test for fchmod #18217

Closed
wants to merge 3 commits into from

Conversation

lucamaraschi
Copy link
Contributor

Added a test to ensure input validation for FD and mode for fs.fchmod.
Removed check for values lower than 0 for mode as it's already checked
by validateUint32.

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

test, fs

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Jan 18, 2018
@jasnell
Copy link
Member

jasnell commented Jan 18, 2018

Hey look @cjihrig ... @lucamaraschi submitted a test case! How many more does he have to go ;-)

@cjihrig
Copy link
Contributor

cjihrig commented Jan 18, 2018

@jasnell if my math is right, 90 once this lands.

@BridgeAR
Copy link
Member

@jasnell @cjihrig I am working on reducing that number:

BridgeAR [7:46 PM]
If you write at least three tests each day, I will not remind you at all! Think about that! :smile:
Luca Maraschi [7:47 PM]
3 tests a day, keep Ruben away!

@addaleax
Copy link
Member

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Jan 18, 2018
@addaleax
Copy link
Member

CI complains about a syntax error:

/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/parallel/test-fs-fchmod.js:47
common.mustCall(() => fs.fchmod(1, modeUpperBoundaryValue);
                                                         ^

SyntaxError: missing ) after argument list
    at new Script (vm.js:50:7)
    at createScript (vm.js:137:10)
    at Object.runInThisContext (vm.js:185:10)
    at Module._compile (module.js:628:28)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:577:32)
    at tryModuleLoad (module.js:517:12)
    at Function.Module._load (module.js:509:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:194:16)

// Check for mode values range
const modeUpperBoundaryValue = 0o777;
common.mustCall(() => fs.fchmod(1, modeUpperBoundaryValue);
common.mustCall(() => fs.fchmodSync(1, modeUpperBoundaryValue);
Copy link
Member

Choose a reason for hiding this comment

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

nit: missing parens at the end of both of these lines.

// Check for mode values range
const modeUpperBoundaryValue = 0o777;
common.mustCall(() => fs.fchmod(1, modeUpperBoundaryValue));
common.mustCall(() => fs.fchmodSync(1, modeUpperBoundaryValue));
Copy link
Member

Choose a reason for hiding this comment

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

Is it me or something is missing? The function returned by common.mustCall is never called, so I expect the test to fail.

Copy link
Member

Choose a reason for hiding this comment

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

Good point. And neither of these two entries should require being wrapped in a mustCall.

Added a test to ensure input validation for FD and mode for fs.fchmod.
Removed check for values lower than 0 for `mode` as it's already checked
by `validateUint32`.
@BridgeAR
Copy link
Member

BridgeAR commented Feb 1, 2018

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 1, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Feb 6, 2018
Added a test to ensure input validation for FD and mode for fs.fchmod.
Removed check for values lower than 0 for `mode` as it's already checked
by `validateUint32`.

PR-URL: nodejs#18217
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@BridgeAR
Copy link
Member

BridgeAR commented Feb 6, 2018

Landed in 075eef5

@lucamaraschi you are very much behind with those tests!

@MylesBorins
Copy link
Contributor

Should this be backported to v9.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants