2022-07-21 11:04:52 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-07-26 10:10:07 +02:00
|
|
|
# This script runs tests in various revisions and configurations and analyses
|
|
|
|
# the results in order to highlight any difference in the set of tests skipped
|
|
|
|
# in the test suites of interest.
|
|
|
|
#
|
|
|
|
# It can be used to ensure the testing criteria mentioned in strategy.md,
|
|
|
|
# end of section "Supporting builds with drivers without the software
|
|
|
|
# implementation" are met, namely:
|
|
|
|
#
|
|
|
|
# - the sets of tests skipped in the default config and the full config must be
|
|
|
|
# the same before and after the PR that implements step 3;
|
|
|
|
# - the set of tests skipped in the driver-only build is the same as in an
|
|
|
|
# equivalent software-based configuration, or the difference is small enough,
|
|
|
|
# justified, and a github issue is created to track it.
|
|
|
|
#
|
|
|
|
# WARNING: this script checks out a commit other than the head of the current
|
2022-07-27 20:37:12 +02:00
|
|
|
# branch; it checks out the current branch again when running successfully,
|
2022-07-26 10:10:07 +02:00
|
|
|
# but while the script is running, or if it terminates early in error, you
|
2022-07-27 20:37:12 +02:00
|
|
|
# should be aware that you might be at a different commit than expected.
|
2022-07-26 10:10:07 +02:00
|
|
|
#
|
|
|
|
# NOTE: This is only an example/template script, you should make a copy and
|
|
|
|
# edit it to suit your needs. The part that needs editing is at the top.
|
2022-07-21 11:04:52 +02:00
|
|
|
#
|
|
|
|
# Also, you can comment out parts that don't need to be re-done when
|
|
|
|
# re-running this script (for example "get numbers before this PR").
|
|
|
|
|
|
|
|
# ----- BEGIN edit this -----
|
2022-07-26 10:10:07 +02:00
|
|
|
# The component in all.sh that builds and tests with drivers.
|
2022-07-21 11:04:52 +02:00
|
|
|
DRIVER_COMPONENT=test_psa_crypto_config_accel_hash_use_psa
|
2022-07-26 10:10:07 +02:00
|
|
|
# A similar configuration to that of the component, except without drivers,
|
|
|
|
# for comparison.
|
2022-07-21 11:04:52 +02:00
|
|
|
reference_config () {
|
2022-10-12 10:57:31 +02:00
|
|
|
# start with full
|
|
|
|
scripts/config.py full
|
|
|
|
# use PSA config and disable driver-less algs as in the component
|
|
|
|
scripts/config.py set MBEDTLS_PSA_CRYPTO_CONFIG
|
|
|
|
scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_STREAM_CIPHER
|
|
|
|
scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_ECB_NO_PADDING
|
|
|
|
# disable options as in the component
|
|
|
|
# (no need to disable whole modules, we'll just skip their test suite)
|
2022-07-21 11:04:52 +02:00
|
|
|
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC
|
2022-10-12 10:57:31 +02:00
|
|
|
scripts/config.py -f include/psa/crypto_config.h unset PSA_WANT_ALG_DETERMINISTIC_ECDSA
|
2022-07-21 11:04:52 +02:00
|
|
|
}
|
2022-10-12 10:57:31 +02:00
|
|
|
# Space-separated list of test suites to ignore:
|
|
|
|
# if SSS is in that list, test_suite_SSS and test_suite_SSS.* are ignored.
|
|
|
|
IGNORE="md mdx shax" # accelerated
|
|
|
|
IGNORE="$IGNORE entropy hmac_drbg random" # disabled (ext. RNG)
|
|
|
|
IGNORE="$IGNORE psa_crypto_init" # needs internal RNG
|
|
|
|
IGNORE="$IGNORE hkdf" # disabled
|
2022-07-21 11:04:52 +02:00
|
|
|
# ----- END edit this -----
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
make clean
|
|
|
|
git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h
|
|
|
|
}
|
|
|
|
|
|
|
|
record() {
|
|
|
|
export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv"
|
|
|
|
rm -f $MBEDTLS_TEST_OUTCOME_FILE
|
|
|
|
make check
|
|
|
|
}
|
|
|
|
|
|
|
|
# save current HEAD
|
|
|
|
HEAD=$(git branch --show-current)
|
|
|
|
|
|
|
|
# get the numbers before this PR for default and full
|
|
|
|
cleanup
|
|
|
|
git checkout $(git merge-base HEAD development)
|
|
|
|
record "before-default"
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
scripts/config.py full
|
|
|
|
record "before-full"
|
|
|
|
|
|
|
|
# get the numbers now for default and full
|
|
|
|
cleanup
|
|
|
|
git checkout $HEAD
|
|
|
|
record "after-default"
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
scripts/config.py full
|
|
|
|
record "after-full"
|
|
|
|
|
|
|
|
# get the numbers now for driver-only and reference
|
|
|
|
cleanup
|
|
|
|
reference_config
|
|
|
|
record "reference"
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-drivers.csv"
|
|
|
|
tests/scripts/all.sh -k test_psa_crypto_config_accel_hash_use_psa
|
|
|
|
|
|
|
|
# analysis
|
|
|
|
|
2022-10-12 10:57:31 +02:00
|
|
|
populate_suites () {
|
|
|
|
SUITES=''
|
|
|
|
make generated_files >/dev/null
|
|
|
|
data_files=$(cd tests/suites && echo *.data)
|
|
|
|
for data in $data_files; do
|
|
|
|
suite=${data#test_suite_}
|
|
|
|
suite=${suite%.data}
|
|
|
|
suite_base=${suite%%.*}
|
|
|
|
case " $IGNORE " in
|
|
|
|
*" $suite_base "*) :;;
|
|
|
|
*) SUITES="$SUITES $suite";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
make neat
|
|
|
|
}
|
|
|
|
|
2022-07-21 11:04:52 +02:00
|
|
|
compare_suite () {
|
|
|
|
ref="outcome-$1.csv"
|
|
|
|
new="outcome-$2.csv"
|
|
|
|
suite="$3"
|
|
|
|
|
|
|
|
pattern_suite=";test_suite_$suite;"
|
|
|
|
total=$(grep -c "$pattern_suite" "$ref")
|
|
|
|
sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p"
|
|
|
|
sed -n "$sed_cmd" "$ref" > skipped-ref
|
|
|
|
sed -n "$sed_cmd" "$new" > skipped-new
|
|
|
|
nb_ref=$(wc -l <skipped-ref)
|
|
|
|
nb_new=$(wc -l <skipped-new)
|
|
|
|
|
2022-10-12 10:57:31 +02:00
|
|
|
printf "%36s: total %4d; skipped %4d -> %4d\n" \
|
2022-07-21 11:04:52 +02:00
|
|
|
$suite $total $nb_ref $nb_new
|
2022-10-12 10:57:31 +02:00
|
|
|
if diff skipped-ref skipped-new | grep '^> '; then
|
|
|
|
ret=1
|
|
|
|
else
|
|
|
|
ret=0
|
|
|
|
fi
|
2022-07-21 11:04:52 +02:00
|
|
|
rm skipped-ref skipped-new
|
2022-10-12 10:57:31 +02:00
|
|
|
return $ret
|
2022-07-21 11:04:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
compare_builds () {
|
|
|
|
printf "\n*** Comparing $1 -> $2 ***\n"
|
2022-10-12 10:57:31 +02:00
|
|
|
failed=''
|
2022-07-21 11:04:52 +02:00
|
|
|
for suite in $SUITES; do
|
2022-10-12 10:57:31 +02:00
|
|
|
if compare_suite "$1" "$2" "$suite"; then :; else
|
|
|
|
failed="$failed $suite"
|
|
|
|
fi
|
2022-07-21 11:04:52 +02:00
|
|
|
done
|
2022-10-12 10:57:31 +02:00
|
|
|
printf "suites with less coverage: %s\n" "$failed"
|
2022-07-21 11:04:52 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 10:57:31 +02:00
|
|
|
populate_suites
|
2022-07-21 11:04:52 +02:00
|
|
|
compare_builds before-default after-default
|
|
|
|
compare_builds before-full after-full
|
|
|
|
compare_builds reference drivers
|