-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.sh
executable file
·95 lines (65 loc) · 2.32 KB
/
run_tests.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
if [ $# -eq 0 ]
then
echo "usage: ./run_tests.sh solver-cmd inputs ref-solutions timeout memout problem-task[s]"
exit 0
fi
BASEDIR=$(dirname "$0")
ORIGINALDIR=$(pwd)
SOLVER=$1
INPUTS=${2:-"inputs"}
REFS=${3:-"reference-results"}
TIMEOUT=${4:-300}
MEMOUT=${5:-2048}
echo 'Making a output directory for' $(date)
TEST_NAME=$(date +'%Y-%m-%d_%H-%M-%S_')$SOLVER
if [ "$SOLVER" == "solved-af" ]
then
TEST_NAME+="_$(git rev-parse HEAD | cut -c 1-8)"
fi
OUTDIR=$ORIGINALDIR"/tests"/$TEST_NAME
BURNER=$OUTDIR/burner
if [ ! -w tests ]
then
mkdir tests
fi
mkdir -p $OUTDIR
mkdir -p $BURNER
OUTFILE=$OUTDIR/test-results_$TEST_NAME.csv
touch $OUTFILE
touch $BURNER/log.txt
echo "Timeout is set for $TIMEOUT seconds, Memout is set for $MEMOUT MB" >> $OUTFILE
HEADER='WCTIME,CPUTIME,USERTIME,SYSTEMTIME,CPUUSAGE,MAXVM,TIMEOUT,MEMOUT'
echo 'TASK,FILE,'$HEADER',MATCH' >> $OUTFILE
PROBLEM_TASKS="${@:6}"
echo 'Beginning Tests for '${PROBLEM_TASKS[@]}' on '$SOLVER'...'
telegram-send --format markdown "*$(hostname)*: Beginning testing for * ${PROBLEM_TASKS[@]} * on $SOLVER!"
for PROBLEM_TASK in ${PROBLEM_TASKS[@]};
do
for PROBLEM_FILE in $BASEDIR/$INPUTS/*.tgf;
do
PROBLEM_FILE_NAME=$(basename -- "$PROBLEM_FILE")
PROBLEM_FILE_NAME="${PROBLEM_FILE_NAME%.*}"
echo -n $PROBLEM_TASK >> $OUTFILE
echo -n ',' >> $OUTFILE
echo -n $PROBLEM_FILE >> $OUTFILE
echo -n ',' >> $OUTFILE
echo '>> Running Test: ' $PROBLEM_TASK 'on ' $PROBLEM_FILE
runsolver -w $BURNER/watcher.txt -v $BURNER/varfile.txt -o $BURNER/solver.o -W $TIMEOUT --vsize-limit $MEMOUT $SOLVER -fo tgf -f $PROBLEM_FILE -p $PROBLEM_TASK
cat $BURNER/watcher.txt >> $BURNER/log.txt
IFS="="
while read -r name value
do
[[ "$name" =~ ^[[:space:]]*# ]] && continue
echo -n $value >> $OUTFILE
echo -n ',' >> $OUTFILE
done < $BURNER/varfile.txt
unset IFS
MATCH=$(compare-exts-mpz "$BURNER"/solver.o "$REFS"/"$PROBLEM_FILE_NAME".apx-"$PROBLEM_TASK".out | tail -1)
echo $MATCH >> $OUTFILE
echo "$MATCH"
done
telegram-send --format markdown "*$(hostname)*: Problem task *$PROBLEM_TASK* completed!"
done
telegram-send --format markdown "$(hostname): *Test $(date +'%Y-%m-%d_%H-%M-%S') completed!*"
echo 'Tests Finished!'