aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Bevenius <daniel.bevenius@gmail.com>2018-04-06 12:22:03 +0200
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-04-11 08:15:14 +0200
commit398968297ae387714431d3e1c6ff0f0cb24807d8 (patch)
treea7a9a11647d63930efadc4113bd40f162f663d46 /test
parent42d8976dff0e5a5f21d6c89457f348d9fdfd26fe (diff)
downloadandroid-node-v8-398968297ae387714431d3e1c6ff0f0cb24807d8.tar.gz
android-node-v8-398968297ae387714431d3e1c6ff0f0cb24807d8.tar.bz2
android-node-v8-398968297ae387714431d3e1c6ff0f0cb24807d8.zip
test: add check for root user
Currently this test fails if run as the root user: Mismatched innerFn function calls. Expected exactly 62, actual 42. The motivation for this is that when building node in a docker container it is convenient to be able to build as root. PR-URL: https://github.com/nodejs/node/pull/19850 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-child-process-spawnsync-validation-errors.js23
1 files changed, 5 insertions, 18 deletions
diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js
index c12476c042..17545d4af7 100644
--- a/test/parallel/test-child-process-spawnsync-validation-errors.js
+++ b/test/parallel/test-child-process-spawnsync-validation-errors.js
@@ -3,18 +3,11 @@ const common = require('../common');
const assert = require('assert');
const spawnSync = require('child_process').spawnSync;
const signals = process.binding('constants').os.signals;
+const rootUser = common.isWindows ? false : process.getuid() === 0;
-let invalidArgTypeError;
-let invalidArgTypeErrorCount = 62;
-
-if (common.isWindows) {
- invalidArgTypeError =
- common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 42);
-} else {
- invalidArgTypeError =
- common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError },
- invalidArgTypeErrorCount);
-}
+const invalidArgTypeError = common.expectsError(
+ { code: 'ERR_INVALID_ARG_TYPE', type: TypeError },
+ common.isWindows || rootUser ? 42 : 62);
const invalidRangeError =
common.expectsError({ code: 'ERR_OUT_OF_RANGE', type: RangeError }, 20);
@@ -64,7 +57,7 @@ function fail(option, value, message) {
if (!common.isWindows) {
{
// Validate the uid option
- if (process.getuid() !== 0) {
+ if (!rootUser) {
pass('uid', undefined);
pass('uid', null);
pass('uid', process.getuid());
@@ -78,9 +71,6 @@ if (!common.isWindows) {
fail('uid', Infinity, invalidArgTypeError);
fail('uid', 3.1, invalidArgTypeError);
fail('uid', -3.1, invalidArgTypeError);
- } else {
- // Decrement invalidArgTypeErrorCount if validation isn't possible
- invalidArgTypeErrorCount -= 10;
}
}
@@ -100,9 +90,6 @@ if (!common.isWindows) {
fail('gid', Infinity, invalidArgTypeError);
fail('gid', 3.1, invalidArgTypeError);
fail('gid', -3.1, invalidArgTypeError);
- } else {
- // Decrement invalidArgTypeErrorCount if validation isn't possible
- invalidArgTypeErrorCount -= 10;
}
}
}