mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
test: add fix so that test exits if port 42 is unprivileged
PR-URL: https://github.com/nodejs/node/pull/45904 Fixes: https://github.com/nodejs/node/issues/45838 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
5c350298b4
commit
4f491d368c
1 file changed
+12
-4
@@ -21,6 +21,18 @@
|
||||
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const cluster = require('cluster');
|
||||
const net = require('net');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
if (common.isLinux) {
|
||||
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
|
||||
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[2], 10);
|
||||
if (unprivilegedPortStart <= 42) {
|
||||
common.skip('Port 42 is unprivileged');
|
||||
}
|
||||
}
|
||||
|
||||
// Skip on OS X Mojave. https://github.com/nodejs/node/issues/21679
|
||||
if (common.isOSX)
|
||||
@@ -35,10 +47,6 @@ if (common.isWindows)
|
||||
if (process.getuid() === 0)
|
||||
common.skip('Test is not supposed to be run as root.');
|
||||
|
||||
const assert = require('assert');
|
||||
const cluster = require('cluster');
|
||||
const net = require('net');
|
||||
|
||||
if (cluster.isPrimary) {
|
||||
cluster.fork().on('exit', common.mustCall((exitCode) => {
|
||||
assert.strictEqual(exitCode, 0);
|
||||
|
||||
Reference in new issue
Block a user