blob: 67510c1447661c39e473fa1e376ce77e6889c092 [file] [log] [blame]
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +02001#!/bin/sh
2
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +02003# 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é-Gonnard68429fc2022-07-27 20:37:12 +020018# branch; it checks out the current branch again when running successfully,
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020019# but while the script is running, or if it terminates early in error, you
Manuel Pégourié-Gonnard68429fc2022-07-27 20:37:12 +020020# should be aware that you might be at a different commit than expected.
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020021#
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é-Gonnardfb2ed582022-07-21 11:04:52 +020024#
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é-Gonnardfca4dc62022-07-26 10:10:07 +020029# The component in all.sh that builds and tests with drivers.
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020030DRIVER_COMPONENT=test_psa_crypto_config_accel_hash_use_psa
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020031# A similar configuration to that of the component, except without drivers,
32# for comparison.
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020033reference_config () {
34 scripts/config.py set MBEDTLS_USE_PSA_CRYPTO
35 scripts/config.py unset MBEDTLS_PKCS1_V21
36 scripts/config.py unset MBEDTLS_X509_RSASSA_PSS_SUPPORT
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020037 scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC
38}
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020039# Space-separated list of test suites of interest.
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020040SUITES="rsa pkcs1_v15 pk pkparse pkwrite"
41# ----- END edit this -----
42
43set -eu
44
45cleanup() {
46 make clean
47 git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h
48}
49
50record() {
51 export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv"
52 rm -f $MBEDTLS_TEST_OUTCOME_FILE
53 make check
54}
55
56# save current HEAD
57HEAD=$(git branch --show-current)
58
59# get the numbers before this PR for default and full
60cleanup
61git checkout $(git merge-base HEAD development)
62record "before-default"
63
64cleanup
65scripts/config.py full
66record "before-full"
67
68# get the numbers now for default and full
69cleanup
70git checkout $HEAD
71record "after-default"
72
73cleanup
74scripts/config.py full
75record "after-full"
76
77# get the numbers now for driver-only and reference
78cleanup
79reference_config
80record "reference"
81
82cleanup
83export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-drivers.csv"
84tests/scripts/all.sh -k test_psa_crypto_config_accel_hash_use_psa
85
86# analysis
87
88compare_suite () {
89 ref="outcome-$1.csv"
90 new="outcome-$2.csv"
91 suite="$3"
92
93 pattern_suite=";test_suite_$suite;"
94 total=$(grep -c "$pattern_suite" "$ref")
95 sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p"
96 sed -n "$sed_cmd" "$ref" > skipped-ref
97 sed -n "$sed_cmd" "$new" > skipped-new
98 nb_ref=$(wc -l <skipped-ref)
99 nb_new=$(wc -l <skipped-new)
100
101 printf "%12s: total %3d; skipped %3d -> %3d\n" \
102 $suite $total $nb_ref $nb_new
103 diff skipped-ref skipped-new | grep '^> ' || true
104 rm skipped-ref skipped-new
105}
106
107compare_builds () {
108 printf "\n*** Comparing $1 -> $2 ***\n"
109 for suite in $SUITES; do
110 compare_suite "$1" "$2" "$suite"
111 done
112}
113
114compare_builds before-default after-default
115compare_builds before-full after-full
116compare_builds reference drivers