Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: fix js-lint errors
  • Loading branch information
7suyash7 committed Dec 21, 2022
commit e9d8d6b9ed8dfc9632f85752e573d418f0d54f41
23 changes: 11 additions & 12 deletions test/parallel/test-cluster-bind-privileged-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');
const { copyFile } = require('fs');

if(common.isLinux) {
const { execSync } = require('child_process');
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[1], 10);
if(unprivilegedPortStart === 42) {
const { execSync } = require('child_process');
const sysctlOutput = execSync('sysctl net.ipv4.ip_unprivileged_port_start').toString();
Comment thread
7suyash7 marked this conversation as resolved.
Outdated
const unprivilegedPortStart = parseInt(sysctlOutput.split(' ')[1], 10);
Comment thread
7suyash7 marked this conversation as resolved.
Outdated

if (common.isLinux) {
if (unprivilegedPortStart === 42) {
Comment thread
7suyash7 marked this conversation as resolved.
Outdated
common.skip('42 is unprivileged');
Comment thread
7suyash7 marked this conversation as resolved.
Outdated
}
}
Expand All @@ -44,22 +44,21 @@ if (common.isIBMi)

if (common.isWindows)
common.skip('not reliable on Windows.');

if (process.getuid() === 0)
common.skip('Test is not supposed to be run as root.');

if (cluster.isPrimary) {
Comment thread
7suyash7 marked this conversation as resolved.
cluster.fork().on('exit', (exitCode) => {
assert.strictEqual(exitCode, 1);
});
assert.strictEqual(exitCode, 1);
});
} else {
const s = net.createServer(common.mustNotCall());
s.listen(unprivilegedPortStart, (err) => {
if (err && err.code === 'EACCES') {
process.disconnect();
} else {
process.exit(0);
}
}
});
}