Skip to content

Commit

Permalink
Fix flakiness in other.test_unistd_close_noderawfs (#16888)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kleisauke authored May 20, 2022
1 parent e749f23 commit 85c8b76
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -11652,19 +11652,22 @@ def test_unistd_fstatfs(self):
@require_node
def test_unistd_close_noderawfs(self):
self.set_setting('NODERAWFS')
create_file('pre.js', '''
const { execSync } = require('child_process');
create_file('pre.js', f'''
const {{ execSync }} = require('child_process');
const process = require('process');
const cmd = 'find /proc/' + process.pid + '/fd -lname "{self.get_dir()}*" -printf "%l\\\\n" || true';
let openFilesPre;
Module['preRun'] = function() {
openFilesPre = execSync('ls -l /proc/' + process.pid + '/fd | wc -l').toString();
}
Module['postRun'] = function() {
const openFilesPost = execSync('ls -l /proc/' + process.pid + '/fd | wc -l').toString();
assert(openFilesPre == openFilesPost, 'File descriptors should not leak');
}
Module['preRun'] = function() {{
openFilesPre = execSync(cmd, {{ stdio: ['ignore', 'pipe', 'ignore'] }}).toString();
}}
Module['postRun'] = function() {{
const openFilesPost = execSync(cmd, {{ stdio: ['ignore', 'pipe', 'ignore'] }}).toString();
assert(openFilesPre == openFilesPost, 'File descriptors should not leak. \\n' +
'Pre: \\n' + openFilesPre +
'Post: \\n' + openFilesPost);
}}
''')
self.emcc_args += ['--pre-js', 'pre.js']
self.do_run_in_out_file_test('unistd/close.c')
Expand Down

0 comments on commit 85c8b76

Please sign in to comment.