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 | # |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 6 | # It can be used to check the first testing criterion mentioned in strategy.md, |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 7 | # end of section "Supporting builds with drivers without the software |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 8 | # implementation", namely: the sets of tests skipped in the default config and |
| 9 | # 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] | 10 | # |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 11 | # USAGE: |
| 12 | # - First, commit any uncommited changes. (Also, see warning below.) |
Manuel Pégourié-Gonnard | 5a2e026 | 2023-01-23 12:51:52 +0100 | [diff] [blame] | 13 | # - Then launch --> [SKIP_SSL_OPT=1] docs/architecture/psa-migration/outcome-analysis.sh |
| 14 | # - 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] | 15 | # |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 16 | # 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] | 17 | # 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] | 18 | # 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] | 19 | # 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] | 20 | # |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 21 | # 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] | 22 | # re-running this script (for example "get numbers before this PR"). |
| 23 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 24 | set -eu |
| 25 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 26 | : ${SKIP_SSL_OPT:=0} |
| 27 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 28 | cleanup() { |
| 29 | make clean |
| 30 | git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h |
| 31 | } |
| 32 | |
| 33 | record() { |
| 34 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv" |
| 35 | rm -f $MBEDTLS_TEST_OUTCOME_FILE |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 36 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 37 | make check |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 38 | |
| 39 | if [ $SKIP_SSL_OPT -eq 0 ]; then |
| 40 | make -C programs ssl/ssl_server2 ssl/ssl_client2 \ |
| 41 | test/udp_proxy test/query_compile_time_config |
| 42 | tests/ssl-opt.sh |
| 43 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 44 | } |
| 45 | |
Valerio Setti | ccb0344 | 2023-07-31 15:07:49 +0200 | [diff] [blame^] | 46 | # save current HEAD. |
| 47 | # Note: unfortunately "git branch --show-current" was added only in GIT |
| 48 | # version 2.22. |
| 49 | GIT_VERSION="$(git --version | sed 's/git version //')" |
| 50 | if dpkg --compare-versions "$GIT_VERSION" "gt" "2.22.0"; then |
| 51 | HEAD=$(git branch --show-current) |
| 52 | else |
| 53 | HEAD=$(git rev-parse --abbrev-ref HEAD) |
| 54 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 55 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 56 | # get the numbers before this PR for default and full |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 57 | cleanup |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 58 | git checkout $(git merge-base HEAD development) |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 59 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 60 | record "before-default" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 61 | |
| 62 | cleanup |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 63 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 64 | scripts/config.py full |
| 65 | record "before-full" |
| 66 | |
| 67 | # get the numbers now for default and full |
| 68 | cleanup |
| 69 | git checkout $HEAD |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 70 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 71 | record "after-default" |
| 72 | |
| 73 | cleanup |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 74 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 75 | scripts/config.py full |
| 76 | record "after-full" |
| 77 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 78 | cleanup |
| 79 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 80 | # analysis |
| 81 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 82 | populate_suites () { |
| 83 | SUITES='' |
| 84 | make generated_files >/dev/null |
| 85 | data_files=$(cd tests/suites && echo *.data) |
| 86 | for data in $data_files; do |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 87 | suite=${data%.data} |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame] | 88 | SUITES="$SUITES $suite" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 89 | done |
| 90 | make neat |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 91 | |
| 92 | if [ $SKIP_SSL_OPT -eq 0 ]; then |
| 93 | SUITES="$SUITES ssl-opt" |
| 94 | extra_files=$(cd tests/opt-testcases && echo *.sh) |
| 95 | for extra in $extra_files; do |
| 96 | suite=${extra%.sh} |
| 97 | SUITES="$SUITES $suite" |
| 98 | done |
| 99 | fi |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 100 | } |
| 101 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 102 | compare_suite () { |
| 103 | ref="outcome-$1.csv" |
| 104 | new="outcome-$2.csv" |
| 105 | suite="$3" |
| 106 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 107 | pattern_suite=";$suite;" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 108 | total=$(grep -c "$pattern_suite" "$ref") |
| 109 | sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p" |
| 110 | sed -n "$sed_cmd" "$ref" > skipped-ref |
| 111 | sed -n "$sed_cmd" "$new" > skipped-new |
| 112 | nb_ref=$(wc -l <skipped-ref) |
| 113 | nb_new=$(wc -l <skipped-new) |
| 114 | |
Manuel Pégourié-Gonnard | 6bbeba6 | 2022-12-29 14:02:05 +0100 | [diff] [blame] | 115 | name=${suite#test_suite_} |
| 116 | printf "%40s: total %4d; skipped %4d -> %4d\n" \ |
| 117 | $name $total $nb_ref $nb_new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 118 | if diff skipped-ref skipped-new | grep '^> '; then |
| 119 | ret=1 |
| 120 | else |
| 121 | ret=0 |
| 122 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 123 | rm skipped-ref skipped-new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 124 | return $ret |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | compare_builds () { |
| 128 | printf "\n*** Comparing $1 -> $2 ***\n" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 129 | failed='' |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 130 | for suite in $SUITES; do |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 131 | if compare_suite "$1" "$2" "$suite"; then :; else |
| 132 | failed="$failed $suite" |
| 133 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 134 | done |
Manuel Pégourié-Gonnard | b51051f | 2022-10-18 09:42:30 +0200 | [diff] [blame] | 135 | if [ -z "$failed" ]; then |
| 136 | printf "No coverage gap found.\n" |
| 137 | else |
| 138 | printf "Suites with less coverage:%s\n" "$failed" |
| 139 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 140 | } |
| 141 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 142 | populate_suites |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 143 | compare_builds before-default after-default |
| 144 | compare_builds before-full after-full |