test: fix test-fs-watch-system-limit

On some systems the default inotify limits might be too high for the
test to actually fail. Detect and skip the test in such environments.

PR-URL: https://github.com/nodejs/node/pull/23986
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Ali Ijaz Sheikh 2018-10-30 16:59:53 -07:00 committed by Rich Trott
parent 67d74e400b
commit a03165a5fd

View File

@ -2,6 +2,7 @@
const common = require('../common');
const assert = require('assert');
const child_process = require('child_process');
const fs = require('fs');
const stream = require('stream');
if (!common.isLinux)
@ -9,6 +10,20 @@ if (!common.isLinux)
if (!common.enoughTestCpu)
common.skip('This test is resource-intensive');
try {
// Ensure inotify limit is low enough for the test to actually exercise the
// limit with small enough resources.
const limit = Number(
fs.readFileSync('/proc/sys/fs/inotify/max_user_watches', 'utf8'));
if (limit > 16384)
common.skip('inotify limit is quite large');
} catch (e) {
if (e.code === 'ENOENT')
common.skip('the inotify /proc subsystem does not exist');
// Fail on other errors.
throw e;
}
const processes = [];
const gatherStderr = new stream.PassThrough();
gatherStderr.setEncoding('utf8');