Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 3 | # This script runs tests before and after a PR and analyzes the results in |
| 4 | # order to highlight any difference in the set of tests skipped. |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 5 | # |
Janos Follath | 1243896 | 2024-12-13 14:36:06 +0000 | [diff] [blame] | 6 | # It can be used to check for unintended consequences when making non-trivial |
| 7 | # changes to compile time guards: the sets of tests skipped in the default |
| 8 | # config and the full config must be the same before and after the PR. |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 9 | # |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 10 | # USAGE: |
| 11 | # - First, commit any uncommited changes. (Also, see warning below.) |
Manuel Pégourié-Gonnard | 5a2e026 | 2023-01-23 12:51:52 +0100 | [diff] [blame] | 12 | # - Then launch --> [SKIP_SSL_OPT=1] docs/architecture/psa-migration/outcome-analysis.sh |
| 13 | # - SKIP_SSL_OPT=1 can optionally be set to skip ssl-opt.sh tests |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 14 | # |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 15 | # WARNING: this script checks out a commit other than the head of the current |
Manuel Pégourié-Gonnard | 68429fc | 2022-07-27 20:37:12 +0200 | [diff] [blame] | 16 | # branch; it checks out the current branch again when running successfully, |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 17 | # but while the script is running, or if it terminates early in error, you |
Manuel Pégourié-Gonnard | 68429fc | 2022-07-27 20:37:12 +0200 | [diff] [blame] | 18 | # should be aware that you might be at a different commit than expected. |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 19 | # |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 20 | # NOTE: you can comment out parts that don't need to be re-done when |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 21 | # re-running this script (for example "get numbers before this PR"). |
| 22 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 23 | set -eu |
| 24 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 25 | : ${SKIP_SSL_OPT:=0} |
| 26 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 27 | cleanup() { |
| 28 | make clean |
Ronald Cron | 7e5d61c | 2024-06-10 14:25:46 +0200 | [diff] [blame] | 29 | git checkout -- include/mbedtls/mbedtls_config.h tf-psa-crypto/include/psa/crypto_config.h |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | record() { |
| 33 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv" |
| 34 | rm -f $MBEDTLS_TEST_OUTCOME_FILE |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 35 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 36 | make check |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 37 | |
| 38 | if [ $SKIP_SSL_OPT -eq 0 ]; then |
| 39 | make -C programs ssl/ssl_server2 ssl/ssl_client2 \ |
| 40 | test/udp_proxy test/query_compile_time_config |
| 41 | tests/ssl-opt.sh |
| 42 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 43 | } |
| 44 | |
Valerio Setti | ccb0344 | 2023-07-31 15:07:49 +0200 | [diff] [blame] | 45 | # save current HEAD. |
Valerio Setti | ab02d39 | 2023-07-31 16:47:07 +0200 | [diff] [blame] | 46 | # Note: this can optionally be updated to |
| 47 | # HEAD=$(git branch --show-current) |
| 48 | # when using a Git version above 2.22 |
| 49 | HEAD=$(git rev-parse --abbrev-ref HEAD) |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 50 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 51 | # get the numbers before this PR for default and full |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 52 | cleanup |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 53 | git checkout $(git merge-base HEAD development) |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 54 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 55 | record "before-default" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 56 | |
| 57 | cleanup |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 58 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 59 | scripts/config.py full |
| 60 | record "before-full" |
| 61 | |
| 62 | # get the numbers now for default and full |
| 63 | cleanup |
| 64 | git checkout $HEAD |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 65 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 66 | record "after-default" |
| 67 | |
| 68 | cleanup |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 69 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 70 | scripts/config.py full |
| 71 | record "after-full" |
| 72 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 73 | cleanup |
| 74 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 75 | # analysis |
| 76 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 77 | populate_suites () { |
| 78 | SUITES='' |
| 79 | make generated_files >/dev/null |
| 80 | data_files=$(cd tests/suites && echo *.data) |
| 81 | for data in $data_files; do |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 82 | suite=${data%.data} |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 83 | SUITES="$SUITES $suite" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 84 | done |
| 85 | make neat |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 86 | |
| 87 | if [ $SKIP_SSL_OPT -eq 0 ]; then |
| 88 | SUITES="$SUITES ssl-opt" |
| 89 | extra_files=$(cd tests/opt-testcases && echo *.sh) |
| 90 | for extra in $extra_files; do |
| 91 | suite=${extra%.sh} |
| 92 | SUITES="$SUITES $suite" |
| 93 | done |
| 94 | fi |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 95 | } |
| 96 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 97 | compare_suite () { |
| 98 | ref="outcome-$1.csv" |
| 99 | new="outcome-$2.csv" |
| 100 | suite="$3" |
| 101 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 102 | pattern_suite=";$suite;" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 103 | total=$(grep -c "$pattern_suite" "$ref") |
| 104 | sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p" |
| 105 | sed -n "$sed_cmd" "$ref" > skipped-ref |
| 106 | sed -n "$sed_cmd" "$new" > skipped-new |
| 107 | nb_ref=$(wc -l <skipped-ref) |
| 108 | nb_new=$(wc -l <skipped-new) |
| 109 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 110 | name=${suite#test_suite_} |
| 111 | printf "%40s: total %4d; skipped %4d -> %4d\n" \ |
| 112 | $name $total $nb_ref $nb_new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 113 | if diff skipped-ref skipped-new | grep '^> '; then |
| 114 | ret=1 |
| 115 | else |
| 116 | ret=0 |
| 117 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 118 | rm skipped-ref skipped-new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 119 | return $ret |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | compare_builds () { |
| 123 | printf "\n*** Comparing $1 -> $2 ***\n" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 124 | failed='' |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 125 | for suite in $SUITES; do |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 126 | if compare_suite "$1" "$2" "$suite"; then :; else |
| 127 | failed="$failed $suite" |
| 128 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 129 | done |
Manuel Pégourié-Gonnard | b51051f | 2022-10-18 09:42:30 +0200 | [diff] [blame] | 130 | if [ -z "$failed" ]; then |
| 131 | printf "No coverage gap found.\n" |
| 132 | else |
| 133 | printf "Suites with less coverage:%s\n" "$failed" |
| 134 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 135 | } |
| 136 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 137 | populate_suites |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 138 | compare_builds before-default after-default |
| 139 | compare_builds before-full after-full |