Mercurial > dropbear
comparison libtommath/testme.sh @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 8bba51a55704 |
children | f52919ffd3b1 |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
41 echo | 41 echo |
42 echo " --make-option=* Give an option to make," | 42 echo " --make-option=* Give an option to make," |
43 echo " e.g. --make-option=\"-f makefile.shared\"" | 43 echo " e.g. --make-option=\"-f makefile.shared\"" |
44 echo " This is an option that will always be passed as parameter to make." | 44 echo " This is an option that will always be passed as parameter to make." |
45 echo | 45 echo |
46 echo " --with-low-mp Also build&run tests with -DMP_{8,16,32}BIT." | |
47 echo | |
46 echo "Godmode:" | 48 echo "Godmode:" |
47 echo | 49 echo |
48 echo " --all Choose all architectures and gcc and clang as compilers" | 50 echo " --all Choose all architectures and gcc and clang as compilers" |
49 echo | 51 echo |
50 echo " --help This message" | 52 echo " --help This message" |
65 | 67 |
66 _runtest() | 68 _runtest() |
67 { | 69 { |
68 echo -ne " Compile $1 $2" | 70 echo -ne " Compile $1 $2" |
69 make clean > /dev/null | 71 make clean > /dev/null |
70 CC="$1" CFLAGS="$2 $TEST_CFLAGS" make -j$MAKE_JOBS test_standalone $MAKE_OPTIONS > /dev/null 2>test_errors.txt | 72 suffix=$(echo ${1}${2} | tr ' ' '_') |
73 CC="$1" CFLAGS="$2 $TEST_CFLAGS" make -j$MAKE_JOBS test_standalone $MAKE_OPTIONS > /dev/null 2>gcc_errors_${suffix}.txt | |
74 errcnt=$(wc -l < gcc_errors_${suffix}.txt) | |
75 if [[ ${errcnt} -gt 1 ]]; then | |
76 echo " failed" | |
77 cat gcc_errors_${suffix}.txt | |
78 exit 128 | |
79 fi | |
71 echo -e "\rRun test $1 $2" | 80 echo -e "\rRun test $1 $2" |
72 timeout --foreground 90 ./test > test_$(echo ${1}${2} | tr ' ' '_').txt || _die "running tests" $? | 81 local _timeout="" |
82 which timeout >/dev/null && _timeout="timeout --foreground 90" | |
83 $_timeout ./test > test_${suffix}.txt || _die "running tests" $? | |
73 } | 84 } |
74 | 85 |
75 _banner() | 86 _banner() |
76 { | 87 { |
77 echo "uname="$(uname -a) | 88 echo "uname="$(uname -a) |
91 } | 102 } |
92 | 103 |
93 ARCHFLAGS="" | 104 ARCHFLAGS="" |
94 COMPILERS="" | 105 COMPILERS="" |
95 CFLAGS="" | 106 CFLAGS="" |
107 WITH_LOW_MP="" | |
96 | 108 |
97 while [ $# -gt 0 ]; | 109 while [ $# -gt 0 ]; |
98 do | 110 do |
99 case $1 in | 111 case $1 in |
100 "--with-m64" | "--with-m32" | "--with-mx32") | 112 "--with-m64" | "--with-m32" | "--with-mx32") |
107 CFLAGS="$CFLAGS ${1#*=}" | 119 CFLAGS="$CFLAGS ${1#*=}" |
108 ;; | 120 ;; |
109 --make-option=*) | 121 --make-option=*) |
110 MAKE_OPTIONS="$MAKE_OPTIONS ${1#*=}" | 122 MAKE_OPTIONS="$MAKE_OPTIONS ${1#*=}" |
111 ;; | 123 ;; |
124 --with-low-mp) | |
125 WITH_LOW_MP="1" | |
126 ;; | |
112 --all) | 127 --all) |
113 COMPILERS="gcc clang" | 128 COMPILERS="gcc clang" |
114 ARCHFLAGS="-m64 -m32 -mx32" | 129 ARCHFLAGS="-m64 -m32 -mx32" |
115 ;; | 130 ;; |
116 --help) | 131 --help | -h) |
117 _help | 132 _help |
133 ;; | |
134 *) | |
135 echo "Ignoring option ${1}" | |
118 ;; | 136 ;; |
119 esac | 137 esac |
120 shift | 138 shift |
121 done | 139 done |
122 | 140 |
123 # default to gcc if nothing is given | 141 # default to gcc if no compiler is defined but some other options |
124 if [[ "$COMPILERS" == "" ]] | 142 if [[ "$COMPILERS" == "" ]] && [[ "$ARCHFLAGS$MAKE_OPTIONS$CFLAGS" != "" ]] |
143 then | |
144 COMPILERS="gcc" | |
145 # default to gcc and run only default config if no option is given | |
146 elif [[ "$COMPILERS" == "" ]] | |
125 then | 147 then |
126 _banner gcc | 148 _banner gcc |
127 _runtest "gcc" "" | 149 _runtest "gcc" "" |
128 _exit | 150 _exit |
129 fi | 151 fi |
156 fi | 178 fi |
157 echo $compiler_version | 179 echo $compiler_version |
158 | 180 |
159 for a in "${archflags[@]}" | 181 for a in "${archflags[@]}" |
160 do | 182 do |
161 if [[ $(expr "$i" : "clang") && "$a" == "-mx32" ]] | 183 if [[ $(expr "$i" : "clang") -ne 0 && "$a" == "-mx32" ]] |
162 then | 184 then |
163 echo "clang -mx32 tests skipped" | 185 echo "clang -mx32 tests skipped" |
164 continue | 186 continue |
165 fi | 187 fi |
166 | 188 |
167 _runtest "$i $a" "" | 189 _runtest "$i $a" "$CFLAGS" |
168 _runtest "$i $a" "-DMP_8BIT" | 190 [ "$WITH_LOW_MP" != "1" ] && continue |
169 _runtest "$i $a" "-DMP_16BIT" | 191 _runtest "$i $a" "-DMP_8BIT $CFLAGS" |
170 _runtest "$i $a" "-DMP_32BIT" | 192 _runtest "$i $a" "-DMP_16BIT $CFLAGS" |
193 _runtest "$i $a" "-DMP_32BIT $CFLAGS" | |
171 done | 194 done |
172 done | 195 done |
173 | 196 |
174 _exit | 197 _exit |