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 | # |
| 11 | # 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] | 12 | # 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] | 13 | # 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] | 14 | # 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] | 15 | # |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame^] | 16 | # 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] | 17 | # re-running this script (for example "get numbers before this PR"). |
| 18 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 19 | set -eu |
| 20 | |
| 21 | cleanup() { |
| 22 | make clean |
| 23 | git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h |
| 24 | } |
| 25 | |
| 26 | record() { |
| 27 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv" |
| 28 | rm -f $MBEDTLS_TEST_OUTCOME_FILE |
| 29 | make check |
| 30 | } |
| 31 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 32 | # save current HEAD |
| 33 | HEAD=$(git branch --show-current) |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 34 | |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 35 | # get the numbers before this PR for default and full |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 36 | cleanup |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 37 | git checkout $(git merge-base HEAD development) |
| 38 | record "before-default" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 39 | |
| 40 | cleanup |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 41 | scripts/config.py full |
| 42 | record "before-full" |
| 43 | |
| 44 | # get the numbers now for default and full |
| 45 | cleanup |
| 46 | git checkout $HEAD |
| 47 | record "after-default" |
| 48 | |
| 49 | cleanup |
| 50 | scripts/config.py full |
| 51 | record "after-full" |
| 52 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 53 | # analysis |
| 54 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 55 | populate_suites () { |
| 56 | SUITES='' |
| 57 | make generated_files >/dev/null |
| 58 | data_files=$(cd tests/suites && echo *.data) |
| 59 | for data in $data_files; do |
| 60 | suite=${data#test_suite_} |
| 61 | suite=${suite%.data} |
Manuel Pégourié-Gonnard | 222bc85 | 2022-12-29 13:47:25 +0100 | [diff] [blame^] | 62 | SUITES="$SUITES $suite" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 63 | done |
| 64 | make neat |
| 65 | } |
| 66 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 67 | compare_suite () { |
| 68 | ref="outcome-$1.csv" |
| 69 | new="outcome-$2.csv" |
| 70 | suite="$3" |
| 71 | |
| 72 | pattern_suite=";test_suite_$suite;" |
| 73 | total=$(grep -c "$pattern_suite" "$ref") |
| 74 | sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p" |
| 75 | sed -n "$sed_cmd" "$ref" > skipped-ref |
| 76 | sed -n "$sed_cmd" "$new" > skipped-new |
| 77 | nb_ref=$(wc -l <skipped-ref) |
| 78 | nb_new=$(wc -l <skipped-new) |
| 79 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 80 | printf "%36s: total %4d; skipped %4d -> %4d\n" \ |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 81 | $suite $total $nb_ref $nb_new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 82 | if diff skipped-ref skipped-new | grep '^> '; then |
| 83 | ret=1 |
| 84 | else |
| 85 | ret=0 |
| 86 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 87 | rm skipped-ref skipped-new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 88 | return $ret |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | compare_builds () { |
| 92 | printf "\n*** Comparing $1 -> $2 ***\n" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 93 | failed='' |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 94 | for suite in $SUITES; do |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 95 | if compare_suite "$1" "$2" "$suite"; then :; else |
| 96 | failed="$failed $suite" |
| 97 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 98 | done |
Manuel Pégourié-Gonnard | b51051f | 2022-10-18 09:42:30 +0200 | [diff] [blame] | 99 | if [ -z "$failed" ]; then |
| 100 | printf "No coverage gap found.\n" |
| 101 | else |
| 102 | printf "Suites with less coverage:%s\n" "$failed" |
| 103 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 104 | } |
| 105 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 106 | populate_suites |
Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 107 | compare_builds before-default after-default |
| 108 | compare_builds before-full after-full |