run_tests.sh 927 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
#/bin/bash -f
test_num=0
failed_test=""
rc=0
test_bins="test_butil test_bvar bthread*unittest brpc*unittest"
for test_bin in $test_bins; do
    test_num=$((test_num + 1))
    >&2 echo "[runtest] $test_bin"
    ./$test_bin
    rc=$?
11
    if [ $rc -ne 0 ]; then
12 13 14 15
        failed_test="$test_bin"
        break;
    fi
done
16
if [ $test_num -eq 0 ]; then
17 18 19
    >&2 echo "[runtest] Cannot find any tests"
    exit 1
fi
20 21 22 23 24 25
print_bt () {
    COREFILE=$(find . -maxdepth 2 -name "core*" | head -n 1) # find core file
    if [[ -f "$COREFILE" ]]; then
        gdb -c "$COREFILE" $1 -ex "thread apply all bt" -ex "set pagination 0" -batch;
    fi
}
26
if [ -z "$failed_test" ]; then
27
    >&2 echo "[runtest] $test_num succeeded"
28
elif [ $test_num -gt 1 ]; then
29
    print_bt $failed_test
30 31
    >&2 echo "[runtest] '$failed_test' failed, $((test_num-1)) succeeded"
else
32
    print_bt $failed_test
33 34 35
    >&2 echo "[runtest] '$failed_test' failed"
fi
exit $rc