mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 #!/usr/bin/perl
markrad 0:cdf462088d13 2
markrad 0:cdf462088d13 3 # run-test-suites.pl
markrad 0:cdf462088d13 4 #
markrad 0:cdf462088d13 5 # This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 6 #
markrad 0:cdf462088d13 7 # Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 8 #
markrad 0:cdf462088d13 9 # Purpose
markrad 0:cdf462088d13 10 #
markrad 0:cdf462088d13 11 # Executes all the available test suites, and provides a basic summary of the
markrad 0:cdf462088d13 12 # results.
markrad 0:cdf462088d13 13 #
markrad 0:cdf462088d13 14 # Usage: run-test-suites.pl [-v]
markrad 0:cdf462088d13 15 #
markrad 0:cdf462088d13 16 # Options :
markrad 0:cdf462088d13 17 # -v|--verbose - Provide a pass/fail/skip breakdown per test suite and
markrad 0:cdf462088d13 18 # in total
markrad 0:cdf462088d13 19 #
markrad 0:cdf462088d13 20
markrad 0:cdf462088d13 21 use warnings;
markrad 0:cdf462088d13 22 use strict;
markrad 0:cdf462088d13 23
markrad 0:cdf462088d13 24 use utf8;
markrad 0:cdf462088d13 25 use open qw(:std utf8);
markrad 0:cdf462088d13 26
markrad 0:cdf462088d13 27 use constant FALSE => 0;
markrad 0:cdf462088d13 28 use constant TRUE => 1;
markrad 0:cdf462088d13 29
markrad 0:cdf462088d13 30 my $verbose;
markrad 0:cdf462088d13 31 my $switch = shift;
markrad 0:cdf462088d13 32 if ( defined($switch) && ( $switch eq "-v" || $switch eq "--verbose" ) ) {
markrad 0:cdf462088d13 33 $verbose = TRUE;
markrad 0:cdf462088d13 34 }
markrad 0:cdf462088d13 35
markrad 0:cdf462088d13 36 my @suites = grep { ! /\.(?:c|gcno|gcda|dSYM)$/ } glob 'test_suite_*';
markrad 0:cdf462088d13 37 die "$0: no test suite found\n" unless @suites;
markrad 0:cdf462088d13 38
markrad 0:cdf462088d13 39 # in case test suites are linked dynamically
markrad 0:cdf462088d13 40 $ENV{'LD_LIBRARY_PATH'} = '../library';
markrad 0:cdf462088d13 41
markrad 0:cdf462088d13 42 my $prefix = $^O eq "MSWin32" ? '' : './';
markrad 0:cdf462088d13 43
markrad 0:cdf462088d13 44 my ($failed_suites, $total_tests_run, $failed, $suite_cases_passed,
markrad 0:cdf462088d13 45 $suite_cases_failed, $suite_cases_skipped, $total_cases_passed,
markrad 0:cdf462088d13 46 $total_cases_failed, $total_cases_skipped );
markrad 0:cdf462088d13 47
markrad 0:cdf462088d13 48 for my $suite (@suites)
markrad 0:cdf462088d13 49 {
markrad 0:cdf462088d13 50 print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " ";
markrad 0:cdf462088d13 51 my $result = `$prefix$suite`;
markrad 0:cdf462088d13 52
markrad 0:cdf462088d13 53 $suite_cases_passed = () = $result =~ /.. PASS/g;
markrad 0:cdf462088d13 54 $suite_cases_failed = () = $result =~ /.. FAILED/g;
markrad 0:cdf462088d13 55 $suite_cases_skipped = () = $result =~ /.. ----/g;
markrad 0:cdf462088d13 56
markrad 0:cdf462088d13 57 if( $result =~ /PASSED/ ) {
markrad 0:cdf462088d13 58 print "PASS\n";
markrad 0:cdf462088d13 59 } else {
markrad 0:cdf462088d13 60 $failed_suites++;
markrad 0:cdf462088d13 61 print "FAIL\n";
markrad 0:cdf462088d13 62 }
markrad 0:cdf462088d13 63
markrad 0:cdf462088d13 64 my ($passed, $tests, $skipped) = $result =~ /([0-9]*) \/ ([0-9]*) tests.*?([0-9]*) skipped/;
markrad 0:cdf462088d13 65 $total_tests_run += $tests - $skipped;
markrad 0:cdf462088d13 66
markrad 0:cdf462088d13 67 if ( $verbose ) {
markrad 0:cdf462088d13 68 print "(test cases passed:", $suite_cases_passed,
markrad 0:cdf462088d13 69 " failed:", $suite_cases_failed,
markrad 0:cdf462088d13 70 " skipped:", $suite_cases_skipped,
markrad 0:cdf462088d13 71 " of total:", ($suite_cases_passed + $suite_cases_failed +
markrad 0:cdf462088d13 72 $suite_cases_skipped),
markrad 0:cdf462088d13 73 ")\n"
markrad 0:cdf462088d13 74 }
markrad 0:cdf462088d13 75
markrad 0:cdf462088d13 76 $total_cases_passed += $suite_cases_passed;
markrad 0:cdf462088d13 77 $total_cases_failed += $suite_cases_failed;
markrad 0:cdf462088d13 78 $total_cases_skipped += $suite_cases_skipped;
markrad 0:cdf462088d13 79 }
markrad 0:cdf462088d13 80
markrad 0:cdf462088d13 81 print "-" x 72, "\n";
markrad 0:cdf462088d13 82 print $failed_suites ? "FAILED" : "PASSED";
markrad 0:cdf462088d13 83 printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run;
markrad 0:cdf462088d13 84
markrad 0:cdf462088d13 85 if ( $verbose ) {
markrad 0:cdf462088d13 86 print " test cases passed :", $total_cases_passed, "\n";
markrad 0:cdf462088d13 87 print " failed :", $total_cases_failed, "\n";
markrad 0:cdf462088d13 88 print " skipped :", $total_cases_skipped, "\n";
markrad 0:cdf462088d13 89 print " of tests executed :", ( $total_cases_passed + $total_cases_failed ),
markrad 0:cdf462088d13 90 "\n";
markrad 0:cdf462088d13 91 print " of available tests :",
markrad 0:cdf462088d13 92 ( $total_cases_passed + $total_cases_failed + $total_cases_skipped ),
markrad 0:cdf462088d13 93 "\n"
markrad 0:cdf462088d13 94 }
markrad 0:cdf462088d13 95
markrad 0:cdf462088d13 96 exit( $failed_suites ? 1 : 0 );
markrad 0:cdf462088d13 97