Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e9915e

Browse filesBrowse files
RafaelGSStargos
authored andcommitted
test: include strace openat test
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: #46150 Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent 60d1a48 commit 4e9915e
Copy full SHA for 4e9915e

File tree

Expand file treeCollapse file tree

3 files changed

+64
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+64
-0
lines changed
Open diff view settings
Collapse file

‎.github/workflows/test-asan.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/test-asan.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545
CXX: clang++
4646
LINK: clang++
4747
CONFIG_FLAGS: --enable-asan
48+
ASAN: true
4849
steps:
4950
- uses: actions/checkout@v3
5051
with:
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const isFreeBSD = process.platform === 'freebsd';
120120
const isOpenBSD = process.platform === 'openbsd';
121121
const isLinux = process.platform === 'linux';
122122
const isOSX = process.platform === 'darwin';
123+
const isAsan = process.env.ASAN !== undefined;
123124
const isPi = (() => {
124125
try {
125126
// Normal Raspberry Pi detection is to find the `Raspberry Pi` string in
@@ -900,6 +901,7 @@ const common = {
900901
invalidArgTypeHelper,
901902
isAIX,
902903
isAlive,
904+
isAsan,
903905
isDumbTerminal,
904906
isFreeBSD,
905907
isLinux,
Collapse file
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const { spawn, spawnSync } = require('node:child_process');
5+
const { createInterface } = require('node:readline');
6+
const assert = require('node:assert');
7+
8+
if (!common.hasCrypto)
9+
common.skip('missing crypto');
10+
if (!common.isLinux)
11+
common.skip('linux only');
12+
if (common.isAsan)
13+
common.skip('strace does not work well with address sanitizer builds');
14+
if (spawnSync('strace').error !== undefined) {
15+
common.skip('missing strace');
16+
}
17+
18+
{
19+
const allowedOpenCalls = new Set([
20+
'/etc/ssl/openssl.cnf',
21+
]);
22+
const strace = spawn('strace', [
23+
'-f', '-ff',
24+
'-e', 'trace=open,openat',
25+
'-s', '512',
26+
'-D', process.execPath, '-e', 'require("crypto")',
27+
]);
28+
29+
// stderr is the default for strace
30+
const rl = createInterface({ input: strace.stderr });
31+
rl.on('line', (line) => {
32+
if (!line.startsWith('open')) {
33+
return;
34+
}
35+
36+
const file = line.match(/"(.*?)"/)[1];
37+
// skip .so reading attempt
38+
if (file.match(/.+\.so(\.?)/) !== null) {
39+
return;
40+
}
41+
// skip /proc/*
42+
if (file.match(/\/proc\/.+/) !== null) {
43+
return;
44+
}
45+
46+
assert(allowedOpenCalls.delete(file), `${file} is not in the list of allowed openat calls`);
47+
});
48+
const debugOutput = [];
49+
strace.stderr.setEncoding('utf8');
50+
strace.stderr.on('data', (chunk) => {
51+
debugOutput.push(chunk.toString());
52+
});
53+
strace.on('error', common.mustNotCall());
54+
strace.on('exit', common.mustCall((code) => {
55+
assert.strictEqual(code, 0, debugOutput);
56+
const missingKeys = Array.from(allowedOpenCalls.keys());
57+
if (missingKeys.length) {
58+
assert.fail(`The following openat call are missing: ${missingKeys.join(',')}`);
59+
}
60+
}));
61+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.