-
Notifications
You must be signed in to change notification settings - Fork 5
/
run_tests
executable file
·154 lines (127 loc) · 4.04 KB
/
run_tests
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
########################################################################
##
## Copyright 2015 PMC-Sierra, Inc.
##
## Licensed under the Apache License, Version 2.0 (the "License"); you
## may not use this file except in compliance with the License. You may
## obtain a copy of the License at
## http://www.apache.org/licenses/LICENSE-2.0 Unless required by
## applicable law or agreed to in writing, software distributed under the
## License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
## CONDITIONS OF ANY KIND, either express or implied. See the License for
## the specific language governing permissions and limitations under the
## License.
##
########################################################################
########################################################################
##
## Author: Logan Gunthorpe
##
## Description:
## Run a set of random unit tests either in simulation or hardware
## (auto-detected)
##
########################################################################
green=$(tput bold)$(tput setaf 2)
red=$(tput bold)$(tput setaf 1)
rst=$(tput sgr0)
bsub=
inserts=$RANDOM
let "inserts = (inserts % 50) + 1"
seed=-1
RUN_CMD="./sim -B $bsub -e"
ARG_SEP="--"
TYPE="SIM"
WID=`tput cols`
let 'WID = WID - 19'
if [ -e /dev/cxl/afu0.0d ]; then
RUN_CMD="build/"
ARG_SEP=""
TYPE="HW "
else
SEED="-seed $RANDOM"
SEED2="-seed $RANDOM"
SIM=1
fi
function print_pass_fail {
$* > /dev/null 2>&1
if (( $? )); then
echo ${red}"FAILED!"${rst}
echo "Failed running command: "
echo " $*"
exit 1
else
echo ${green}"PASSED!"${rst}
fi
}
function run_test {
LINE="$*"
printf " %-3s %-*s : " "RUN" $WID "${LINE::$WID}"
print_pass_fail build/$*
}
function run_hw_test {
args=${*:2}
LINE="$*"
printf " %-3s %-*s : " $TYPE $WID "${LINE::$WID}"
print_pass_fail ${RUN_CMD}$1 $ARG_SEP $args
}
function check_files_match {
if ! cmp -s $*; then
echo ${red}"Files differ!"${rst}
exit 1
fi
}
function check_matches {
if ! [ `grep -o $1 $2 | wc -w` -eq $3 ]; then
echo ${red}"Could not find $3 instances of $1 in $2!"${rst}
exit 1
fi
}
mkdir -p build
./waf > /dev/null || exit -1
run_test unittest -S -n 0
run_test unittest -S -n 2048
run_test unittest -S -n 2048 -r
run_test unittest -S -n 2048 -R
run_test unittest -S -n 4096 -v -v
run_test unittest -S -E
run_test lfsrtest -S
run_test searchtest -S
run_test searchtest -S --test-flow
dd if=/dev/urandom bs=8k count=50 of=build/test.dat 2> /dev/null
run_test textswap -S -C build/test.dat build/test_out.dat
check_files_match build/test.dat build/test_out.dat
run_test gen_haystack -P -s 100k -p GoPower8 -i $inserts build/haystack.dat
check_matches GoPower8 build/haystack.dat $inserts
run_test textswap -S build/haystack.dat -p GoPower8 -s Power8Go -E $inserts
check_matches Power8Go build/haystack.dat $inserts
run_test textswap -S build/haystack.dat -p Power8Go -s GoPower8 -E $inserts -R
check_matches Power8Go build/haystack.dat $inserts
run_test textswap -S build/haystack.dat --read-discard
run_test textswap -S build/haystack.dat --write-discard
if ! [ -z "$SIM" ]; then
if ! ./sim --build >/dev/null; then
echo ${red}"Could not build simulation code!"${rst}
exit -1
fi
fi
run_hw_test unittest -n 0 $SEED
run_hw_test unittest -n 2k -r $SEED
run_hw_test unittest -n 2k -R $SEED
run_hw_test unittest -n 4k -v -v $SEED
run_hw_test unittest -n 16k $SEED
run_hw_test unittest -n 16k $SEED2
run_hw_test unittest -E $SEED
run_hw_test lfsrtest $SEED
run_hw_test iotest $SEED
run_hw_test searchtest $SEED
run_hw_test searchtest -i 100 $SEED
run_hw_test searchtest --test-flow $SEED
rm -f build/test_out.dat
run_hw_test textswap -C build/test.dat build/test_out.dat
check_files_match build/test.dat build/test_out.dat
run_hw_test textswap build/haystack.dat -p Power8Go -s GoPower8 -E $inserts
check_matches GoPower8 build/haystack.dat $inserts
rm -f build/test.dat build/test_out.dat
echo ${green}"All Tests PASSED!"${rst}