2018-04-04 22:26:56 +00:00
|
|
|
#!/usr/bin/env perl
|
2015-07-08 20:20:03 +00:00
|
|
|
|
2016-03-11 17:33:39 +00:00
|
|
|
# run-test-suites.pl
|
|
|
|
#
|
2016-04-17 22:24:50 +00:00
|
|
|
# This file is part of mbed TLS (https://tls.mbed.org)
|
|
|
|
#
|
2016-03-11 17:33:39 +00:00
|
|
|
# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
|
|
|
|
#
|
|
|
|
# Purpose
|
|
|
|
#
|
|
|
|
# Executes all the available test suites, and provides a basic summary of the
|
|
|
|
# results.
|
|
|
|
#
|
|
|
|
# Usage: run-test-suites.pl [-v]
|
|
|
|
#
|
|
|
|
# Options :
|
|
|
|
# -v|--verbose - Provide a pass/fail/skip breakdown per test suite and
|
|
|
|
# in total
|
|
|
|
#
|
|
|
|
|
2015-07-08 20:20:03 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
use utf8;
|
|
|
|
use open qw(:std utf8);
|
|
|
|
|
2018-10-05 11:45:15 +00:00
|
|
|
use Getopt::Long;
|
2016-03-11 17:33:39 +00:00
|
|
|
|
2018-10-05 12:23:35 +00:00
|
|
|
my $verbose = 0;
|
|
|
|
GetOptions( "verbose|v:1" => \$verbose );
|
2016-03-11 17:33:39 +00:00
|
|
|
|
2017-05-03 14:26:47 +00:00
|
|
|
# All test suites = executable files, excluding source files, debug
|
|
|
|
# and profiling information, etc. We can't just grep {! /\./} because
|
2018-06-27 15:16:39 +00:00
|
|
|
# some of our test cases' base names contain a dot.
|
2017-05-03 14:26:47 +00:00
|
|
|
my @suites = grep { -x $_ || /\.exe$/ } glob 'test_suite_*';
|
2018-09-30 20:57:34 +00:00
|
|
|
@suites = grep { !/\.c$/ && !/\.data$/ && -f } @suites;
|
2015-07-08 20:20:03 +00:00
|
|
|
die "$0: no test suite found\n" unless @suites;
|
|
|
|
|
|
|
|
# in case test suites are linked dynamically
|
|
|
|
$ENV{'LD_LIBRARY_PATH'} = '../library';
|
2018-03-27 18:57:58 +00:00
|
|
|
$ENV{'DYLD_LIBRARY_PATH'} = '../library';
|
2015-07-08 20:20:03 +00:00
|
|
|
|
|
|
|
my $prefix = $^O eq "MSWin32" ? '' : './';
|
|
|
|
|
2016-03-11 17:33:39 +00:00
|
|
|
my ($failed_suites, $total_tests_run, $failed, $suite_cases_passed,
|
|
|
|
$suite_cases_failed, $suite_cases_skipped, $total_cases_passed,
|
|
|
|
$total_cases_failed, $total_cases_skipped );
|
|
|
|
|
2018-10-05 11:21:15 +00: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 20:20:03 +00:00
|
|
|
for my $suite (@suites)
|
|
|
|
{
|
|
|
|
print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
|
2018-10-05 11:21:15 +00:00
|
|
|
my $command = "$prefix$suite";
|
|
|
|
if( $verbose ) {
|
|
|
|
$command .= ' -v';
|
|
|
|
}
|
|
|
|
my $result = `$command`;
|
2016-03-11 17:33:39 +00:00
|
|
|
|
|
|
|
$suite_cases_passed = () = $result =~ /.. PASS/g;
|
|
|
|
$suite_cases_failed = () = $result =~ /.. FAILED/g;
|
|
|
|
$suite_cases_skipped = () = $result =~ /.. ----/g;
|
|
|
|
|
2015-07-08 20:20:03 +00:00
|
|
|
if( $result =~ /PASSED/ ) {
|
|
|
|
print "PASS\n";
|
2018-10-05 12:23:35 +00:00
|
|
|
if( $verbose > 2 ) {
|
|
|
|
pad_print_center( 72, '-', "Begin $suite" );
|
|
|
|
print $result;
|
|
|
|
pad_print_center( 72, '-', "End $suite" );
|
|
|
|
}
|
2015-07-08 20:20:03 +00:00
|
|
|
} else {
|
|
|
|
$failed_suites++;
|
|
|
|
print "FAIL\n";
|
2018-10-05 11:21:15 +00:00
|
|
|
if( $verbose ) {
|
|
|
|
pad_print_center( 72, '-', "Begin $suite" );
|
|
|
|
print $result;
|
|
|
|
pad_print_center( 72, '-', "End $suite" );
|
|
|
|
}
|
2015-07-08 20:20:03 +00:00
|
|
|
}
|
2016-03-11 17:33:39 +00:00
|
|
|
|
|
|
|
my ($passed, $tests, $skipped) = $result =~ /([0-9]*) \/ ([0-9]*) tests.*?([0-9]*) skipped/;
|
|
|
|
$total_tests_run += $tests - $skipped;
|
|
|
|
|
2018-10-05 12:23:35 +00:00
|
|
|
if( $verbose > 1 ) {
|
2016-03-11 17:33:39 +00:00
|
|
|
print "(test cases passed:", $suite_cases_passed,
|
|
|
|
" failed:", $suite_cases_failed,
|
|
|
|
" skipped:", $suite_cases_skipped,
|
2016-04-17 22:24:50 +00:00
|
|
|
" of total:", ($suite_cases_passed + $suite_cases_failed +
|
|
|
|
$suite_cases_skipped),
|
2016-03-11 17:33:39 +00:00
|
|
|
")\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
$total_cases_passed += $suite_cases_passed;
|
|
|
|
$total_cases_failed += $suite_cases_failed;
|
|
|
|
$total_cases_skipped += $suite_cases_skipped;
|
2015-07-08 20:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
print "-" x 72, "\n";
|
|
|
|
print $failed_suites ? "FAILED" : "PASSED";
|
|
|
|
printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run;
|
2016-03-11 17:33:39 +00:00
|
|
|
|
2018-10-05 12:23:35 +00:00
|
|
|
if( $verbose > 1 ) {
|
2016-03-11 17:33:39 +00: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 ),
|
|
|
|
"\n"
|
|
|
|
}
|
|
|
|
|
2015-07-08 20:20:03 +00:00
|
|
|
exit( $failed_suites ? 1 : 0 );
|
2016-03-11 17:33:39 +00:00
|
|
|
|