blob: 1f73a545e77d88cb95b31b69712f045151b0dbab [file] [log] [blame]
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +01001#!/usr/bin/perl
2
SimonBad8fbc02016-03-11 17:33:39 +00003# run-test-suites.pl
4#
SimonB8ca7bc42016-04-17 23:24:50 +01005# This file is part of mbed TLS (https://tls.mbed.org)
6#
SimonBad8fbc02016-03-11 17:33:39 +00007# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
8#
9# Purpose
10#
11# Executes all the available test suites, and provides a basic summary of the
12# results.
13#
14# Usage: run-test-suites.pl [-v]
15#
16# Options :
17# -v|--verbose - Provide a pass/fail/skip breakdown per test suite and
18# in total
19#
20
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010021use warnings;
22use strict;
23
24use utf8;
25use open qw(:std utf8);
26
SimonBad8fbc02016-03-11 17:33:39 +000027use constant FALSE => 0;
28use constant TRUE => 1;
29
30my $verbose;
31my $switch = shift;
32if ( defined($switch) && ( $switch eq "-v" || $switch eq "--verbose" ) ) {
33 $verbose = TRUE;
34}
35
Gilles Peskine071db412017-05-03 16:26:47 +020036# All test suites = executable files, excluding source files, debug
37# and profiling information, etc. We can't just grep {! /\./} because
38#some of our test cases' base names contain a dot.
39my @suites = grep { -x $_ || /\.exe$/ } glob 'test_suite_*';
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010040die "$0: no test suite found\n" unless @suites;
41
42# in case test suites are linked dynamically
43$ENV{'LD_LIBRARY_PATH'} = '../library';
44
45my $prefix = $^O eq "MSWin32" ? '' : './';
46
SimonBad8fbc02016-03-11 17:33:39 +000047my ($failed_suites, $total_tests_run, $failed, $suite_cases_passed,
48 $suite_cases_failed, $suite_cases_skipped, $total_cases_passed,
49 $total_cases_failed, $total_cases_skipped );
50
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010051for my $suite (@suites)
52{
53 print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
54 my $result = `$prefix$suite`;
SimonBad8fbc02016-03-11 17:33:39 +000055
56 $suite_cases_passed = () = $result =~ /.. PASS/g;
57 $suite_cases_failed = () = $result =~ /.. FAILED/g;
58 $suite_cases_skipped = () = $result =~ /.. ----/g;
59
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010060 if( $result =~ /PASSED/ ) {
61 print "PASS\n";
62 } else {
63 $failed_suites++;
64 print "FAIL\n";
65 }
SimonBad8fbc02016-03-11 17:33:39 +000066
67 my ($passed, $tests, $skipped) = $result =~ /([0-9]*) \/ ([0-9]*) tests.*?([0-9]*) skipped/;
68 $total_tests_run += $tests - $skipped;
69
70 if ( $verbose ) {
71 print "(test cases passed:", $suite_cases_passed,
72 " failed:", $suite_cases_failed,
73 " skipped:", $suite_cases_skipped,
SimonB8ca7bc42016-04-17 23:24:50 +010074 " of total:", ($suite_cases_passed + $suite_cases_failed +
75 $suite_cases_skipped),
SimonBad8fbc02016-03-11 17:33:39 +000076 ")\n"
77 }
78
79 $total_cases_passed += $suite_cases_passed;
80 $total_cases_failed += $suite_cases_failed;
81 $total_cases_skipped += $suite_cases_skipped;
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010082}
83
84print "-" x 72, "\n";
85print $failed_suites ? "FAILED" : "PASSED";
86printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run;
SimonBad8fbc02016-03-11 17:33:39 +000087
88if ( $verbose ) {
89 print " test cases passed :", $total_cases_passed, "\n";
90 print " failed :", $total_cases_failed, "\n";
91 print " skipped :", $total_cases_skipped, "\n";
92 print " of tests executed :", ( $total_cases_passed + $total_cases_failed ),
93 "\n";
94 print " of available tests :",
95 ( $total_cases_passed + $total_cases_failed + $total_cases_skipped ),
96 "\n"
97 }
98
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010099exit( $failed_suites ? 1 : 0 );
SimonBad8fbc02016-03-11 17:33:39 +0000100