|
1 | 1 | #!/bin/bash -ex |
2 | 2 |
|
3 | | -TRACE="cmsTraceFunction --startAfterFunction ScheduleItems::initMisc setenv -f putenv --abort" |
| 3 | +TRACE="cmsTraceFunction --startAfterFunction ScheduleItems::initMisc setenv -f putenv" |
4 | 4 |
|
5 | 5 | check_func() { |
6 | 6 | local func_name="$1" |
7 | 7 | local src_name="$2" |
| 8 | + local trace_opts="$3" |
8 | 9 | local exe_name="test-cmsTraceFunction-${func_name}" |
9 | 10 | local raw_log="${func_name}_raw.log" |
10 | 11 | local log="${func_name}.log" |
11 | 12 |
|
12 | 13 | g++ -o "$exe_name" "$(dirname $0)/$src_name" |
13 | 14 | set +e |
14 | | - $TRACE ./$exe_name 2>&1 > "$raw_log" |
| 15 | + $TRACE $trace_opts ./$exe_name 2>&1 > "$raw_log" |
15 | 16 | local ret=$? |
16 | 17 | set -e |
17 | 18 | grep "$func_name" "$raw_log" > "$log" |
18 | 19 |
|
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 |
22 | 36 | fi |
23 | 37 |
|
24 | 38 | local call_count=$(grep -c "^${func_name}() called" "$log") |
25 | 39 | 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}" |
28 | 42 | exit 1 |
29 | 43 | fi |
30 | 44 | } |
31 | 45 |
|
32 | 46 | # 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 | + |
34 | 50 |
|
35 | 51 | # 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