From 85113848bd043e637c84125e3ea973b5e19dbba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 8 Jul 2015 21:20:03 +0100 Subject: [PATCH] Use Perl to run tests suites with make - works on Windows too! - we need Perl to generate/build the test suites anyway - easier & more flexible (eg, now count total number of tests run) --- Makefile | 2 +- tests/Makefile | 19 +---------------- tests/scripts/run-test-suites.pl | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 tests/scripts/run-test-suites.pl diff --git a/Makefile b/Makefile index c5720c784..2f05e1273 100644 --- a/Makefile +++ b/Makefile @@ -59,12 +59,12 @@ ifndef WINDOWS find . \( -name \*.gcno -o -name \*.gcda -o -name *.info \) -exec rm {} + endif -ifndef WINDOWS check: lib $(MAKE) -C tests check test: check +ifndef WINDOWS # note: for coverage testing, build with: # make CFLAGS='--coverage -g3 -O0' covtest: diff --git a/tests/Makefile b/tests/Makefile index a741730ed..d1f982995 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -431,24 +431,7 @@ else del /Q /F *.c *.exe endif -ifndef WINDOWS check: $(APPS) - echo "Running checks (Success if all tests PASSED)" - RETURN=0; \ - for i in $(APPS); \ - do \ - echo " - $${i}"; \ - RESULT=`LD_LIBRARY_PATH=../library ./$${i} | grep -v 'PASS$$' | grep -v -- '----' | grep -v '^$$'`; \ - PASSED=`echo $$RESULT |grep PASSED`; \ - echo " $$RESULT"; \ - if [ "x$$PASSED" = "x" ]; \ - then \ - echo "**** Failed ***************"; \ - RETURN=1; \ - fi; \ - echo ""; \ - done; \ - if [ "$$RETURN" -eq 1 ]; then exit 1; fi + perl scripts/run-test-suites.pl test: check -endif diff --git a/tests/scripts/run-test-suites.pl b/tests/scripts/run-test-suites.pl new file mode 100644 index 000000000..e8611f4f1 --- /dev/null +++ b/tests/scripts/run-test-suites.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use utf8; +use open qw(:std utf8); + +my @suites = grep { ! /\.c$/ } glob 'test_suite_*'; +die "$0: no test suite found\n" unless @suites; + +# in case test suites are linked dynamically +$ENV{'LD_LIBRARY_PATH'} = '../library'; + +my $prefix = $^O eq "MSWin32" ? '' : './'; + +my ($failed_suites, $total_tests_run); +for my $suite (@suites) +{ + print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " "; + my $result = `$prefix$suite`; + if( $result =~ /PASSED/ ) { + print "PASS\n"; + } else { + $failed_suites++; + print "FAIL\n"; + } + my ($tests, $skipped) = $result =~ /([0-9]*) tests.*?([0-9]*) skipped/; + $total_tests_run += $tests - $skipped; +} + +print "-" x 72, "\n"; +print $failed_suites ? "FAILED" : "PASSED"; +printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run; +exit( $failed_suites ? 1 : 0 );