@@ -32,54 +32,57 @@ def __call_process(arg):
32
32
33
33
34
34
def test_assert ():
35
- _ , stdout , stderr = __call_process ('assert' )
35
+ exitcode , stdout , stderr = __call_process ('assert' )
36
36
if sys .platform == "darwin" :
37
37
assert stderr .startswith ("Assertion failed: (false), function my_assert, file test-signalhandler.cpp, line " ), stderr
38
38
else :
39
- assert stderr .endswith ("test-signalhandler.cpp:34 : void my_assert(): Assertion `false' failed.\n " ), stderr
39
+ assert stderr .endswith ("test-signalhandler.cpp:41 : void my_assert(): Assertion `false' failed.\n " ), stderr
40
40
lines = stdout .splitlines ()
41
41
assert lines [0 ] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
42
- # no stacktrace of MacOs
42
+ # no stacktrace of macOS
43
43
if sys .platform != "darwin" :
44
44
assert lines [1 ] == 'Callstack:'
45
45
assert lines [2 ].endswith ('my_abort()' ), lines [2 ] # TODO: wrong function
46
46
assert lines [len (lines )- 1 ] == 'Please report this to the cppcheck developers!'
47
+ assert exitcode == - 6
47
48
48
49
49
50
def test_abort ():
50
- _ , stdout , _ = __call_process ('abort' )
51
+ exitcode , stdout , _ = __call_process ('abort' )
51
52
lines = stdout .splitlines ()
52
53
assert lines [0 ] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
53
- # no stacktrace on MaCos
54
+ # no stacktrace on macOS
54
55
if sys .platform != "darwin" :
55
56
assert lines [1 ] == 'Callstack:'
56
57
assert lines [2 ].endswith ('my_segv()' ), lines [2 ] # TODO: wrong function
57
58
assert lines [len (lines )- 1 ] == 'Please report this to the cppcheck developers!'
59
+ assert exitcode == - 6
58
60
59
61
60
62
def test_segv ():
61
- _ , stdout , stderr = __call_process ('segv' )
63
+ exitcode , stdout , stderr = __call_process ('segv' )
62
64
assert stderr == ''
63
65
lines = stdout .splitlines ()
64
66
if sys .platform == "darwin" :
65
67
assert lines [0 ] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (at 0x0).'
66
68
else :
67
69
assert lines [0 ] == 'Internal error: cppcheck received signal SIGSEGV - SEGV_MAPERR (reading at 0x0).'
68
- # no stacktrace on MacOS
70
+ # no stacktrace on macOS
69
71
if sys .platform != "darwin" :
70
72
assert lines [1 ] == 'Callstack:'
71
73
assert lines [2 ].endswith ('my_segv()' ), lines [2 ] # TODO: wrong function
72
74
assert lines [len (lines )- 1 ] == 'Please report this to the cppcheck developers!'
75
+ assert exitcode == - 11
73
76
74
77
75
- # TODO: make this work
76
- @pytest .mark .skip
78
+ @pytest .mark .skipif (sys .platform == 'darwin' , reason = 'Cannot raise FPE on macOS' )
77
79
def test_fpe ():
78
- _ , stdout , stderr = __call_process ('fpe' )
80
+ exitcode , stdout , stderr = __call_process ('fpe' )
79
81
assert stderr == ''
80
82
lines = stdout .splitlines ()
81
- assert lines [0 ].startswith ('Internal error: cppcheck received signal SIGFPE - FPE_FLTDIV (at 0x7f ' ), lines [0 ]
83
+ assert lines [0 ].startswith ('Internal error: cppcheck received signal SIGFPE - FPE_FLTINV (at 0x ' ), lines [0 ]
82
84
assert lines [0 ].endswith (').' ), lines [0 ]
83
85
assert lines [1 ] == 'Callstack:'
84
- assert lines [2 ].endswith ('my_fpe()' ), lines [2 ]
86
+ assert lines [3 ].endswith ('my_fpe()' ), lines [2 ]
85
87
assert lines [len (lines )- 1 ] == 'Please report this to the cppcheck developers!'
88
+ assert exitcode == - 8
0 commit comments