SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # basic-build-tests.sh |
| 4 | # |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 5 | # Copyright The Mbed TLS Contributors |
Bence Szépkúti | c7da1fe | 2020-05-26 01:54:15 +0200 | [diff] [blame] | 6 | # SPDX-License-Identifier: Apache-2.0 |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | # |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 20 | # Purpose |
| 21 | # |
| 22 | # Executes the basic test suites, captures the results, and generates a simple |
| 23 | # test report and code coverage report. |
| 24 | # |
| 25 | # The tests include: |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 26 | # * Unit tests - executed using tests/scripts/run-test-suite.pl |
Paul Bakker | 4b8bc52 | 2016-07-20 09:52:01 +0100 | [diff] [blame] | 27 | # * Self-tests - executed using the test suites above |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 28 | # * System tests - executed using tests/ssl-opt.sh |
| 29 | # * Interoperability tests - executed using tests/compat.sh |
| 30 | # |
| 31 | # The tests focus on functionality and do not consider performance. |
| 32 | # |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 33 | # Note the tests self-adapt due to configurations in include/mbedtls/mbedtls_config.h |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 34 | # which can lead to some tests being skipped, and can cause the number of |
Paul Bakker | 4b8bc52 | 2016-07-20 09:52:01 +0100 | [diff] [blame] | 35 | # available tests to fluctuate. |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 36 | # |
| 37 | # This script has been written to be generic and should work on any shell. |
| 38 | # |
| 39 | # Usage: basic-build-tests.sh |
| 40 | # |
| 41 | |
| 42 | # Abort on errors (and uninitiliased variables) |
| 43 | set -eu |
| 44 | |
| 45 | if [ -d library -a -d include -a -d tests ]; then :; else |
| 46 | echo "Must be run from mbed TLS root" >&2 |
| 47 | exit 1 |
| 48 | fi |
| 49 | |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 50 | : ${OPENSSL:="openssl"} |
| 51 | : ${OPENSSL_LEGACY:="$OPENSSL"} |
| 52 | : ${GNUTLS_CLI:="gnutls-cli"} |
| 53 | : ${GNUTLS_SERV:="gnutls-serv"} |
| 54 | : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} |
| 55 | : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} |
| 56 | |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 57 | # Used to make ssl-opt.sh deterministic. |
Manuel Pégourié-Gonnard | 5430447 | 2020-06-22 10:11:47 +0200 | [diff] [blame] | 58 | # |
| 59 | # See also RELEASE_SEED in all.sh. Debugging is easier if both values are kept |
| 60 | # in sync. If you change the value here because it breaks some tests, you'll |
| 61 | # definitely want to change it in all.sh as well. |
Manuel Pégourié-Gonnard | e050191 | 2020-06-08 12:59:27 +0200 | [diff] [blame] | 62 | : ${SEED:=1} |
| 63 | export SEED |
| 64 | |
Gilles Peskine | a3d2264 | 2021-07-13 23:23:23 +0200 | [diff] [blame] | 65 | # if MAKEFLAGS is not set add the -j option to speed up invocations of make |
| 66 | if [ -z "${MAKEFLAGS+set}" ]; then |
| 67 | export MAKEFLAGS="-j" |
| 68 | fi |
| 69 | |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 70 | # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh |
| 71 | # we just export the variables they require |
| 72 | export OPENSSL_CMD="$OPENSSL" |
| 73 | export GNUTLS_CLI="$GNUTLS_CLI" |
| 74 | export GNUTLS_SERV="$GNUTLS_SERV" |
| 75 | |
Bence Szépkúti | bb0cfeb | 2021-05-28 09:42:25 +0200 | [diff] [blame] | 76 | CONFIG_H='include/mbedtls/mbedtls_config.h' |
Janos Follath | 7ccac85 | 2016-06-06 13:18:39 +0100 | [diff] [blame] | 77 | CONFIG_BAK="$CONFIG_H.bak" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 78 | |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 79 | # Step 0 - print build environment info |
Andres AG | b2fdd04 | 2016-09-22 14:17:46 +0100 | [diff] [blame] | 80 | OPENSSL="$OPENSSL" \ |
| 81 | OPENSSL_LEGACY="$OPENSSL_LEGACY" \ |
| 82 | GNUTLS_CLI="$GNUTLS_CLI" \ |
| 83 | GNUTLS_SERV="$GNUTLS_SERV" \ |
| 84 | GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \ |
| 85 | GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" \ |
| 86 | scripts/output_env.sh |
Janos Follath | b72c678 | 2016-07-19 14:54:17 +0100 | [diff] [blame] | 87 | echo |
| 88 | |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 89 | # Step 1 - Make and instrumented build for code coverage |
Simon Butcher | c2b0efc | 2016-03-18 18:28:43 +0000 | [diff] [blame] | 90 | export CFLAGS=' --coverage -g3 -O0 ' |
Philippe Antoine | 702c659 | 2019-07-09 17:44:53 +0200 | [diff] [blame] | 91 | export LDFLAGS=' --coverage' |
SimonB | 098a3b5 | 2016-04-16 21:56:59 +0100 | [diff] [blame] | 92 | make clean |
Janos Follath | 7ccac85 | 2016-06-06 13:18:39 +0100 | [diff] [blame] | 93 | cp "$CONFIG_H" "$CONFIG_BAK" |
Gilles Peskine | 5d46f6a | 2019-07-27 23:52:53 +0200 | [diff] [blame] | 94 | scripts/config.py full |
Gilles Peskine | a3d2264 | 2021-07-13 23:23:23 +0200 | [diff] [blame] | 95 | make |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 96 | |
| 97 | |
| 98 | # Step 2 - Execute the tests |
| 99 | TEST_OUTPUT=out_${PPID} |
| 100 | cd tests |
Gilles Peskine | 3c8ccc0 | 2019-05-20 11:39:18 +0200 | [diff] [blame] | 101 | if [ ! -f "seedfile" ]; then |
Gilles Peskine | bfcb6e1 | 2020-04-09 18:33:34 +0200 | [diff] [blame] | 102 | dd if=/dev/urandom of="seedfile" bs=64 count=1 |
Gilles Peskine | 3c8ccc0 | 2019-05-20 11:39:18 +0200 | [diff] [blame] | 103 | fi |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 104 | echo |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 105 | |
Gilles Peskine | ca51b47 | 2020-04-09 18:29:42 +0200 | [diff] [blame] | 106 | # Step 2a - Unit Tests (keep going even if some tests fail) |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 107 | echo '################ Unit tests ################' |
Jaeden Amero | 60ca6e5 | 2018-12-07 13:06:24 +0000 | [diff] [blame] | 108 | perl scripts/run-test-suites.pl -v 2 |tee unit-test-$TEST_OUTPUT |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 109 | echo '^^^^^^^^^^^^^^^^ Unit tests ^^^^^^^^^^^^^^^^' |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 110 | echo |
| 111 | |
Gilles Peskine | ca51b47 | 2020-04-09 18:29:42 +0200 | [diff] [blame] | 112 | # Step 2b - System Tests (keep going even if some tests fail) |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 113 | echo |
| 114 | echo '################ ssl-opt.sh ################' |
Gilles Peskine | bbced87 | 2021-07-13 23:26:00 +0200 | [diff] [blame] | 115 | echo "ssl-opt.sh will use SEED=$SEED for udp_proxy" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 116 | sh ssl-opt.sh |tee sys-test-$TEST_OUTPUT |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 117 | echo '^^^^^^^^^^^^^^^^ ssl-opt.sh ^^^^^^^^^^^^^^^^' |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 118 | echo |
| 119 | |
Gilles Peskine | ca51b47 | 2020-04-09 18:29:42 +0200 | [diff] [blame] | 120 | # Step 2c - Compatibility tests (keep going even if some tests fail) |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 121 | echo '################ compat.sh ################' |
| 122 | { |
| 123 | echo '#### compat.sh: Default versions' |
Manuel Pégourié-Gonnard | 9473229 | 2022-04-14 09:12:10 +0200 | [diff] [blame^] | 124 | sh compat.sh |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 125 | echo |
| 126 | |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 127 | echo '#### compat.sh: legacy (null)' |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 128 | OPENSSL_CMD="$OPENSSL_LEGACY" \ |
| 129 | GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" \ |
Manuel Pégourié-Gonnard | 296787f | 2022-04-06 13:28:27 +0200 | [diff] [blame] | 130 | sh compat.sh -e '^$' -f 'NULL' |
Gilles Peskine | 40be51f | 2020-04-09 18:50:08 +0200 | [diff] [blame] | 131 | echo |
| 132 | |
| 133 | echo '#### compat.sh: next (ARIA, ChaCha)' |
| 134 | OPENSSL_CMD="$OPENSSL_NEXT" sh compat.sh -e '^$' -f 'ARIA\|CHACHA' |
| 135 | echo |
| 136 | } | tee compat-test-$TEST_OUTPUT |
| 137 | echo '^^^^^^^^^^^^^^^^ compat.sh ^^^^^^^^^^^^^^^^' |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 138 | echo |
| 139 | |
| 140 | # Step 3 - Process the coverage report |
| 141 | cd .. |
Gilles Peskine | 5757d54 | 2020-04-09 18:32:48 +0200 | [diff] [blame] | 142 | { |
| 143 | make lcov |
| 144 | echo SUCCESS |
| 145 | } | tee tests/cov-$TEST_OUTPUT |
| 146 | |
| 147 | if [ "$(tail -n1 tests/cov-$TEST_OUTPUT)" != "SUCCESS" ]; then |
| 148 | echo >&2 "Fatal: 'make lcov' failed" |
| 149 | exit 2 |
| 150 | fi |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 151 | |
| 152 | |
| 153 | # Step 4 - Summarise the test report |
| 154 | echo |
| 155 | echo "=========================================================================" |
| 156 | echo "Test Report Summary" |
| 157 | echo |
| 158 | |
Gilles Peskine | 6ee3b7e | 2021-07-22 11:08:30 +0200 | [diff] [blame] | 159 | # A failure of the left-hand side of a pipe is ignored (this is a limitation |
| 160 | # of sh). We'll use the presence of this file as a marker that the generation |
| 161 | # of the report succeeded. |
Gilles Peskine | d8d1932 | 2021-07-22 12:29:27 +0200 | [diff] [blame] | 162 | rm -f "tests/basic-build-test-$$.ok" |
Gilles Peskine | 6ee3b7e | 2021-07-22 11:08:30 +0200 | [diff] [blame] | 163 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 164 | { |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 165 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 166 | cd tests |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 167 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 168 | # Step 4a - Unit tests |
| 169 | echo "Unit tests - tests/scripts/run-test-suites.pl" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 170 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 171 | PASSED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ') |
| 172 | SKIPPED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ') |
| 173 | TOTAL_SUITES=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ') |
| 174 | FAILED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ') |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 175 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 176 | echo "No test suites : $TOTAL_SUITES" |
| 177 | echo "Passed : $PASSED_TESTS" |
| 178 | echo "Failed : $FAILED_TESTS" |
| 179 | echo "Skipped : $SKIPPED_TESTS" |
| 180 | echo "Total exec'd tests : $(($PASSED_TESTS + $FAILED_TESTS))" |
| 181 | echo "Total avail tests : $(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))" |
| 182 | echo |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 183 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 184 | TOTAL_PASS=$PASSED_TESTS |
| 185 | TOTAL_FAIL=$FAILED_TESTS |
| 186 | TOTAL_SKIP=$SKIPPED_TESTS |
| 187 | TOTAL_AVAIL=$(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS)) |
| 188 | TOTAL_EXED=$(($PASSED_TESTS + $FAILED_TESTS)) |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 189 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 190 | # Step 4b - TLS Options tests |
| 191 | echo "TLS Options tests - tests/ssl-opt.sh" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 192 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 193 | PASSED_TESTS=$(tail -n5 sys-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p') |
| 194 | SKIPPED_TESTS=$(tail -n5 sys-test-$TEST_OUTPUT|sed -n -e 's/.* ([0-9]* \/ [0-9]* tests (\([0-9]*\) skipped))$/\1/p') |
| 195 | TOTAL_TESTS=$(tail -n5 sys-test-$TEST_OUTPUT|sed -n -e 's/.* ([0-9]* \/ \([0-9]*\) tests ([0-9]* skipped))$/\1/p') |
| 196 | FAILED_TESTS=$(($TOTAL_TESTS - $PASSED_TESTS)) |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 197 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 198 | echo "Passed : $PASSED_TESTS" |
| 199 | echo "Failed : $FAILED_TESTS" |
| 200 | echo "Skipped : $SKIPPED_TESTS" |
| 201 | echo "Total exec'd tests : $TOTAL_TESTS" |
| 202 | echo "Total avail tests : $(($TOTAL_TESTS + $SKIPPED_TESTS))" |
| 203 | echo |
| 204 | |
| 205 | TOTAL_PASS=$(($TOTAL_PASS+$PASSED_TESTS)) |
| 206 | TOTAL_FAIL=$(($TOTAL_FAIL+$FAILED_TESTS)) |
| 207 | TOTAL_SKIP=$(($TOTAL_SKIP+$SKIPPED_TESTS)) |
| 208 | TOTAL_AVAIL=$(($TOTAL_AVAIL + $TOTAL_TESTS + $SKIPPED_TESTS)) |
| 209 | TOTAL_EXED=$(($TOTAL_EXED + $TOTAL_TESTS)) |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 210 | |
| 211 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 212 | # Step 4c - System Compatibility tests |
| 213 | echo "System/Compatibility tests - tests/compat.sh" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 214 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 215 | PASSED_TESTS=$(cat compat-test-$TEST_OUTPUT | sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p' | awk 'BEGIN{ s = 0 } { s += $1 } END{ print s }') |
| 216 | SKIPPED_TESTS=$(cat compat-test-$TEST_OUTPUT | sed -n -e 's/.* ([0-9]* \/ [0-9]* tests (\([0-9]*\) skipped))$/\1/p' | awk 'BEGIN{ s = 0 } { s += $1 } END{ print s }') |
| 217 | EXED_TESTS=$(cat compat-test-$TEST_OUTPUT | sed -n -e 's/.* ([0-9]* \/ \([0-9]*\) tests ([0-9]* skipped))$/\1/p' | awk 'BEGIN{ s = 0 } { s += $1 } END{ print s }') |
| 218 | FAILED_TESTS=$(($EXED_TESTS - $PASSED_TESTS)) |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 219 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 220 | echo "Passed : $PASSED_TESTS" |
| 221 | echo "Failed : $FAILED_TESTS" |
| 222 | echo "Skipped : $SKIPPED_TESTS" |
| 223 | echo "Total exec'd tests : $EXED_TESTS" |
| 224 | echo "Total avail tests : $(($EXED_TESTS + $SKIPPED_TESTS))" |
| 225 | echo |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 226 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 227 | TOTAL_PASS=$(($TOTAL_PASS+$PASSED_TESTS)) |
| 228 | TOTAL_FAIL=$(($TOTAL_FAIL+$FAILED_TESTS)) |
| 229 | TOTAL_SKIP=$(($TOTAL_SKIP+$SKIPPED_TESTS)) |
| 230 | TOTAL_AVAIL=$(($TOTAL_AVAIL + $EXED_TESTS + $SKIPPED_TESTS)) |
| 231 | TOTAL_EXED=$(($TOTAL_EXED + $EXED_TESTS)) |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 232 | |
| 233 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 234 | # Step 4d - Grand totals |
| 235 | echo "-------------------------------------------------------------------------" |
| 236 | echo "Total tests" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 237 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 238 | echo "Total Passed : $TOTAL_PASS" |
| 239 | echo "Total Failed : $TOTAL_FAIL" |
| 240 | echo "Total Skipped : $TOTAL_SKIP" |
| 241 | echo "Total exec'd tests : $TOTAL_EXED" |
| 242 | echo "Total avail tests : $TOTAL_AVAIL" |
| 243 | echo |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 244 | |
| 245 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 246 | # Step 4e - Coverage |
| 247 | echo "Coverage" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 248 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 249 | LINES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* lines)/\1/p') |
| 250 | LINES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) lines)/\1/p') |
| 251 | FUNCS_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* functions)$/\1/p') |
| 252 | FUNCS_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) functions)$/\1/p') |
| 253 | BRANCHES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* branches)$/\1/p') |
| 254 | BRANCHES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) branches)$/\1/p') |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 255 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 256 | LINES_PERCENT=$((1000*$LINES_TESTED/$LINES_TOTAL)) |
| 257 | LINES_PERCENT="$(($LINES_PERCENT/10)).$(($LINES_PERCENT-($LINES_PERCENT/10)*10))" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 258 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 259 | FUNCS_PERCENT=$((1000*$FUNCS_TESTED/$FUNCS_TOTAL)) |
| 260 | FUNCS_PERCENT="$(($FUNCS_PERCENT/10)).$(($FUNCS_PERCENT-($FUNCS_PERCENT/10)*10))" |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 261 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 262 | BRANCHES_PERCENT=$((1000*$BRANCHES_TESTED/$BRANCHES_TOTAL)) |
| 263 | BRANCHES_PERCENT="$(($BRANCHES_PERCENT/10)).$(($BRANCHES_PERCENT-($BRANCHES_PERCENT/10)*10))" |
Dan Handley | a8b26c2 | 2020-05-28 16:20:31 +0100 | [diff] [blame] | 264 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 265 | rm unit-test-$TEST_OUTPUT |
| 266 | rm sys-test-$TEST_OUTPUT |
| 267 | rm compat-test-$TEST_OUTPUT |
| 268 | rm cov-$TEST_OUTPUT |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 269 | |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 270 | echo "Lines Tested : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%" |
| 271 | echo "Functions Tested : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%" |
| 272 | echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%" |
| 273 | echo |
SimonB | 21ab9d7 | 2016-03-12 20:37:32 +0000 | [diff] [blame] | 274 | |
Gilles Peskine | d8d1932 | 2021-07-22 12:29:27 +0200 | [diff] [blame] | 275 | # Mark the report generation as having succeeded. This must be the |
| 276 | # last thing in the report generation. |
Gilles Peskine | 6ee3b7e | 2021-07-22 11:08:30 +0200 | [diff] [blame] | 277 | touch "basic-build-test-$$.ok" |
Gilles Peskine | fc70b52 | 2021-07-13 23:27:01 +0200 | [diff] [blame] | 278 | } | tee coverage-summary.txt |
Janos Follath | 7ccac85 | 2016-06-06 13:18:39 +0100 | [diff] [blame] | 279 | |
| 280 | make clean |
| 281 | |
| 282 | if [ -f "$CONFIG_BAK" ]; then |
| 283 | mv "$CONFIG_BAK" "$CONFIG_H" |
| 284 | fi |
Gilles Peskine | 6d6ee98 | 2020-04-09 18:28:14 +0200 | [diff] [blame] | 285 | |
Gilles Peskine | 6ee3b7e | 2021-07-22 11:08:30 +0200 | [diff] [blame] | 286 | # The file must exist, otherwise it means something went wrong while generating |
| 287 | # the coverage report. If something did go wrong, rm will complain so this |
| 288 | # script will exit with a failure status. |
Gilles Peskine | d8d1932 | 2021-07-22 12:29:27 +0200 | [diff] [blame] | 289 | rm "tests/basic-build-test-$$.ok" |