Mercurial > dropbear
annotate libtommath/testme.sh @ 1613:caa9bb54dfa0
fix #endif (#59)
author | François Perrad <francois.perrad@gadz.org> |
---|---|
date | Wed, 28 Feb 2018 15:10:14 +0100 |
parents | 8bba51a55704 |
children | f52919ffd3b1 |
rev | line source |
---|---|
1436 | 1 #!/bin/bash |
2 # | |
3 # return values of this script are: | |
4 # 0 success | |
5 # 128 a test failed | |
6 # >0 the number of timed-out tests | |
7 | |
8 set -e | |
9 | |
10 if [ -f /proc/cpuinfo ] | |
11 then | |
12 MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 )) | |
13 else | |
14 MAKE_JOBS=8 | |
15 fi | |
16 | |
17 ret=0 | |
18 TEST_CFLAGS="" | |
19 | |
20 _help() | |
21 { | |
22 echo "Usage options for $(basename $0) [--with-cc=arg [other options]]" | |
23 echo | |
24 echo "Executing this script without any parameter will only run the default configuration" | |
25 echo "that has automatically been determined for the architecture you're running." | |
26 echo | |
27 echo " --with-cc=* The compiler(s) to use for the tests" | |
28 echo " This is an option that will be iterated." | |
29 echo | |
30 echo "To be able to specify options a compiler has to be given." | |
31 echo "All options will be tested with all MP_xBIT configurations." | |
32 echo | |
33 echo " --with-{m64,m32,mx32} The architecture(s) to build and test for," | |
34 echo " e.g. --with-mx32." | |
35 echo " This is an option that will be iterated, multiple selections are possible." | |
36 echo " The mx32 architecture is not supported by clang and will not be executed." | |
37 echo | |
38 echo " --cflags=* Give an option to the compiler," | |
39 echo " e.g. --cflags=-g" | |
40 echo " This is an option that will always be passed as parameter to CC." | |
41 echo | |
42 echo " --make-option=* Give an option to make," | |
43 echo " e.g. --make-option=\"-f makefile.shared\"" | |
44 echo " This is an option that will always be passed as parameter to make." | |
45 echo | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
46 echo " --with-low-mp Also build&run tests with -DMP_{8,16,32}BIT." |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
47 echo |
1436 | 48 echo "Godmode:" |
49 echo | |
50 echo " --all Choose all architectures and gcc and clang as compilers" | |
51 echo | |
52 echo " --help This message" | |
53 exit 0 | |
54 } | |
55 | |
56 _die() | |
57 { | |
58 echo "error $2 while $1" | |
59 if [ "$2" != "124" ] | |
60 then | |
61 exit 128 | |
62 else | |
63 echo "assuming timeout while running test - continue" | |
64 ret=$(( $ret + 1 )) | |
65 fi | |
66 } | |
67 | |
68 _runtest() | |
69 { | |
70 echo -ne " Compile $1 $2" | |
71 make clean > /dev/null | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
72 suffix=$(echo ${1}${2} | tr ' ' '_') |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
73 CC="$1" CFLAGS="$2 $TEST_CFLAGS" make -j$MAKE_JOBS test_standalone $MAKE_OPTIONS > /dev/null 2>gcc_errors_${suffix}.txt |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
74 errcnt=$(wc -l < gcc_errors_${suffix}.txt) |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
75 if [[ ${errcnt} -gt 1 ]]; then |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
76 echo " failed" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
77 cat gcc_errors_${suffix}.txt |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
78 exit 128 |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
79 fi |
1436 | 80 echo -e "\rRun test $1 $2" |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
81 local _timeout="" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
82 which timeout >/dev/null && _timeout="timeout --foreground 90" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
83 $_timeout ./test > test_${suffix}.txt || _die "running tests" $? |
1436 | 84 } |
85 | |
86 _banner() | |
87 { | |
88 echo "uname="$(uname -a) | |
89 [[ "$#" != "0" ]] && (echo $1=$($1 -dumpversion)) || true | |
90 } | |
91 | |
92 _exit() | |
93 { | |
94 if [ "$ret" == "0" ] | |
95 then | |
96 echo "Tests successful" | |
97 else | |
98 echo "$ret tests timed out" | |
99 fi | |
100 | |
101 exit $ret | |
102 } | |
103 | |
104 ARCHFLAGS="" | |
105 COMPILERS="" | |
106 CFLAGS="" | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
107 WITH_LOW_MP="" |
1436 | 108 |
109 while [ $# -gt 0 ]; | |
110 do | |
111 case $1 in | |
112 "--with-m64" | "--with-m32" | "--with-mx32") | |
113 ARCHFLAGS="$ARCHFLAGS ${1:6}" | |
114 ;; | |
115 --with-cc=*) | |
116 COMPILERS="$COMPILERS ${1#*=}" | |
117 ;; | |
118 --cflags=*) | |
119 CFLAGS="$CFLAGS ${1#*=}" | |
120 ;; | |
121 --make-option=*) | |
122 MAKE_OPTIONS="$MAKE_OPTIONS ${1#*=}" | |
123 ;; | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
124 --with-low-mp) |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
125 WITH_LOW_MP="1" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
126 ;; |
1436 | 127 --all) |
128 COMPILERS="gcc clang" | |
129 ARCHFLAGS="-m64 -m32 -mx32" | |
130 ;; | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
131 --help | -h) |
1436 | 132 _help |
133 ;; | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
134 *) |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
135 echo "Ignoring option ${1}" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
136 ;; |
1436 | 137 esac |
138 shift | |
139 done | |
140 | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
141 # default to gcc if no compiler is defined but some other options |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
142 if [[ "$COMPILERS" == "" ]] && [[ "$ARCHFLAGS$MAKE_OPTIONS$CFLAGS" != "" ]] |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
143 then |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
144 COMPILERS="gcc" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
145 # default to gcc and run only default config if no option is given |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
146 elif [[ "$COMPILERS" == "" ]] |
1436 | 147 then |
148 _banner gcc | |
149 _runtest "gcc" "" | |
150 _exit | |
151 fi | |
152 | |
153 archflags=( $ARCHFLAGS ) | |
154 compilers=( $COMPILERS ) | |
155 | |
156 # choosing a compiler without specifying an architecture will use the default architecture | |
157 if [ "${#archflags[@]}" == "0" ] | |
158 then | |
159 archflags[0]=" " | |
160 fi | |
161 | |
162 _banner | |
163 | |
164 for i in "${compilers[@]}" | |
165 do | |
166 if [ -z "$(which $i)" ] | |
167 then | |
168 echo "Skipped compiler $i, file not found" | |
169 continue | |
170 fi | |
171 compiler_version=$(echo "$i="$($i -dumpversion)) | |
172 if [ "$compiler_version" == "clang=4.2.1" ] | |
173 then | |
174 # one of my versions of clang complains about some stuff in stdio.h and stdarg.h ... | |
175 TEST_CFLAGS="-Wno-typedef-redefinition" | |
176 else | |
177 TEST_CFLAGS="" | |
178 fi | |
179 echo $compiler_version | |
180 | |
181 for a in "${archflags[@]}" | |
182 do | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
183 if [[ $(expr "$i" : "clang") -ne 0 && "$a" == "-mx32" ]] |
1436 | 184 then |
185 echo "clang -mx32 tests skipped" | |
186 continue | |
187 fi | |
188 | |
1470
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
189 _runtest "$i $a" "$CFLAGS" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
190 [ "$WITH_LOW_MP" != "1" ] && continue |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
191 _runtest "$i $a" "-DMP_8BIT $CFLAGS" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
192 _runtest "$i $a" "-DMP_16BIT $CFLAGS" |
8bba51a55704
Update to libtommath v1.0.1
Matt Johnston <matt@ucc.asn.au>
parents:
1436
diff
changeset
|
193 _runtest "$i $a" "-DMP_32BIT $CFLAGS" |
1436 | 194 done |
195 done | |
196 | |
197 _exit |