blob: 1805a3ca0e3f7aea9b51ef914e1a90f51a3f785d [file] [log] [blame]
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +02001#!/bin/sh
2
Manuel Pégourié-Gonnard222bc852022-12-29 13:47:25 +01003# This script runs tests before and after a PR and analyzes the results in
4# order to highlight any difference in the set of tests skipped.
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +02005#
Manuel Pégourié-Gonnard222bc852022-12-29 13:47:25 +01006# It can be used to check the first testing criterion mentioned in strategy.md,
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +02007# end of section "Supporting builds with drivers without the software
Manuel Pégourié-Gonnard222bc852022-12-29 13:47:25 +01008# implementation", namely: the sets of tests skipped in the default config and
9# the full config must be the same before and after the PR.
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020010#
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010011# USAGE:
12# - First, commit any uncommited changes. (Also, see warning below.)
Manuel Pégourié-Gonnard5a2e0262023-01-23 12:51:52 +010013# - Then launch --> [SKIP_SSL_OPT=1] docs/architecture/psa-migration/outcome-analysis.sh
14# - SKIP_SSL_OPT=1 can optionally be set to skip ssl-opt.sh tests
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010015#
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020016# WARNING: this script checks out a commit other than the head of the current
Manuel Pégourié-Gonnard68429fc2022-07-27 20:37:12 +020017# branch; it checks out the current branch again when running successfully,
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020018# but while the script is running, or if it terminates early in error, you
Manuel Pégourié-Gonnard68429fc2022-07-27 20:37:12 +020019# should be aware that you might be at a different commit than expected.
Manuel Pégourié-Gonnardfca4dc62022-07-26 10:10:07 +020020#
Manuel Pégourié-Gonnard222bc852022-12-29 13:47:25 +010021# NOTE: you can comment out parts that don't need to be re-done when
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020022# re-running this script (for example "get numbers before this PR").
23
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020024set -eu
25
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010026: ${SKIP_SSL_OPT:=0}
27
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020028cleanup() {
29 make clean
30 git checkout -- include/mbedtls/mbedtls_config.h include/psa/crypto_config.h
31}
32
33record() {
34 export MBEDTLS_TEST_OUTCOME_FILE="$PWD/outcome-$1.csv"
35 rm -f $MBEDTLS_TEST_OUTCOME_FILE
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010036
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020037 make check
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010038
39 if [ $SKIP_SSL_OPT -eq 0 ]; then
40 make -C programs ssl/ssl_server2 ssl/ssl_client2 \
41 test/udp_proxy test/query_compile_time_config
42 tests/ssl-opt.sh
43 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020044}
45
Valerio Setticcb03442023-07-31 15:07:49 +020046# save current HEAD.
Valerio Settiab02d392023-07-31 16:47:07 +020047# Note: this can optionally be updated to
48# HEAD=$(git branch --show-current)
49# when using a Git version above 2.22
50HEAD=$(git rev-parse --abbrev-ref HEAD)
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020051
Przemek Stekiel93986642022-11-09 15:06:44 +010052# get the numbers before this PR for default and full
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020053cleanup
Przemek Stekiel93986642022-11-09 15:06:44 +010054git checkout $(git merge-base HEAD development)
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010055
Przemek Stekiel93986642022-11-09 15:06:44 +010056record "before-default"
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020057
58cleanup
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010059
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
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010066
Przemek Stekiel93986642022-11-09 15:06:44 +010067record "after-default"
68
69cleanup
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010070
Przemek Stekiel93986642022-11-09 15:06:44 +010071scripts/config.py full
72record "after-full"
73
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010074cleanup
75
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020076# analysis
77
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +020078populate_suites () {
79 SUITES=''
80 make generated_files >/dev/null
81 data_files=$(cd tests/suites && echo *.data)
82 for data in $data_files; do
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010083 suite=${data%.data}
Manuel Pégourié-Gonnard222bc852022-12-29 13:47:25 +010084 SUITES="$SUITES $suite"
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +020085 done
86 make neat
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +010087
88 if [ $SKIP_SSL_OPT -eq 0 ]; then
89 SUITES="$SUITES ssl-opt"
90 extra_files=$(cd tests/opt-testcases && echo *.sh)
91 for extra in $extra_files; do
92 suite=${extra%.sh}
93 SUITES="$SUITES $suite"
94 done
95 fi
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +020096}
97
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +020098compare_suite () {
99 ref="outcome-$1.csv"
100 new="outcome-$2.csv"
101 suite="$3"
102
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +0100103 pattern_suite=";$suite;"
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200104 total=$(grep -c "$pattern_suite" "$ref")
105 sed_cmd="s/^.*$pattern_suite\(.*\);SKIP.*/\1/p"
106 sed -n "$sed_cmd" "$ref" > skipped-ref
107 sed -n "$sed_cmd" "$new" > skipped-new
108 nb_ref=$(wc -l <skipped-ref)
109 nb_new=$(wc -l <skipped-new)
110
Manuel Pégourié-Gonnard6bbeba62022-12-29 14:02:05 +0100111 name=${suite#test_suite_}
112 printf "%40s: total %4d; skipped %4d -> %4d\n" \
113 $name $total $nb_ref $nb_new
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200114 if diff skipped-ref skipped-new | grep '^> '; then
115 ret=1
116 else
117 ret=0
118 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200119 rm skipped-ref skipped-new
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200120 return $ret
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200121}
122
123compare_builds () {
124 printf "\n*** Comparing $1 -> $2 ***\n"
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200125 failed=''
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200126 for suite in $SUITES; do
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200127 if compare_suite "$1" "$2" "$suite"; then :; else
128 failed="$failed $suite"
129 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200130 done
Manuel Pégourié-Gonnardb51051f2022-10-18 09:42:30 +0200131 if [ -z "$failed" ]; then
132 printf "No coverage gap found.\n"
133 else
134 printf "Suites with less coverage:%s\n" "$failed"
135 fi
Manuel Pégourié-Gonnardfb2ed582022-07-21 11:04:52 +0200136}
137
Manuel Pégourié-Gonnard2bb2f152022-10-12 10:57:31 +0200138populate_suites
Przemek Stekiel93986642022-11-09 15:06:44 +0100139compare_builds before-default after-default
140compare_builds before-full after-full