From a03165a5fd5ab0325eec506e346f6ec5db46780d Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 30 Oct 2018 16:59:53 -0700 Subject: 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 Reviewed-By: Luigi Pinca --- test/sequential/test-fs-watch-system-limit.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/sequential') diff --git a/test/sequential/test-fs-watch-system-limit.js b/test/sequential/test-fs-watch-system-limit.js index e896cbf83b..8b9cb62ad0 100644 --- a/test/sequential/test-fs-watch-system-limit.js +++ b/test/sequential/test-fs-watch-system-limit.js @@ -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'); -- cgit v1.2.3