-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_all
executable file
·91 lines (82 loc) · 1.89 KB
/
test_all
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
#!/bin/bash
# this program is called by make test.
# It takes all given sudoku data sets
# and checks that for each of them
# the basic solver gives the exact same
# output as the advanced solver. In case
# the outputs differ, the result is placed
# into res/ directory.
make
basic=./sudoku_solver
adv=./sudoku_advanced
result=0
outfolder=res
mkdir -p "$outfolder"
run_test() {
file=$1; shift
out1=$($basic < "$file")
out2=$($adv < "$file")
if [ "$out1" != "$out2" ]; then
echo "fail!"
{
cat "$file"
echo "------------"
echo "$out1"
echo "------------"
echo "$out2"
} > "$outfolder/$(basename "$file")"
fi
}
maxthreads=$(getconf _NPROCESSORS_ONLN)
nthreads=0
test_dir() {
dir=$1; shift
[ -d "$dir" ] || {
echo "no such directory: $dir"
return 0
}
for f in $dir/*; do
[ "$nthreads" -ge "$maxthreads" ] && {
wait
nthreads=0
}
[ "$result" -ne 0 ] && return 1
echo "$f"
run_test "$f" &
((++nthreads))
done
wait
}
get_time() {
program=$1; shift
input_file=$1; shift
gtime "--format=%E" $program < "$input_file" > /dev/null
}
print_time() {
program=$1; shift
input_file=$1; shift
get_time "$program" "$input_file" 2>&1 | tr '.' ':' | sed 's/:/ /g' | (
read -r m s ms
m=${m#0} s=${s#0} ms=${ms#0}
printf "%02d.%02d\t%s\n" "$((m * 60 + s))" "${ms#0}" "$input_file"
)
}
main() {
for f in $(find tests -name "*.in" | grep -E '([123]_|seq-3)' | grep -v "very_hard_1.in"); do
echo "$f"
run_test "$f"
done
print_time "$adv" tests/3_sudoku_advanced_tests/very_hard/very_hard_1.in
for f in $(find tests -name "*.in" | grep 'seq-' | grep -ve 'seq-3' -ve 'seq-8'); do
print_time "$adv" "$f"
done
no_files=$(find "$outfolder" -depth 1 | wc -l)
[ "$no_files" -eq 0 ] && {
echo "success"
} || {
for f in res/*;do
echo "problem file: $f"
done
}
}
time ( main )