-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
74 lines (63 loc) · 1.89 KB
/
test.sh
File metadata and controls
74 lines (63 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# settings to change
times=20
project="3b"
removelog=1
# don't change
if [ ! -d "./test_output" ]; then
mkdir "./test_output"
fi
logdir="./test_output/${project}"
if [ ! -d $logdir ]; then
mkdir $logdir
fi
lastdir="${logdir}/`date +%Y%m%d%H%M%S`"
if [ ! -d $lastdir ]; then
mkdir $lastdir
fi
statistics=0
totalpass=0
totalfail=0
totalpanic=0
totalruntime=0
LOG_LEVEL=fatal
summary="${lastdir}/summary.log"
echo "times. pass. fail. panic. error. runtime." >> $summary
for i in $(seq 1 $times)
do
logfile="${lastdir}/$i.log"
start=$(date +%Y-%m-%d" "%H:%M:%S)
start_s=$(date +%s)
echo "make project${project} $i times"
echo "$start begin to test" >> $logfile
LOG_LEVEL=${LOG_LEVEL} make project${project} >> $logfile
end=$(date +%Y-%m-%d" "%H:%M:%S)
end_s=$(date +%s)
runtime=$((end_s-start_s))
echo "$start begins, $end ends, total:$runtime" >> $logfile
echo "$start begins, $end ends, total:$runtime"
panic_count=0
if [ $statistics -eq 1 ]; then
fail_count=$(grep -i "fail" $logfile | wc -l)
echo "fail count: $fail_count"
panic_count=$(grep -i "panic" $logfile | wc -l)
echo "panic count: $panic_count"
error_count=$(grep -i "error" $logfile | wc -l)
echo "error count: $error_count"
fi
pass_count=$(grep -i "PASS" $logfile | wc -l)
echo "pass count: $pass_count"
echo "$i. $pass_count. $fail_count. $panic_count. $error_count. $runtime." >> $summary
totalpass=$((totalpass+pass_count))
totalfail=$((totalfail+fail_count))
totalpanic=$((totalpanic+panic_count))
totalruntime=$((totalruntime+runtime))
# if pass, remove the log
if [ $removelog -eq 1 ]; then
if [ $panic_count -lt 0 ]; then
rm $logfile
fi
sleep 1
fi
done
echo "total $totalfail $totalpanic $totalruntime" >> $summary