Skip to content

Commit

Permalink
test: fix test-fs-watch-system-limit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ofrobots authored and rvagg committed Nov 28, 2018
1 parent 823b8b9 commit e283919
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/sequential/test-fs-watch-system-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@
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)
common.skip('The fs watch limit is OS-dependent');
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');
Expand Down

0 comments on commit e283919

Please sign in to comment.