Gavin Howard | 805cd41 | 2019-01-05 19:34:35 -0700 | [diff] [blame] | 1 | #! /bin/sh |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2018 Gavin D. Howard |
| 4 | # |
| 5 | # Permission to use, copy, modify, and/or distribute this software for any |
| 6 | # purpose with or without fee is hereby granted. |
| 7 | # |
| 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 9 | # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 10 | # AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 11 | # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 12 | # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 13 | # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 14 | # PERFORMANCE OF THIS SOFTWARE. |
| 15 | # |
| 16 | |
| 17 | usage() { |
Gavin Howard | 0b934b5 | 2019-02-15 15:06:35 -0700 | [diff] [blame] | 18 | printf 'usage: %s [run_tests] [generate_tests] [test_with_gcc] [run_sanitizers] [run_valgrind]\n' "$script" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 19 | exit 1 |
| 20 | } |
| 21 | |
| 22 | header() { |
| 23 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 24 | local msg="$1" |
| 25 | shift |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 26 | |
Gavin Howard | 805cd41 | 2019-01-05 19:34:35 -0700 | [diff] [blame] | 27 | printf '\n' |
Gavin Howard | 03e2467 | 2019-01-05 19:47:22 -0700 | [diff] [blame] | 28 | printf '*******************\n' |
Gavin Howard | 805cd41 | 2019-01-05 19:34:35 -0700 | [diff] [blame] | 29 | printf '%s...\n' "$msg" |
Gavin Howard | 03e2467 | 2019-01-05 19:47:22 -0700 | [diff] [blame] | 30 | printf '*******************\n' |
Gavin Howard | 805cd41 | 2019-01-05 19:34:35 -0700 | [diff] [blame] | 31 | printf '\n' |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 32 | } |
| 33 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 34 | do_make() { |
| 35 | make -j4 "$@" |
| 36 | } |
| 37 | |
Gavin Howard | b026ebd | 2019-01-05 19:44:49 -0700 | [diff] [blame] | 38 | configure() { |
| 39 | |
| 40 | local CFLAGS="$1" |
| 41 | shift |
| 42 | |
| 43 | local CC="$1" |
| 44 | shift |
| 45 | |
| 46 | local configure_flags="$1" |
| 47 | shift |
| 48 | |
Gavin Howard | fd7513b | 2019-02-13 18:12:54 -0700 | [diff] [blame] | 49 | if [ "$gen_tests" -eq 0 ]; then |
Gavin Howard | a28acf8 | 2019-02-13 18:06:29 -0700 | [diff] [blame] | 50 | configure_flags="-G $configure_flags" |
| 51 | fi |
| 52 | |
Gavin Howard | bffa6c9 | 2019-01-11 23:12:19 -0700 | [diff] [blame] | 53 | if [ "$CC" = "clang" ]; then |
| 54 | CFLAGS="$clang_flags $CFLAGS" |
| 55 | fi |
| 56 | |
Gavin Howard | 79f605c | 2019-01-08 13:08:21 -0700 | [diff] [blame] | 57 | header "Running \"./configure.sh $configure_flags\" with CC=\"$CC\" and CFLAGS=\"$CFLAGS\"" |
| 58 | CFLAGS="$CFLAGS" CC="$CC" ./configure.sh $configure_flags > /dev/null |
Gavin Howard | b026ebd | 2019-01-05 19:44:49 -0700 | [diff] [blame] | 59 | |
| 60 | } |
| 61 | |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 62 | build() { |
| 63 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 64 | local CFLAGS="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 65 | shift |
| 66 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 67 | local CC="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 68 | shift |
| 69 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 70 | local configure_flags="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 71 | shift |
| 72 | |
Gavin Howard | b026ebd | 2019-01-05 19:44:49 -0700 | [diff] [blame] | 73 | configure "$CFLAGS" "$CC" "$configure_flags" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 74 | |
Gavin Howard | b026ebd | 2019-01-05 19:44:49 -0700 | [diff] [blame] | 75 | header "Building with CC=\"$CC\" and CFLAGS=\"$CFLAGS\"" |
| 76 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 77 | do_make > /dev/null 2> "$scriptdir/.test.txt" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 78 | |
| 79 | if [ -s "$scriptdir/.test.txt" ]; then |
Gavin Howard | 805cd41 | 2019-01-05 19:34:35 -0700 | [diff] [blame] | 80 | printf '%s generated warning(s):\n' "$CC" |
| 81 | printf '\n' |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 82 | cat "$scriptdir/.test.txt" |
| 83 | exit 1 |
| 84 | fi |
| 85 | } |
| 86 | |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 87 | runtest() { |
| 88 | |
| 89 | header "Running tests" |
| 90 | |
Gavin Howard | 95358a9 | 2019-01-08 01:17:29 -0700 | [diff] [blame] | 91 | if [ "$#" -gt 0 ]; then |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 92 | do_make "$@" |
Gavin Howard | 95358a9 | 2019-01-08 01:17:29 -0700 | [diff] [blame] | 93 | else |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 94 | do_make test |
Gavin Howard | 95358a9 | 2019-01-08 01:17:29 -0700 | [diff] [blame] | 95 | fi |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | runconfigtests() { |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 99 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 100 | local CFLAGS="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 101 | shift |
| 102 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 103 | local CC="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 104 | shift |
| 105 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 106 | local configure_flags="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 107 | shift |
| 108 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 109 | local run_tests="$1" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 110 | shift |
| 111 | |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 112 | if [ "$run_tests" -ne 0 ]; then |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 113 | header "Running tests with configure flags \"$configure_flags\", CC=\"$CC\", and CFLAGS=\"$CFLAGS\"" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 114 | else |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 115 | header "Building with configure flags \"$configure_flags\", CC=\"$CC\", and CFLAGS=\"$CFLAGS\"" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 116 | fi |
| 117 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 118 | build "$CFLAGS" "$CC" "$configure_flags" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 119 | if [ "$run_tests" -ne 0 ]; then |
| 120 | runtest |
| 121 | fi |
| 122 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 123 | do_make clean |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 124 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 125 | build "$CFLAGS" "$CC" "$configure_flags -b" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 126 | if [ "$run_tests" -ne 0 ]; then |
| 127 | runtest |
| 128 | fi |
| 129 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 130 | do_make clean |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 131 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 132 | build "$CFLAGS" "$CC" "$configure_flags -d" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 133 | if [ "$run_tests" -ne 0 ]; then |
| 134 | runtest |
| 135 | fi |
| 136 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 137 | do_make clean |
Gavin Howard | 6e27dec | 2018-10-24 17:38:34 -0600 | [diff] [blame] | 138 | } |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 139 | |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 140 | runtestseries() { |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 141 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 142 | local CFLAGS="$1" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 143 | shift |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 144 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 145 | local CC="$1" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 146 | shift |
| 147 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 148 | local run_tests="$1" |
Gavin Howard | 8c4780b | 2019-01-04 12:37:33 -0700 | [diff] [blame] | 149 | shift |
| 150 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 151 | runconfigtests "$CFLAGS" "$CC" "" "$run_tests" |
| 152 | runconfigtests "$CFLAGS" "$CC" "-E" "$run_tests" |
| 153 | runconfigtests "$CFLAGS" "$CC" "-H" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 154 | runconfigtests "$CFLAGS" "$CC" "-N" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 155 | runconfigtests "$CFLAGS" "$CC" "-R" "$run_tests" |
| 156 | runconfigtests "$CFLAGS" "$CC" "-S" "$run_tests" |
| 157 | runconfigtests "$CFLAGS" "$CC" "-EH" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 158 | runconfigtests "$CFLAGS" "$CC" "-EN" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 159 | runconfigtests "$CFLAGS" "$CC" "-ER" "$run_tests" |
| 160 | runconfigtests "$CFLAGS" "$CC" "-ES" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 161 | runconfigtests "$CFLAGS" "$CC" "-HN" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 162 | runconfigtests "$CFLAGS" "$CC" "-HR" "$run_tests" |
| 163 | runconfigtests "$CFLAGS" "$CC" "-HS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 164 | runconfigtests "$CFLAGS" "$CC" "-NR" "$run_tests" |
| 165 | runconfigtests "$CFLAGS" "$CC" "-NS" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 166 | runconfigtests "$CFLAGS" "$CC" "-RS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 167 | runconfigtests "$CFLAGS" "$CC" "-EHN" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 168 | runconfigtests "$CFLAGS" "$CC" "-EHR" "$run_tests" |
| 169 | runconfigtests "$CFLAGS" "$CC" "-EHS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 170 | runconfigtests "$CFLAGS" "$CC" "-ENR" "$run_tests" |
| 171 | runconfigtests "$CFLAGS" "$CC" "-ENS" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 172 | runconfigtests "$CFLAGS" "$CC" "-ERS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 173 | runconfigtests "$CFLAGS" "$CC" "-HNR" "$run_tests" |
| 174 | runconfigtests "$CFLAGS" "$CC" "-HNS" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 175 | runconfigtests "$CFLAGS" "$CC" "-HRS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 176 | runconfigtests "$CFLAGS" "$CC" "-NRS" "$run_tests" |
| 177 | runconfigtests "$CFLAGS" "$CC" "-EHNR" "$run_tests" |
| 178 | runconfigtests "$CFLAGS" "$CC" "-EHNS" "$run_tests" |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 179 | runconfigtests "$CFLAGS" "$CC" "-EHRS" "$run_tests" |
Gavin Howard | 2be9b7d | 2019-02-20 16:27:02 -0700 | [diff] [blame] | 180 | runconfigtests "$CFLAGS" "$CC" "-ENRS" "$run_tests" |
| 181 | runconfigtests "$CFLAGS" "$CC" "-HNRS" "$run_tests" |
| 182 | runconfigtests "$CFLAGS" "$CC" "-EHNRS" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | runtests() { |
| 186 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 187 | local CFLAGS="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 188 | shift |
| 189 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 190 | local CC="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 191 | shift |
| 192 | |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 193 | local run_tests="$1" |
| 194 | shift |
| 195 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 196 | runtestseries "$CFLAGS" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 197 | } |
| 198 | |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 199 | karatsuba() { |
| 200 | |
| 201 | header "Running Karatsuba tests" |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 202 | do_make karatsuba_test |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | vg() { |
| 206 | |
| 207 | header "Running valgrind" |
| 208 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 209 | build "$reldebug" "$CC" "-g" |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 210 | runtest valgrind |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 211 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 212 | do_make clean_config |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 213 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 214 | build "$reldebug" "$CC" "-gb" |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 215 | runtest valgrind |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 216 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 217 | do_make clean_config |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 218 | |
Gavin Howard | d4fece3 | 2019-01-08 02:06:22 -0700 | [diff] [blame] | 219 | build "$reldebug" "$CC" "-gd" |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 220 | runtest valgrind |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 221 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 222 | do_make clean_config |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 223 | } |
| 224 | |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 225 | debug() { |
| 226 | |
Gavin Howard | 6f1aa5a | 2019-01-04 13:29:04 -0700 | [diff] [blame] | 227 | local CC="$1" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 228 | shift |
| 229 | |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 230 | local run_tests="$1" |
| 231 | shift |
| 232 | |
| 233 | runtests "$debug" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 234 | |
Gavin Howard | dd9ecc2 | 2019-02-14 13:10:52 -0700 | [diff] [blame] | 235 | if [ "$CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 236 | runtests "$debug -fsanitize=address" "$CC" "$run_tests" |
| 237 | runtests "$debug -fsanitize=undefined" "$CC" "$run_tests" |
| 238 | runtests "$debug -fsanitize=memory" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 239 | fi |
| 240 | } |
| 241 | |
| 242 | release() { |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 243 | |
| 244 | local CC="$1" |
| 245 | shift |
| 246 | |
| 247 | local run_tests="$1" |
| 248 | shift |
| 249 | |
| 250 | runtests "$release" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | reldebug() { |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 254 | |
| 255 | local CC="$1" |
| 256 | shift |
| 257 | |
| 258 | local run_tests="$1" |
| 259 | shift |
| 260 | |
| 261 | runtests "$reldebug" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | minsize() { |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 265 | |
| 266 | local CC="$1" |
| 267 | shift |
| 268 | |
| 269 | local run_tests="$1" |
| 270 | shift |
| 271 | |
| 272 | runtests "$minsize" "$CC" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 273 | } |
| 274 | |
Gavin Howard | bffa6c9 | 2019-01-11 23:12:19 -0700 | [diff] [blame] | 275 | clang_flags="-Weverything -Wno-padded -Wno-switch-enum -Wno-format-nonliteral" |
| 276 | clang_flags="$clang_flags -Wno-cast-align -Wno-missing-noreturn -Wno-disabled-macro-expansion" |
| 277 | clang_flags="$clang_flags -Wno-unreachable-code -Wno-unreachable-code-return" |
| 278 | |
Gavin Howard | 6fe912a | 2019-02-02 12:45:37 -0700 | [diff] [blame] | 279 | cflags="-Wall -Wextra -Werror -pedantic -std=c99" |
Gavin Howard | db6b3fc | 2019-01-04 21:51:46 -0700 | [diff] [blame] | 280 | |
| 281 | debug="$cflags -g -O0 -fno-omit-frame-pointer" |
| 282 | release="$cflags -DNDEBUG -O3" |
| 283 | reldebug="$cflags -O3 -g -fno-omit-frame-pointer" |
| 284 | minsize="$cflags -DNDEBUG -Os" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 285 | |
| 286 | set -e |
| 287 | |
| 288 | script="$0" |
| 289 | scriptdir=$(dirname "$script") |
| 290 | |
Gavin Howard | 30a203e | 2019-01-05 19:37:03 -0700 | [diff] [blame] | 291 | if [ "$#" -gt 0 ]; then |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 292 | run_tests="$1" |
| 293 | shift |
| 294 | else |
| 295 | run_tests=1 |
| 296 | fi |
| 297 | |
| 298 | if [ "$#" -gt 0 ]; then |
Gavin Howard | a28acf8 | 2019-02-13 18:06:29 -0700 | [diff] [blame] | 299 | gen_tests="$1" |
| 300 | shift |
| 301 | else |
| 302 | gen_tests=1 |
| 303 | fi |
| 304 | |
| 305 | if [ "$#" -gt 0 ]; then |
Gavin Howard | bbb5ec3 | 2019-01-05 19:45:30 -0700 | [diff] [blame] | 306 | test_with_gcc="$1" |
| 307 | shift |
| 308 | else |
| 309 | test_with_gcc=1 |
| 310 | fi |
| 311 | |
Gavin Howard | dd9ecc2 | 2019-02-14 13:10:52 -0700 | [diff] [blame] | 312 | if [ "$#" -gt 0 ]; then |
| 313 | run_sanitizers="$1" |
| 314 | shift |
| 315 | else |
| 316 | run_sanitizers=1 |
| 317 | fi |
| 318 | |
Gavin Howard | 0b934b5 | 2019-02-15 15:06:35 -0700 | [diff] [blame] | 319 | if [ "$#" -gt 0 ]; then |
| 320 | run_valgrind="$1" |
| 321 | shift |
| 322 | else |
| 323 | run_valgrind=1 |
| 324 | fi |
| 325 | |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 326 | cd "$scriptdir" |
| 327 | |
Gavin Howard | b65f0f8 | 2019-01-24 16:22:08 -0700 | [diff] [blame] | 328 | build "$debug" "clang" "" |
| 329 | |
| 330 | header "Running math library under --standard" |
| 331 | |
Gavin Howard | 5008025 | 2019-02-20 15:27:43 -0700 | [diff] [blame] | 332 | printf 'quit\n' | bin/bc -ls |
Gavin Howard | b026ebd | 2019-01-05 19:44:49 -0700 | [diff] [blame] | 333 | |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 334 | version=$(make version) |
| 335 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 336 | do_make clean_tests |
Gavin Howard | 68f4a4e | 2019-01-07 17:50:15 -0700 | [diff] [blame] | 337 | |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 338 | debug "clang" "$run_tests" |
| 339 | release "clang" "$run_tests" |
| 340 | reldebug "clang" "$run_tests" |
| 341 | minsize "clang" "$run_tests" |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 342 | |
Gavin Howard | 91afc87 | 2019-01-05 20:22:37 -0700 | [diff] [blame] | 343 | if [ "$test_with_gcc" -ne 0 ]; then |
Gavin Howard | bbb5ec3 | 2019-01-05 19:45:30 -0700 | [diff] [blame] | 344 | debug "gcc" "$run_tests" |
| 345 | release "gcc" "$run_tests" |
| 346 | reldebug "gcc" "$run_tests" |
| 347 | minsize "gcc" "$run_tests" |
| 348 | fi |
Gavin Howard | 4052e03 | 2018-10-23 17:22:57 -0600 | [diff] [blame] | 349 | |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 350 | if [ "$run_tests" -ne 0 ]; then |
Gavin Howard | c7ae8af | 2019-01-10 09:33:47 -0700 | [diff] [blame] | 351 | |
Gavin Howard | ecbee38 | 2019-02-01 12:46:26 -0700 | [diff] [blame] | 352 | build "$release" "clang" "" |
Gavin Howard | bc8cf8c | 2019-01-16 11:29:03 -0700 | [diff] [blame] | 353 | |
Gavin Howard | d2143fb | 2019-01-04 22:00:30 -0700 | [diff] [blame] | 354 | karatsuba |
Gavin Howard | 0b934b5 | 2019-02-15 15:06:35 -0700 | [diff] [blame] | 355 | |
| 356 | if [ "$run_valgrind" -ne 0 ]; then |
| 357 | vg |
| 358 | fi |
Gavin Howard | 1620812 | 2018-10-24 17:20:45 -0600 | [diff] [blame] | 359 | |
Gavin Howard | 2686337 | 2019-02-15 18:36:27 -0700 | [diff] [blame] | 360 | configure "$reldebug" "afl-gcc" "" |
Gavin Howard | cf61474 | 2019-01-05 20:27:16 -0700 | [diff] [blame] | 361 | |
| 362 | printf '\n' |
Gavin Howard | 2686337 | 2019-02-15 18:36:27 -0700 | [diff] [blame] | 363 | printf 'Run make\n' |
| 364 | printf '\n' |
Gavin Howard | 1b5ea80 | 2019-02-19 21:24:04 -0700 | [diff] [blame] | 365 | printf 'Then run %s/tests/randmath.py and the fuzzer.\n' "$scriptdir" |
Gavin Howard | cf61474 | 2019-01-05 20:27:16 -0700 | [diff] [blame] | 366 | printf 'Then run the GitHub release script as follows:\n' |
| 367 | printf '\n' |
Gavin Howard | 9c5840f | 2019-02-20 11:15:04 -0700 | [diff] [blame] | 368 | printf ' <github_release> %s <msg> .travis.yml codecov.yml release.sh RELEASE.md \\\n' "$version" |
Gavin Howard | c083fad | 2019-01-09 09:55:09 -0700 | [diff] [blame] | 369 | printf ' tests/afl.py tests/randmath.py tests/bc/scripts/timeconst.bc\n' |
Gavin Howard | cf61474 | 2019-01-05 20:27:16 -0700 | [diff] [blame] | 370 | |
| 371 | fi |