blob: fb77e1571cfbcd3369017080a9593f04ea944bcf [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#
5# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
6#
7# Purpose
8#
9# Executes all the available test suites, and provides a basic summary of the
10# results.
11#
12# Usage: run-test-suites.pl [-v]
13#
14# Options :
15# -v|--verbose - Provide a pass/fail/skip breakdown per test suite and
16# in total
17#
18
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010019use warnings;
20use strict;
21
22use utf8;
23use open qw(:std utf8);
24
SimonBad8fbc02016-03-11 17:33:39 +000025use constant FALSE => 0;
26use constant TRUE => 1;
27
28my $verbose;
29my $switch = shift;
30if ( defined($switch) && ( $switch eq "-v" || $switch eq "--verbose" ) ) {
31 $verbose = TRUE;
32}
33
Simon Butcherab0c51d2016-03-13 01:23:34 +000034my @suites = grep { ! /\.(?:c|gcno|gcda|dSYM)$/ } glob 'test_suite_*';
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010035die "$0: no test suite found\n" unless @suites;
36
37# in case test suites are linked dynamically
38$ENV{'LD_LIBRARY_PATH'} = '../library';
39
40my $prefix = $^O eq "MSWin32" ? '' : './';
41
SimonBad8fbc02016-03-11 17:33:39 +000042my ($failed_suites, $total_tests_run, $failed, $suite_cases_passed,
43 $suite_cases_failed, $suite_cases_skipped, $total_cases_passed,
44 $total_cases_failed, $total_cases_skipped );
45
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010046for my $suite (@suites)
47{
48 print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
49 my $result = `$prefix$suite`;
SimonBad8fbc02016-03-11 17:33:39 +000050
51 $suite_cases_passed = () = $result =~ /.. PASS/g;
52 $suite_cases_failed = () = $result =~ /.. FAILED/g;
53 $suite_cases_skipped = () = $result =~ /.. ----/g;
54
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010055 if( $result =~ /PASSED/ ) {
56 print "PASS\n";
57 } else {
58 $failed_suites++;
59 print "FAIL\n";
60 }
SimonBad8fbc02016-03-11 17:33:39 +000061
62 my ($passed, $tests, $skipped) = $result =~ /([0-9]*) \/ ([0-9]*) tests.*?([0-9]*) skipped/;
63 $total_tests_run += $tests - $skipped;
64
65 if ( $verbose ) {
66 print "(test cases passed:", $suite_cases_passed,
67 " failed:", $suite_cases_failed,
68 " skipped:", $suite_cases_skipped,
69 " of total:", ( $suite_cases_passed + $suite_cases_failed ),
70 ")\n"
71 }
72
73 $total_cases_passed += $suite_cases_passed;
74 $total_cases_failed += $suite_cases_failed;
75 $total_cases_skipped += $suite_cases_skipped;
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010076}
77
78print "-" x 72, "\n";
79print $failed_suites ? "FAILED" : "PASSED";
80printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run;
SimonBad8fbc02016-03-11 17:33:39 +000081
82if ( $verbose ) {
83 print " test cases passed :", $total_cases_passed, "\n";
84 print " failed :", $total_cases_failed, "\n";
85 print " skipped :", $total_cases_skipped, "\n";
86 print " of tests executed :", ( $total_cases_passed + $total_cases_failed ),
87 "\n";
88 print " of available tests :",
89 ( $total_cases_passed + $total_cases_failed + $total_cases_skipped ),
90 "\n"
91 }
92
Manuel Pégourié-Gonnard85113842015-07-08 21:20:03 +010093exit( $failed_suites ? 1 : 0 );
SimonBad8fbc02016-03-11 17:33:39 +000094