2018-04-04 23:44:29 +02:00
|
|
|
#!/usr/bin/env perl
|
2015-07-08 22:20:03 +02:00
|
|
|
|
2016-03-11 18:33:39 +01:00
|
|
|
# run-test-suites.pl
|
|
|
|
#
|
2020-08-07 13:07:28 +02:00
|
|
|
# Copyright The Mbed TLS Contributors
|
2020-05-26 01:54:15 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2018-12-14 18:23:13 +01:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
Execute all the test suites and print a summary of the results.
|
|
|
|
|
2018-11-29 11:15:06 +01:00
|
|
|
run-test-suites.pl [[-v|--verbose] [VERBOSITY]] [--skip=SUITE[...]]
|
2018-12-14 18:23:13 +01:00
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
|
|
-v|--verbose Print detailed failure information.
|
|
|
|
-v 2|--verbose=2 Print detailed failure information and summary messages.
|
|
|
|
-v 3|--verbose=3 Print detailed information about every test case.
|
2018-11-29 11:15:06 +01:00
|
|
|
--skip=SUITE[,SUITE...]
|
|
|
|
Skip the specified SUITE(s). This option can be used
|
|
|
|
multiple times.
|
2018-12-14 18:23:13 +01:00
|
|
|
|
|
|
|
=cut
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2015-07-08 22:20:03 +02:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use utf8;
|
|
|
|
use open qw(:std utf8);
|
|
|
|
|
2018-11-29 11:15:06 +01:00
|
|
|
use Getopt::Long qw(:config auto_help gnu_compat);
|
2018-12-14 18:23:13 +01:00
|
|
|
use Pod::Usage;
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2018-10-05 14:23:35 +02:00
|
|
|
my $verbose = 0;
|
2018-11-29 11:15:06 +01:00
|
|
|
my @skip_patterns = ();
|
2018-12-14 18:23:13 +01:00
|
|
|
GetOptions(
|
2018-11-29 11:15:06 +01:00
|
|
|
'skip=s' => \@skip_patterns,
|
2018-12-14 18:23:13 +01:00
|
|
|
'verbose|v:1' => \$verbose,
|
|
|
|
) or die;
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2022-11-15 23:54:26 +01:00
|
|
|
# All test suites = executable files with a .datax file.
|
2022-11-07 10:05:49 +01:00
|
|
|
my @suites = ();
|
2022-11-15 23:54:26 +01:00
|
|
|
for my $data_file (glob 'test_suite_*.datax') {
|
|
|
|
(my $base = $data_file) =~ s/\.datax$//;
|
2022-11-07 10:05:49 +01:00
|
|
|
push @suites, $base if -x $base;
|
|
|
|
push @suites, "$base.exe" if -e "$base.exe";
|
|
|
|
}
|
2015-07-08 22:20:03 +02:00
|
|
|
die "$0: no test suite found\n" unless @suites;
|
|
|
|
|
2018-11-29 11:15:06 +01:00
|
|
|
# "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar"
|
|
|
|
# but not "test_suite_foobar".
|
|
|
|
my $skip_re =
|
|
|
|
( '\Atest_suite_(' .
|
|
|
|
join('|', map {
|
|
|
|
s/[ ,;]/|/g; # allow any of " ,;|" as separators
|
|
|
|
s/\./\./g; # "." in the input means ".", not "any character"
|
|
|
|
$_
|
|
|
|
} @skip_patterns) .
|
|
|
|
')(\z|\.)' );
|
|
|
|
|
2015-07-08 22:20:03 +02:00
|
|
|
# in case test suites are linked dynamically
|
|
|
|
$ENV{'LD_LIBRARY_PATH'} = '../library';
|
2018-03-27 20:57:58 +02:00
|
|
|
$ENV{'DYLD_LIBRARY_PATH'} = '../library';
|
2015-07-08 22:20:03 +02:00
|
|
|
|
|
|
|
my $prefix = $^O eq "MSWin32" ? '' : './';
|
|
|
|
|
2022-10-11 10:48:32 +02:00
|
|
|
my (@failed_suites, $total_tests_run, $failed, $suite_cases_passed,
|
2016-03-11 18:33:39 +01:00
|
|
|
$suite_cases_failed, $suite_cases_skipped, $total_cases_passed,
|
|
|
|
$total_cases_failed, $total_cases_skipped );
|
2018-11-29 11:15:06 +01:00
|
|
|
my $suites_skipped = 0;
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2018-10-05 13:21:15 +02:00
|
|
|
sub pad_print_center {
|
|
|
|
my( $width, $padchar, $string ) = @_;
|
|
|
|
my $padlen = ( $width - length( $string ) - 2 ) / 2;
|
|
|
|
print $padchar x( $padlen ), " $string ", $padchar x( $padlen ), "\n";
|
|
|
|
}
|
|
|
|
|
2015-07-08 22:20:03 +02:00
|
|
|
for my $suite (@suites)
|
|
|
|
{
|
|
|
|
print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
|
2018-11-29 11:15:06 +01:00
|
|
|
if( $suite =~ /$skip_re/o ) {
|
|
|
|
print "SKIP\n";
|
|
|
|
++$suites_skipped;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2018-10-05 13:21:15 +02:00
|
|
|
my $command = "$prefix$suite";
|
|
|
|
if( $verbose ) {
|
|
|
|
$command .= ' -v';
|
|
|
|
}
|
|
|
|
my $result = `$command`;
|
2016-03-11 18:33:39 +01:00
|
|
|
|
|
|
|
$suite_cases_passed = () = $result =~ /.. PASS/g;
|
|
|
|
$suite_cases_failed = () = $result =~ /.. FAILED/g;
|
|
|
|
$suite_cases_skipped = () = $result =~ /.. ----/g;
|
|
|
|
|
2019-10-21 19:08:07 +02:00
|
|
|
if( $? == 0 ) {
|
2015-07-08 22:20:03 +02:00
|
|
|
print "PASS\n";
|
2018-10-05 14:23:35 +02:00
|
|
|
if( $verbose > 2 ) {
|
|
|
|
pad_print_center( 72, '-', "Begin $suite" );
|
|
|
|
print $result;
|
|
|
|
pad_print_center( 72, '-', "End $suite" );
|
|
|
|
}
|
2015-07-08 22:20:03 +02:00
|
|
|
} else {
|
2022-10-11 10:48:32 +02:00
|
|
|
push @failed_suites, $suite;
|
2015-07-08 22:20:03 +02:00
|
|
|
print "FAIL\n";
|
2018-10-05 13:21:15 +02:00
|
|
|
if( $verbose ) {
|
|
|
|
pad_print_center( 72, '-', "Begin $suite" );
|
|
|
|
print $result;
|
|
|
|
pad_print_center( 72, '-', "End $suite" );
|
|
|
|
}
|
2015-07-08 22:20:03 +02:00
|
|
|
}
|
2016-03-11 18:33:39 +01:00
|
|
|
|
|
|
|
my ($passed, $tests, $skipped) = $result =~ /([0-9]*) \/ ([0-9]*) tests.*?([0-9]*) skipped/;
|
|
|
|
$total_tests_run += $tests - $skipped;
|
|
|
|
|
2018-10-05 14:23:35 +02:00
|
|
|
if( $verbose > 1 ) {
|
2016-03-11 18:33:39 +01:00
|
|
|
print "(test cases passed:", $suite_cases_passed,
|
|
|
|
" failed:", $suite_cases_failed,
|
|
|
|
" skipped:", $suite_cases_skipped,
|
2016-04-18 00:24:50 +02:00
|
|
|
" of total:", ($suite_cases_passed + $suite_cases_failed +
|
|
|
|
$suite_cases_skipped),
|
2016-03-11 18:33:39 +01:00
|
|
|
")\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
$total_cases_passed += $suite_cases_passed;
|
|
|
|
$total_cases_failed += $suite_cases_failed;
|
|
|
|
$total_cases_skipped += $suite_cases_skipped;
|
2015-07-08 22:20:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print "-" x 72, "\n";
|
2022-10-11 10:48:32 +02:00
|
|
|
print @failed_suites ? "FAILED" : "PASSED";
|
2018-11-29 11:15:06 +01:00
|
|
|
printf( " (%d suites, %d tests run%s)\n",
|
|
|
|
scalar(@suites) - $suites_skipped,
|
|
|
|
$total_tests_run,
|
|
|
|
$suites_skipped ? ", $suites_skipped suites skipped" : "" );
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2022-10-11 10:48:32 +02:00
|
|
|
if( $verbose && @failed_suites ) {
|
|
|
|
# the output can be very long, so provide a summary of which suites failed
|
|
|
|
print " failed suites : @failed_suites\n";
|
|
|
|
}
|
|
|
|
|
2018-10-05 14:23:35 +02:00
|
|
|
if( $verbose > 1 ) {
|
2016-03-11 18:33:39 +01:00
|
|
|
print " test cases passed :", $total_cases_passed, "\n";
|
|
|
|
print " failed :", $total_cases_failed, "\n";
|
|
|
|
print " skipped :", $total_cases_skipped, "\n";
|
|
|
|
print " of tests executed :", ( $total_cases_passed + $total_cases_failed ),
|
|
|
|
"\n";
|
|
|
|
print " of available tests :",
|
|
|
|
( $total_cases_passed + $total_cases_failed + $total_cases_skipped ),
|
2018-11-29 11:15:06 +01:00
|
|
|
"\n";
|
|
|
|
if( $suites_skipped != 0 ) {
|
|
|
|
print "Note: $suites_skipped suites were skipped.\n";
|
2016-03-11 18:33:39 +01:00
|
|
|
}
|
2018-11-29 11:15:06 +01:00
|
|
|
}
|
2016-03-11 18:33:39 +01:00
|
|
|
|
2022-10-11 10:48:32 +02:00
|
|
|
exit( @failed_suites ? 1 : 0 );
|
2016-03-11 18:33:39 +01:00
|
|
|
|