Merge pull request #9558 from gilles-peskine-arm/run-test-suites-on-subproject

Run test suites on subproject
This commit is contained in:
Gilles Peskine 2024-09-28 08:31:30 +00:00 committed by GitHub
commit 46771295f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 58 deletions

View File

@ -281,7 +281,6 @@ endif
# Test suites caught by SKIP_TEST_SUITES are built but not executed.
check: $(BINARIES) $(CRYPTO_BINARIES)
perl scripts/run-test-suites.pl $(TEST_FLAGS) --skip=$(SKIP_TEST_SUITES)
cd ../tf-psa-crypto/tests && perl ../../tests/scripts/run-test-suites.pl $(TEST_FLAGS) --skip=$(SKIP_TEST_SUITES)
test: check

View File

@ -35,8 +35,6 @@ if [ -d library -a -d include -a -d tests ]; then :; else
exit 1
fi
MBEDTLS_ROOT_DIR="$PWD"
: ${OPENSSL:="openssl"}
: ${GNUTLS_CLI:="gnutls-cli"}
: ${GNUTLS_SERV:="gnutls-serv"}
@ -81,26 +79,21 @@ make
# Step 2 - Execute the tests
TEST_OUTPUT=out_${PPID}
cd $MBEDTLS_ROOT_DIR/tests
cd tests
if [ ! -f "seedfile" ]; then
dd if=/dev/urandom of="seedfile" bs=64 count=1
fi
cd $MBEDTLS_ROOT_DIR/tf-psa-crypto/tests
if [ ! -f "seedfile" ]; then
dd if=/dev/urandom of="seedfile" bs=64 count=1
if [ ! -f "../tf-psa-crypto/tests/seedfile" ]; then
cp "seedfile" "../tf-psa-crypto/tests/seedfile"
fi
echo
# Step 2a - Unit Tests (keep going even if some tests fail)
echo '################ Unit tests ################'
cd $MBEDTLS_ROOT_DIR/tests
perl scripts/run-test-suites.pl -v 2 |tee tls-x509-unit-test-$TEST_OUTPUT
cd $MBEDTLS_ROOT_DIR/tf-psa-crypto/tests
perl $MBEDTLS_ROOT_DIR/tests/scripts/run-test-suites.pl -v 2 |tee ../../tests/crypto-unit-test-$TEST_OUTPUT
perl scripts/run-test-suites.pl -v 2 |tee unit-test-$TEST_OUTPUT
echo '^^^^^^^^^^^^^^^^ Unit tests ^^^^^^^^^^^^^^^^'
echo
cd $MBEDTLS_ROOT_DIR/tests
# Step 2b - System Tests (keep going even if some tests fail)
echo
echo '################ ssl-opt.sh ################'
@ -151,13 +144,13 @@ rm -f "tests/basic-build-test-$$.ok"
cd tests
# Step 4a - TLS and x509 unit tests
echo "TLS and x509 unit tests - tests/scripts/run-test-suites.pl"
# Step 4a - Unit tests
echo "Unit tests - tests/scripts/run-test-suites.pl"
PASSED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
SKIPPED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
TOTAL_SUITES=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
FAILED_TESTS=$(tail -n6 tls-x509-unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
PASSED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
SKIPPED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
TOTAL_SUITES=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
FAILED_TESTS=$(tail -n6 unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
echo "No test suites : $TOTAL_SUITES"
echo "Passed : $PASSED_TESTS"
@ -173,29 +166,7 @@ rm -f "tests/basic-build-test-$$.ok"
TOTAL_AVAIL=$(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))
TOTAL_EXED=$(($PASSED_TESTS + $FAILED_TESTS))
# Step 4b - Crypto unit tests
echo "Crypto unit tests - tests/scripts/run-test-suites.pl"
PASSED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/test cases passed :[\t]*\([0-9]*\)/\1/p'| tr -d ' ')
SKIPPED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/skipped :[ \t]*\([0-9]*\)/\1/p'| tr -d ' ')
TOTAL_SUITES=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) .*, [0-9]* tests run)/\1/p'| tr -d ' ')
FAILED_TESTS=$(tail -n6 crypto-unit-test-$TEST_OUTPUT|sed -n -e 's/failed :[\t]*\([0-9]*\)/\1/p' |tr -d ' ')
echo "No test suites : $TOTAL_SUITES"
echo "Passed : $PASSED_TESTS"
echo "Failed : $FAILED_TESTS"
echo "Skipped : $SKIPPED_TESTS"
echo "Total exec'd tests : $(($PASSED_TESTS + $FAILED_TESTS))"
echo "Total avail tests : $(($PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))"
echo
TOTAL_PASS=$(($TOTAL_PASS+$PASSED_TESTS))
TOTAL_FAIL=$(($TOTAL_FAIL+$FAILED_TESTS))
TOTAL_SKIP=$(($TOTAL_SKIP+$SKIPPED_TESTS))
TOTAL_AVAIL=$(($TOTAL_AVAIL + $PASSED_TESTS + $FAILED_TESTS + $SKIPPED_TESTS))
TOTAL_EXED=$(($TOTAL_EXED + $PASSED_TESTS + $FAILED_TESTS))
# Step 4c - TLS Options tests
# Step 4b - TLS Options tests
echo "TLS Options tests - tests/ssl-opt.sh"
PASSED_TESTS=$(tail -n5 sys-test-$TEST_OUTPUT|sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p')
@ -217,7 +188,7 @@ rm -f "tests/basic-build-test-$$.ok"
TOTAL_EXED=$(($TOTAL_EXED + $TOTAL_TESTS))
# Step 4d - System Compatibility tests
# Step 4c - System Compatibility tests
echo "System/Compatibility tests - tests/compat.sh"
PASSED_TESTS=$(cat compat-test-$TEST_OUTPUT | sed -n -e 's/.* (\([0-9]*\) \/ [0-9]* tests ([0-9]* skipped))$/\1/p' | awk 'BEGIN{ s = 0 } { s += $1 } END{ print s }')
@ -239,7 +210,7 @@ rm -f "tests/basic-build-test-$$.ok"
TOTAL_EXED=$(($TOTAL_EXED + $EXED_TESTS))
# Step 4e - Grand totals
# Step 4d - Grand totals
echo "-------------------------------------------------------------------------"
echo "Total tests"
@ -251,13 +222,12 @@ rm -f "tests/basic-build-test-$$.ok"
echo
# Step 4f - Coverage report
# Step 4e - Coverage report
echo "Coverage statistics:"
sed -n '1,/^Overall coverage/d; /%/p' cov-$TEST_OUTPUT
echo
rm tls-x509-unit-test-$TEST_OUTPUT
rm crypto-unit-test-$TEST_OUTPUT
rm unit-test-$TEST_OUTPUT
rm sys-test-$TEST_OUTPUT
rm compat-test-$TEST_OUTPUT
rm cov-$TEST_OUTPUT

View File

@ -28,6 +28,7 @@ use strict;
use utf8;
use open qw(:std utf8);
use Cwd qw(getcwd);
use Getopt::Long qw(:config auto_help gnu_compat);
use Pod::Usage;
@ -40,7 +41,8 @@ GetOptions(
# All test suites = executable files with a .datax file.
my @suites = ();
for my $data_file (glob 'test_suite_*.datax') {
my @test_dirs = qw(../tf-psa-crypto/tests .);
for my $data_file (map {glob "$_/test_suite_*.datax"} @test_dirs) {
(my $base = $data_file) =~ s/\.datax$//;
push @suites, $base if -x $base;
push @suites, "$base.exe" if -e "$base.exe";
@ -59,15 +61,8 @@ my $skip_re =
')(\z|\.)' );
# in case test suites are linked dynamically
if (-d '../../tf-psa-crypto') {
$ENV{'LD_LIBRARY_PATH'} = '../../library';
$ENV{'DYLD_LIBRARY_PATH'} = '../../library';
}
else
{
$ENV{'LD_LIBRARY_PATH'} = '../library';
$ENV{'DYLD_LIBRARY_PATH'} = '../library';
}
$ENV{'LD_LIBRARY_PATH'} = getcwd() . "/../library";
$ENV{'DYLD_LIBRARY_PATH'} = $ENV{'LD_LIBRARY_PATH'}; # For macOS
my $prefix = $^O eq "MSWin32" ? '' : './';
@ -82,8 +77,13 @@ sub pad_print_center {
print $padchar x( $padlen ), " $string ", $padchar x( $padlen ), "\n";
}
for my $suite (@suites)
for my $suite_path (@suites)
{
my ($dir, $suite) = ('.', $suite_path);
if ($suite =~ m!(.*)/([^/]*)!) {
$dir = $1;
$suite = $2;
}
print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
if( $suite =~ /$skip_re/o ) {
print "SKIP\n";
@ -91,7 +91,7 @@ for my $suite (@suites)
next;
}
my $command = "$prefix$suite";
my $command = "cd $dir && $prefix$suite";
if( $verbose ) {
$command .= ' -v';
}