Skip to content

Commit 7c6eb1d

Browse files
committed
avoid temporary file for strace output
1 parent 50e8a1f commit 7c6eb1d

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎test/cli/other_test.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,7 +4865,6 @@ def test_ipc_inline_suppressions(tmp_path):
48654865

48664866
def __count_openat_calls(tmpdir, flags, expected):
48674867
source_pathname = os.path.join(tmpdir, 'test.c')
4868-
strace_pathname = os.path.join(tmpdir, 'strace.txt')
48694868
content = """
48704869
void f(int x) {
48714870
int y = x / 0;
@@ -4883,22 +4882,19 @@ def __count_openat_calls(tmpdir, flags, expected):
48834882
'--summary-columns=count',
48844883
'--trace=openat',
48854884
'--follow-forks',
4886-
f'--output={strace_pathname}',
48874885
f'--trace-path={source_pathname}',
48884886
cppcheck_path,
48894887
'-q',
48904888
source_pathname,
48914889
]
48924890

48934891
args += flags
4894-
proc = subprocess.run(args, check=False)
4892+
proc = subprocess.Popen(args, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
48954893

4896-
assert proc.returncode == 0
4897-
4898-
with open(strace_pathname, 'r') as f:
4899-
strace_content = f.read()
4894+
_, stderr = proc.communicate()
49004895

4901-
assert strace_content.splitlines()[-1].strip() == f'{expected} total'
4896+
assert proc.returncode == 0
4897+
assert stderr.splitlines()[-1].strip() == f'{expected} total'.encode('utf-8')
49024898

49034899
__strace_decorator = pytest.mark.skipif(
49044900
sys.platform != 'linux' or 'ASAN_OPTIONS' in os.environ,

0 commit comments

Comments
 (0)