Skip to content

Commit 85c8b76

Browse files
authored
Fix flakiness in other.test_unistd_close_noderawfs (#16888)
By looking only for file descriptors pointing to the current test directory (i.e. exclude the internal file descriptors of Node). And forward stdin/stderr to `/dev/null`, we are only interested in `stdout`. So: ``` find /proc/<PROCESS>/fd -lname "<DIR>*" -printf "%l\n" || true ``` Instead of: ``` find /proc/<PROCESS>/fd -lname "<DIR>*" -printf "%l " || true ``` Fixes: #16887.
1 parent e749f23 commit 85c8b76

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tests/test_other.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11652,19 +11652,22 @@ def test_unistd_fstatfs(self):
1165211652
@require_node
1165311653
def test_unistd_close_noderawfs(self):
1165411654
self.set_setting('NODERAWFS')
11655-
create_file('pre.js', '''
11656-
const { execSync } = require('child_process');
11655+
create_file('pre.js', f'''
11656+
const {{ execSync }} = require('child_process');
1165711657
const process = require('process');
1165811658
11659+
const cmd = 'find /proc/' + process.pid + '/fd -lname "{self.get_dir()}*" -printf "%l\\\\n" || true';
1165911660
let openFilesPre;
1166011661
11661-
Module['preRun'] = function() {
11662-
openFilesPre = execSync('ls -l /proc/' + process.pid + '/fd | wc -l').toString();
11663-
}
11664-
Module['postRun'] = function() {
11665-
const openFilesPost = execSync('ls -l /proc/' + process.pid + '/fd | wc -l').toString();
11666-
assert(openFilesPre == openFilesPost, 'File descriptors should not leak');
11667-
}
11662+
Module['preRun'] = function() {{
11663+
openFilesPre = execSync(cmd, {{ stdio: ['ignore', 'pipe', 'ignore'] }}).toString();
11664+
}}
11665+
Module['postRun'] = function() {{
11666+
const openFilesPost = execSync(cmd, {{ stdio: ['ignore', 'pipe', 'ignore'] }}).toString();
11667+
assert(openFilesPre == openFilesPost, 'File descriptors should not leak. \\n' +
11668+
'Pre: \\n' + openFilesPre +
11669+
'Post: \\n' + openFilesPost);
11670+
}}
1166811671
''')
1166911672
self.emcc_args += ['--pre-js', 'pre.js']
1167011673
self.do_run_in_out_file_test('unistd/close.c')

0 commit comments

Comments
 (0)