blob: 9084685482b693012b641b05c143cdd664cbe252 [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.
Przemek Stekiel93986642022-11-09 15:06:44 +010016# This part is verified by tests/scripts/analyze_outcomes.py
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020017#
18# WARNING: this script checks out a commit other than the head of the current
Manuel Pégourié-Gonnard68429fc2022-07-27 20:37:12 +020019# branch; it checks out the current branch again when running successfully,
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020020# but while the script is running, or if it terminates early in error, you
Manuel Pégourié-Gonnard68429fc2022-07-27 20:37:12 +020021# should be aware that you might be at a different commit than expected.
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020022#
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é-Gonnardfb2ed582022-07-21 11:04:52 +020025#
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é-Gonnard2bb2f152022-10-12 10:57:31 +020030# Space-separated list of test suites to ignore:
31# if SSS is in that list, test_suite_SSS and test_suite_SSS.* are ignored.
32IGNORE="md mdx shax" # accelerated
33IGNORE="$IGNORE entropy hmac_drbg random" # disabled (ext. RNG)
34IGNORE="$IGNORE psa_crypto_init" # needs internal RNG
Manuel Pégourié-Gonnard0dc40772022-10-19 12:12:21 +020035IGNORE="$IGNORE hkdf" # disabled in the all.sh component tested
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020036# ----- END edit this -----
37
38set -eu
39
40cleanup() {
41 make clean
42 git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h
43}
44
45record() {
46 export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv"
47 rm -f $MBEDTLS_TEST_OUTCOME_FILE
48 make check
49}
50
Przemek Stekiel93986642022-11-09 15:06:44 +010051# save current HEAD
52HEAD=$(git branch --show-current)
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020053
Przemek Stekiel93986642022-11-09 15:06:44 +010054# get the numbers before this PR for default and full
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020055cleanup
Przemek Stekiel93986642022-11-09 15:06:44 +010056git checkout $(git merge-base HEAD development)
57record "before-default"
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020058
59cleanup
Przemek Stekiel93986642022-11-09 15:06:44 +010060scripts/config.py full
61record "before-full"
62
63# get the numbers now for default and full
64cleanup
65git checkout $HEAD
66record "after-default"
67
68cleanup
69scripts/config.py full
70record "after-full"
71
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020072
73# analysis
74
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +020075populate_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é-Gonnardfb2ed582022-07-21 11:04:52 +020091compare_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é-Gonnard2bb2f152022-10-12 10:57:31 +0200104 printf "%36s: total %4d; skipped %4d -> %4d\n" \
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200105 $suite $total $nb_ref $nb_new
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200106 if diff skipped-ref skipped-new | grep '^> '; then
107 ret=1
108 else
109 ret=0
110 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200111 rm skipped-ref skipped-new
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200112 return $ret
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200113}
114
115compare_builds () {
116 printf "\n*** Comparing $1 -> $2 ***\n"
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200117 failed=''
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200118 for suite in $SUITES; do
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200119 if compare_suite "$1" "$2" "$suite"; then :; else
120 failed="$failed $suite"
121 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200122 done
Manuel Pégourié-Gonnardb51051f2022-10-18 09:42:30 +0200123 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é-Gonnardfb2ed582022-07-21 11:04:52 +0200128}
129
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200130populate_suites
Przemek Stekiel93986642022-11-09 15:06:44 +0100131compare_builds before-default after-default
132compare_builds before-full after-full