Skip to content

Commit 73abe93

Browse files
author
H. Peter Anvin (Intel)
committed
travis: run from a Makefile to parallelize testing
The travis tool itself runs all tests it is given in series. Use make to parallelize running the tests, leaving a log in each subdirectory in addition to the global log. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
1 parent 7f69cf6 commit 73abe93

5 files changed

Lines changed: 105 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ TAGS
100100
/test/testresults
101101
/test/ffmpegtest
102102
/test/x264test
103+
/travis.mk
103104
/version.h
104105
/version.mac
105106
/version.mak

Makefile.in

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,14 @@ golden: $(PROGS)
574574
#
575575
# Travis tests
576576
#
577-
travis_version = travis/_version/_version.stdout
577+
travis: $(PROGS)
578+
$(MAKE) -f travis.mk all
578579

579-
$(travis_version): version
580-
printf 'NASM version %s compiled on ?\n' `cat version` > $@
580+
clean-travis travis-clean:
581+
$(MAKE) -f travis.mk clean
581582

582-
travis: $(PROGS) $(travis_version)
583-
-$(PYTHON3) tools/travis/nasm-t.py run --stop=n > travis.log
584-
@if $(GREP) FAIL travis.log; then exit 1; else \
585-
echo '=== All tests PASS ==='; fi
583+
update-travis travis-update:
584+
$(MAKE) -f travis.mk update
586585

587586
#
588587
# Rules to run autogen if necessary

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,5 @@ dnl
371371
PA_CHECK_BAD_STDC_INLINE
372372
PA_C_TYPEOF
373373

374-
AC_CONFIG_FILES([Makefile doc/Makefile misc/Makefile test/Makefile])
374+
AC_CONFIG_FILES([Makefile doc/Makefile misc/Makefile test/Makefile travis.mk])
375375
AC_OUTPUT

tools/travis/findtests.pl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use integer;
5+
use File::Find;
6+
use File::Spec;
7+
8+
my($srcdir,$objdir,$subdir) = @ARGV;
9+
10+
my $base = File::Spec->catdir($srcdir, $subdir);
11+
12+
sub print_dir {
13+
return if (! -d $_);
14+
my($vol,$dirs) = File::Spec->splitpath($_, 1);
15+
my @dirs = File::Spec->splitdir($dirs);
16+
17+
# $objdir really should be part of catfile, but that breaks our
18+
# current "golden reference" files -- fix that at some point.
19+
my $json = File::Spec->catfile(@dirs, $dirs[-1].'.json');
20+
if ( -f $json ) {
21+
print File::Spec->catfile($objdir, File::Spec->abs2rel($json, $srcdir)), "\n";
22+
}
23+
}
24+
find({no_chdir => 1, wanted => \&print_dir}, $base);

travis.mk.in

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# -*- makefile -*-
2+
# SPDX-License-Identifier: BSD-2-Clause
3+
#
4+
# Makefile wrapper to parallelize running travis
5+
#
6+
# Run from the main Makefile with "make travis"
7+
# This Makefile, unlike the main one, assumes GNU make or equivalent
8+
#
9+
10+
srcdir = @srcdir@
11+
objdir = @builddir@
12+
VPATH = @srcdir@
13+
14+
PYTHON3 = @PYTHON3@
15+
GREP = grep
16+
17+
tools = $(srcdir)/tools
18+
19+
PERL = perl
20+
PERLFLAGS = -I$(srcdir)/perllib
21+
RUNPERL = $(PERL) $(PERLFLAGS)
22+
23+
NASM = $(objdir)/nasm$(X)
24+
25+
PERL = perl
26+
RUNPERL = $(PERL)
27+
28+
PYTHON3 = @PYTHON3@
29+
GREP = grep
30+
31+
travistools = $(tools)/travis
32+
TRAVIS = $(travistools)/nasm-t.py
33+
testdir = travis
34+
35+
tests := $(shell $(RUNPERL) $(travistools)/findtests.pl $(srcdir) $(objdir) $(testdir))
36+
logs = $(tests:.json=.log)
37+
38+
all: travis.log
39+
@ ! $(GREP) FAIL travis.log && echo '=== All tests PASS ==='
40+
41+
.PRECIOUS: travis.log
42+
travis.log: $(logs)
43+
@cat $(logs) > travis.log
44+
45+
.PRECIOUS: %.log
46+
%.log: $(NASM) %.json
47+
@echo 'Running: $(@D)'
48+
@$(PYTHON3) $(TRAVIS) -d $(srcdir)/$(@D) \
49+
--nasm $(NASM) run --stop=n > $@
50+
51+
.PHONY: update
52+
update: $(tests:.json=.update)
53+
54+
.PHONY: %.update
55+
%.update:
56+
@echo 'Updating: $(@D)'
57+
@$(PYTHON3) $(TRAVIS) -d $(srcdir)/$(@D) --nasm $(NASM) update
58+
59+
#
60+
# Generated files needed for some specific tests
61+
# (If this ends up being a longer list, consider making subdirectory-
62+
# specific Makefiles).
63+
#
64+
GENFILES = $(testdir)/_version/_version.stdout
65+
66+
$(testdir)/_version/_version.stdout: version
67+
printf 'NASM version %s compiled on ?\n' `cat version` > $@
68+
69+
$(testdir)/_version/_version.log: $(testdir)/_version/_version.stdout
70+
71+
# XXX: need to clean up build artifacts, too
72+
clean:
73+
rm -f travis.log $(logs)

0 commit comments

Comments
 (0)