Skip to content

Commit f388711

Browse files
committed
Extend test to cover no-abort option as well
1 parent 463184a commit f388711

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,53 @@
11
#!/bin/bash -ex
22

3-
TRACE="cmsTraceFunction --startAfterFunction ScheduleItems::initMisc setenv -f putenv --abort"
3+
TRACE="cmsTraceFunction --startAfterFunction ScheduleItems::initMisc setenv -f putenv"
44

55
check_func() {
66
local func_name="$1"
77
local src_name="$2"
8+
local trace_opts="$3"
89
local exe_name="test-cmsTraceFunction-${func_name}"
910
local raw_log="${func_name}_raw.log"
1011
local log="${func_name}.log"
1112

1213
g++ -o "$exe_name" "$(dirname $0)/$src_name"
1314
set +e
14-
$TRACE ./$exe_name 2>&1 > "$raw_log"
15+
$TRACE $trace_opts ./$exe_name 2>&1 > "$raw_log"
1516
local ret=$?
1617
set -e
1718
grep "$func_name" "$raw_log" > "$log"
1819

19-
if [ ${ret} = 0 ]; then
20-
echo "cmsTraceFunction exited with exit code 0, expected non-zero exit code"
21-
exit 1
20+
if [ ${trace_opts} = "--abort" ]; then
21+
call_count_expected=1
22+
break_count_expected=1
23+
24+
if [ ${ret} = 0 ]; then
25+
echo "cmsTraceFunction exited with exit code 0, expected non-zero exit code"
26+
exit 1
27+
fi
28+
else
29+
call_count_expected=3
30+
break_count_expected=2
31+
32+
if [ ${ret} != 0 ]; then
33+
echo "cmsTraceFunction exited with exit code $ret, expected zero exit code"
34+
exit 1
35+
fi
2236
fi
2337

2438
local call_count=$(grep -c "^${func_name}() called" "$log")
2539
local break_count=$(grep -c "Breakpoint .* in ${func_name} ()" "$log")
26-
if [ ${call_count} != 1 ] || [ ${break_count} != 1 ] ; then
27-
echo "Unexpected number of ${func_name} calls ${call_count} or breakpoints ${break_count}; expecting both to be 1"
40+
if [ ${call_count} != ${call_count_expected} ] || [ ${break_count} != ${break_count_expected} ] ; then
41+
echo "Unexpected number of ${func_name} calls ${call_count} or breakpoints ${break_count}; expecting calls ${call_count_expected} and breakpoints ${break_count_expected}"
2842
exit 1
2943
fi
3044
}
3145

3246
# Check setenv
33-
check_func "setenv" "test-cmsTraceFunction-setenv.cpp"
47+
check_func "setenv" "test-cmsTraceFunction-setenv.cpp" ""
48+
check_func "setenv" "test-cmsTraceFunction-setenv.cpp" "--abort"
49+
3450

3551
# Check putenv
36-
check_func "putenv" "test-cmsTraceFunction-putenv.cpp"
52+
check_func "putenv" "test-cmsTraceFunction-putenv.cpp" ""
53+
check_func "putenv" "test-cmsTraceFunction-putenv.cpp" "--abort"

0 commit comments

Comments
 (0)