| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 1 | #!/bin/sh | 
|  | 2 |  | 
| Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 3 | # This script runs tests in various revisions and configurations and analyses | 
|  | 4 | # the results in order to highlight any difference in the set of tests skipped | 
|  | 5 | # in the test suites of interest. | 
|  | 6 | # | 
|  | 7 | # It can be used to ensure the testing criteria mentioned in strategy.md, | 
|  | 8 | # end of section "Supporting builds with drivers without the software | 
|  | 9 | # implementation" are met, namely: | 
|  | 10 | # | 
|  | 11 | # - the sets of tests skipped in the default config and the full config must be | 
|  | 12 | #   the same before and after the PR that implements step 3; | 
|  | 13 | # - the set of tests skipped in the driver-only build is the same as in an | 
|  | 14 | #   equivalent software-based configuration, or the difference is small enough, | 
|  | 15 | #   justified, and a github issue is created to track it. | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 16 | #   This part is verified by tests/scripts/analyze_outcomes.py | 
| Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 17 | # | 
|  | 18 | # 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] | 19 | # 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] | 20 | # 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] | 21 | # 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] | 22 | # | 
|  | 23 | # NOTE: This is only an example/template script, you should make a copy and | 
|  | 24 | # edit it to suit your needs. The part that needs editing is at the top. | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 25 | # | 
|  | 26 | # Also, you can comment out parts that don't need to be re-done when | 
|  | 27 | # re-running this script (for example "get numbers before this PR"). | 
|  | 28 |  | 
|  | 29 | # ----- BEGIN edit this ----- | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 30 | # Space-separated list of test suites to ignore: | 
|  | 31 | # if SSS is in that list, test_suite_SSS and test_suite_SSS.* are ignored. | 
|  | 32 | IGNORE="md mdx shax" # accelerated | 
|  | 33 | IGNORE="$IGNORE entropy hmac_drbg random" # disabled (ext. RNG) | 
|  | 34 | IGNORE="$IGNORE psa_crypto_init" # needs internal RNG | 
| Manuel Pégourié-Gonnard | 0dc4077 | 2022-10-19 12:12:21 +0200 | [diff] [blame] | 35 | IGNORE="$IGNORE hkdf" # disabled in the all.sh component tested | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 36 | # ----- END edit this ----- | 
|  | 37 |  | 
|  | 38 | set -eu | 
|  | 39 |  | 
|  | 40 | cleanup() { | 
|  | 41 | make clean | 
|  | 42 | git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | record() { | 
|  | 46 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv" | 
|  | 47 | rm -f $MBEDTLS_TEST_OUTCOME_FILE | 
|  | 48 | make check | 
|  | 49 | } | 
|  | 50 |  | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 51 | # save current HEAD | 
|  | 52 | HEAD=$(git branch --show-current) | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 53 |  | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 54 | # get the numbers before this PR for default and full | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 55 | cleanup | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 56 | git checkout $(git merge-base HEAD development) | 
|  | 57 | record "before-default" | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 58 |  | 
|  | 59 | cleanup | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 60 | scripts/config.py full | 
|  | 61 | record "before-full" | 
|  | 62 |  | 
|  | 63 | # get the numbers now for default and full | 
|  | 64 | cleanup | 
|  | 65 | git checkout $HEAD | 
|  | 66 | record "after-default" | 
|  | 67 |  | 
|  | 68 | cleanup | 
|  | 69 | scripts/config.py full | 
|  | 70 | record "after-full" | 
|  | 71 |  | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 72 |  | 
|  | 73 | # analysis | 
|  | 74 |  | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 75 | populate_suites () { | 
|  | 76 | SUITES='' | 
|  | 77 | make generated_files >/dev/null | 
|  | 78 | data_files=$(cd tests/suites && echo *.data) | 
|  | 79 | for data in $data_files; do | 
|  | 80 | suite=${data#test_suite_} | 
|  | 81 | suite=${suite%.data} | 
|  | 82 | suite_base=${suite%%.*} | 
|  | 83 | case " $IGNORE " in | 
|  | 84 | *" $suite_base "*) :;; | 
|  | 85 | *) SUITES="$SUITES $suite";; | 
|  | 86 | esac | 
|  | 87 | done | 
|  | 88 | make neat | 
|  | 89 | } | 
|  | 90 |  | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 91 | compare_suite () { | 
|  | 92 | ref="outcome-$1.csv" | 
|  | 93 | new="outcome-$2.csv" | 
|  | 94 | suite="$3" | 
|  | 95 |  | 
|  | 96 | pattern_suite=";test_suite_$suite;" | 
|  | 97 | total=$(grep -c "$pattern_suite" "$ref") | 
|  | 98 | sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p" | 
|  | 99 | sed -n "$sed_cmd" "$ref" > skipped-ref | 
|  | 100 | sed -n "$sed_cmd" "$new" > skipped-new | 
|  | 101 | nb_ref=$(wc -l <skipped-ref) | 
|  | 102 | nb_new=$(wc -l <skipped-new) | 
|  | 103 |  | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 104 | printf "%36s: total %4d; skipped %4d -> %4d\n" \ | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 105 | $suite      $total       $nb_ref $nb_new | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 106 | if diff skipped-ref skipped-new | grep '^> '; then | 
|  | 107 | ret=1 | 
|  | 108 | else | 
|  | 109 | ret=0 | 
|  | 110 | fi | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 111 | rm skipped-ref skipped-new | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 112 | return $ret | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 113 | } | 
|  | 114 |  | 
|  | 115 | compare_builds () { | 
|  | 116 | printf "\n*** Comparing $1 -> $2 ***\n" | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 117 | failed='' | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 118 | for suite in $SUITES; do | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 119 | if compare_suite "$1" "$2" "$suite"; then :; else | 
|  | 120 | failed="$failed $suite" | 
|  | 121 | fi | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 122 | done | 
| Manuel Pégourié-Gonnard | b51051f | 2022-10-18 09:42:30 +0200 | [diff] [blame] | 123 | if [ -z "$failed" ]; then | 
|  | 124 | printf "No coverage gap found.\n" | 
|  | 125 | else | 
|  | 126 | printf "Suites with less coverage:%s\n" "$failed" | 
|  | 127 | fi | 
| Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 128 | } | 
|  | 129 |  | 
| Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame] | 130 | populate_suites | 
| Przemek Stekiel | 9398664 | 2022-11-09 15:06:44 +0100 | [diff] [blame] | 131 | compare_builds before-default after-default | 
|  | 132 | compare_builds before-full after-full |