Skip to content

Commit 8bffd90

Browse files
ofrobotstargos
authored andcommitted
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: #23986 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b8a71be commit 8bffd90

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/sequential/test-fs-watch-system-limit.js

+15
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,28 @@
22
const common = require('../common');
33
const assert = require('assert');
44
const child_process = require('child_process');
5+
const fs = require('fs');
56
const stream = require('stream');
67

78
if (!common.isLinux)
89
common.skip('The fs watch limit is OS-dependent');
910
if (!common.enoughTestCpu)
1011
common.skip('This test is resource-intensive');
1112

13+
try {
14+
// Ensure inotify limit is low enough for the test to actually exercise the
15+
// limit with small enough resources.
16+
const limit = Number(
17+
fs.readFileSync('/proc/sys/fs/inotify/max_user_watches', 'utf8'));
18+
if (limit > 16384)
19+
common.skip('inotify limit is quite large');
20+
} catch (e) {
21+
if (e.code === 'ENOENT')
22+
common.skip('the inotify /proc subsystem does not exist');
23+
// Fail on other errors.
24+
throw e;
25+
}
26+
1227
const processes = [];
1328
const gatherStderr = new stream.PassThrough();
1429
gatherStderr.setEncoding('utf8');

0 commit comments

Comments
 (0)