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. |
| 16 | # |
| 17 | # 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] | 18 | # 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] | 19 | # 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] | 20 | # 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] | 21 | # |
| 22 | # NOTE: This is only an example/template script, you should make a copy and |
| 23 | # 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] | 24 | # |
| 25 | # Also, you can comment out parts that don't need to be re-done when |
| 26 | # re-running this script (for example "get numbers before this PR"). |
| 27 | |
| 28 | # ----- BEGIN edit this ----- |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 29 | # The component in all.sh that builds and tests with drivers. |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 30 | DRIVER_COMPONENT=test_psa_crypto_config_accel_hash_use_psa |
Manuel Pégourié-Gonnard | fca4dc6 | 2022-07-26 10:10:07 +0200 | [diff] [blame] | 31 | # A similar configuration to that of the component, except without drivers, |
| 32 | # for comparison. |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 33 | reference_config () { |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 34 | # start with full |
| 35 | scripts/config.py full |
| 36 | # use PSA config and disable driver-less algs as in the component |
| 37 | scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG |
| 38 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER |
| 39 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING |
| 40 | # disable options as in the component |
| 41 | # (no need to disable whole modules, we'll just skip their test suite) |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 42 | scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 43 | scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_DETERMINISTIC_ECDSA |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 44 | } |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 45 | # Space-separated list of test suites to ignore: |
| 46 | # if SSS is in that list, test_suite_SSS and test_suite_SSS.* are ignored. |
| 47 | IGNORE="md mdx shax" # accelerated |
| 48 | IGNORE="$IGNORE entropy hmac_drbg random" # disabled (ext. RNG) |
| 49 | IGNORE="$IGNORE psa_crypto_init" # needs internal RNG |
| 50 | IGNORE="$IGNORE hkdf" # disabled |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 51 | # ----- END edit this ----- |
| 52 | |
| 53 | set -eu |
| 54 | |
| 55 | cleanup() { |
| 56 | make clean |
| 57 | git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h |
| 58 | } |
| 59 | |
| 60 | record() { |
| 61 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv" |
| 62 | rm -f $MBEDTLS_TEST_OUTCOME_FILE |
| 63 | make check |
| 64 | } |
| 65 | |
| 66 | # save current HEAD |
| 67 | HEAD=$(git branch --show-current) |
| 68 | |
| 69 | # get the numbers before this PR for default and full |
| 70 | cleanup |
| 71 | git checkout $(git merge-base HEAD development) |
| 72 | record "before-default" |
| 73 | |
| 74 | cleanup |
| 75 | scripts/config.py full |
| 76 | record "before-full" |
| 77 | |
| 78 | # get the numbers now for default and full |
| 79 | cleanup |
| 80 | git checkout $HEAD |
| 81 | record "after-default" |
| 82 | |
| 83 | cleanup |
| 84 | scripts/config.py full |
| 85 | record "after-full" |
| 86 | |
| 87 | # get the numbers now for driver-only and reference |
| 88 | cleanup |
| 89 | reference_config |
| 90 | record "reference" |
| 91 | |
| 92 | cleanup |
| 93 | export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-drivers.csv" |
| 94 | tests/scripts/all.sh -k test_psa_crypto_config_accel_hash_use_psa |
| 95 | |
| 96 | # analysis |
| 97 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 98 | populate_suites () { |
| 99 | SUITES='' |
| 100 | make generated_files >/dev/null |
| 101 | data_files=$(cd tests/suites && echo *.data) |
| 102 | for data in $data_files; do |
| 103 | suite=${data#test_suite_} |
| 104 | suite=${suite%.data} |
| 105 | suite_base=${suite%%.*} |
| 106 | case " $IGNORE " in |
| 107 | *" $suite_base "*) :;; |
| 108 | *) SUITES="$SUITES $suite";; |
| 109 | esac |
| 110 | done |
| 111 | make neat |
| 112 | } |
| 113 | |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 114 | compare_suite () { |
| 115 | ref="outcome-$1.csv" |
| 116 | new="outcome-$2.csv" |
| 117 | suite="$3" |
| 118 | |
| 119 | pattern_suite=";test_suite_$suite;" |
| 120 | total=$(grep -c "$pattern_suite" "$ref") |
| 121 | sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p" |
| 122 | sed -n "$sed_cmd" "$ref" > skipped-ref |
| 123 | sed -n "$sed_cmd" "$new" > skipped-new |
| 124 | nb_ref=$(wc -l <skipped-ref) |
| 125 | nb_new=$(wc -l <skipped-new) |
| 126 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 127 | printf "%36s: total %4d; skipped %4d -> %4d\n" \ |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 128 | $suite $total $nb_ref $nb_new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 129 | if diff skipped-ref skipped-new | grep '^> '; then |
| 130 | ret=1 |
| 131 | else |
| 132 | ret=0 |
| 133 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 134 | rm skipped-ref skipped-new |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 135 | return $ret |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | compare_builds () { |
| 139 | printf "\n*** Comparing $1 -> $2 ***\n" |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 140 | failed='' |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 141 | for suite in $SUITES; do |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 142 | if compare_suite "$1" "$2" "$suite"; then :; else |
| 143 | failed="$failed $suite" |
| 144 | fi |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 145 | done |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 146 | printf "suites with less coverage: %s\n" "$failed" |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 147 | } |
| 148 | |
Manuel Pégourié-Gonnard | 2bb2f15 | 2022-10-12 10:57:31 +0200 | [diff] [blame^] | 149 | populate_suites |
Manuel Pégourié-Gonnard | fb2ed58 | 2022-07-21 11:04:52 +0200 | [diff] [blame] | 150 | compare_builds before-default after-default |
| 151 | compare_builds before-full after-full |
| 152 | compare_builds reference drivers |