update readme
[c11concurrency-benchmarks.git] / tsan11-missingbug / test.sh
1 #!/bin/bash
2
3 EXE=$1
4 TOTAL_RUN=1000
5 CDSLIB="/home/vagrant/c11tester"
6 export LD_LIBRARY_PATH=${CDSLIB}
7 export C11TESTER='-x1'
8
9 COUNT_ASSERT=0
10 COUNT_TIME=0
11
12 for i in `seq 1 1 $TOTAL_RUN` ; do
13   OUTPUT="$(/usr/bin/time -f "time: %U %S" $EXE 2>&1)"
14   ASSERT="$(echo "$OUTPUT" | grep "Assertion")"
15   if [ -n "$ASSERT" ] ; then
16     ((++COUNT_ASSERT))
17   fi
18
19   TIME="$(echo "$OUTPUT" | grep -o "time: .\... .\...")"
20   TIME_USER_S="$(echo "$TIME" | cut -d' ' -f2 | cut -d'.' -f1)"
21   TIME_USER_CS="$(echo "$TIME" | cut -d' ' -f2 | cut -d'.' -f2)"
22   TIME_SYSTEM_S="$(echo "$TIME" | cut -d' ' -f3 | cut -d'.' -f1)"
23   TIME_SYSTEM_CS="$(echo "$TIME" | cut -d' ' -f3 | cut -d'.' -f2)"
24
25   TIME_EXE=$((10#$TIME_USER_S * 1000 + 10#$TIME_USER_CS * 10 + 10#$TIME_SYSTEM_S * 1000 + 10#$TIME_SYSTEM_CS * 10))
26   COUNT_TIME=$((COUNT_TIME + TIME_EXE))
27 done
28
29 AVG_ASSERT=$(echo "${COUNT_ASSERT} * 100 / ${TOTAL_RUN}" | bc -l | xargs printf "%.1f")
30
31 # -3 / log(1 - p) < n
32 echo "Runs: $TOTAL_RUN | Assertions: $COUNT_ASSERT | Total time: ${COUNT_TIME}ms | Assert rate: ${AVG_ASSERT}%"
33 rm C11FuzzerTmp*  2> /dev/null