Skip to content

Commit ef72a3c

Browse files
committed
test-signalhandler: assert exitcode
1 parent 3780314 commit ef72a3c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: test/signal/test-signalhandler.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __call_process(arg):
3232

3333

3434
def test_assert():
35-
_, stdout, stderr = __call_process('assert')
35+
exitcode, stdout, stderr = __call_process('assert')
3636
if sys.platform == "darwin":
3737
assert stderr.startswith("Assertion failed: (false), function my_assert, file test-signalhandler.cpp, line "), stderr
3838
else:
@@ -44,21 +44,23 @@ def test_assert():
4444
assert lines[1] == 'Callstack:'
4545
assert lines[2].endswith('my_abort()'), lines[2] # TODO: wrong function
4646
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
47+
assert exitcode == -6
4748

4849

4950
def test_abort():
50-
_, stdout, _ = __call_process('abort')
51+
exitcode, stdout, _ = __call_process('abort')
5152
lines = stdout.splitlines()
5253
assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
5354
# no stacktrace on macOS
5455
if sys.platform != "darwin":
5556
assert lines[1] == 'Callstack:'
5657
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
5758
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
59+
assert exitcode == -6
5860

5961

6062
def test_segv():
61-
_, stdout, stderr = __call_process('segv')
63+
exitcode, stdout, stderr = __call_process('segv')
6264
assert stderr == ''
6365
lines = stdout.splitlines()
6466
if sys.platform == "darwin":
@@ -70,15 +72,17 @@ def test_segv():
7072
assert lines[1] == 'Callstack:'
7173
assert lines[2].endswith('my_segv()'), lines[2] # TODO: wrong function
7274
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
75+
assert exitcode == -11
7376

7477

7578
@pytest.mark.skipif(sys.platform == 'darwin', reason='Cannot raise FPE on macOS')
7679
def test_fpe():
77-
_, stdout, stderr = __call_process('fpe')
80+
exitcode, stdout, stderr = __call_process('fpe')
7881
assert stderr == ''
7982
lines = stdout.splitlines()
8083
assert lines[0].startswith('Internal error: cppcheck received signal SIGFPE - FPE_FLTINV (at 0x'), lines[0]
8184
assert lines[0].endswith(').'), lines[0]
8285
assert lines[1] == 'Callstack:'
8386
assert lines[3].endswith('my_fpe()'), lines[2]
8487
assert lines[len(lines)-1] == 'Please report this to the cppcheck developers!'
88+
assert exitcode == -8

0 commit comments

Comments
 (0)