diff --git a/.gitignore b/.gitignore index 592ae0892..edc86da57 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,7 @@ TAGS /test/testresults /test/ffmpegtest /test/x264test +/travis.mk /version.h /version.mac /version.mak diff --git a/Makefile.in b/Makefile.in index 04e0193ed..c1746efd4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -574,15 +574,14 @@ golden: $(PROGS) # # Travis tests # -travis_version = travis/_version/_version.stdout +travis: $(PROGS) + $(MAKE) -f travis.mk all -$(travis_version): version - printf 'NASM version %s compiled on ?\n' `cat version` > $@ +clean-travis travis-clean: + $(MAKE) -f travis.mk clean -travis: $(PROGS) $(travis_version) - -$(PYTHON3) tools/travis/nasm-t.py run --stop=n > travis.log - @if $(GREP) FAIL travis.log; then exit 1; else \ - echo '=== All tests PASS ==='; fi +update-travis travis-update: + $(MAKE) -f travis.mk update # # Rules to run autogen if necessary diff --git a/configure.ac b/configure.ac index 9a584a727..560d83657 100644 --- a/configure.ac +++ b/configure.ac @@ -371,5 +371,5 @@ dnl PA_CHECK_BAD_STDC_INLINE PA_C_TYPEOF -AC_CONFIG_FILES([Makefile doc/Makefile misc/Makefile test/Makefile]) +AC_CONFIG_FILES([Makefile doc/Makefile misc/Makefile test/Makefile travis.mk]) AC_OUTPUT diff --git a/tools/travis/findtests.pl b/tools/travis/findtests.pl new file mode 100755 index 000000000..3ab783497 --- /dev/null +++ b/tools/travis/findtests.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use strict; +use integer; +use File::Find; +use File::Spec; + +my($srcdir,$objdir,$subdir) = @ARGV; + +my $base = File::Spec->catdir($srcdir, $subdir); + +sub print_dir { + return if (! -d $_); + my($vol,$dirs) = File::Spec->splitpath($_, 1); + my @dirs = File::Spec->splitdir($dirs); + + # $objdir really should be part of catfile, but that breaks our + # current "golden reference" files -- fix that at some point. + my $json = File::Spec->catfile(@dirs, $dirs[-1].'.json'); + if ( -f $json ) { + print File::Spec->catfile($objdir, File::Spec->abs2rel($json, $srcdir)), "\n"; + } +} +find({no_chdir => 1, wanted => \&print_dir}, $base); diff --git a/travis.mk.in b/travis.mk.in new file mode 100644 index 000000000..6924bb30d --- /dev/null +++ b/travis.mk.in @@ -0,0 +1,73 @@ +# -*- makefile -*- +# SPDX-License-Identifier: BSD-2-Clause +# +# Makefile wrapper to parallelize running travis +# +# Run from the main Makefile with "make travis" +# This Makefile, unlike the main one, assumes GNU make or equivalent +# + +srcdir = @srcdir@ +objdir = @builddir@ +VPATH = @srcdir@ + +PYTHON3 = @PYTHON3@ +GREP = grep + +tools = $(srcdir)/tools + +PERL = perl +PERLFLAGS = -I$(srcdir)/perllib +RUNPERL = $(PERL) $(PERLFLAGS) + +NASM = $(objdir)/nasm$(X) + +PERL = perl +RUNPERL = $(PERL) + +PYTHON3 = @PYTHON3@ +GREP = grep + +travistools = $(tools)/travis +TRAVIS = $(travistools)/nasm-t.py +testdir = travis + +tests := $(shell $(RUNPERL) $(travistools)/findtests.pl $(srcdir) $(objdir) $(testdir)) +logs = $(tests:.json=.log) + +all: travis.log + @ ! $(GREP) FAIL travis.log && echo '=== All tests PASS ===' + +.PRECIOUS: travis.log +travis.log: $(logs) + @cat $(logs) > travis.log + +.PRECIOUS: %.log +%.log: $(NASM) %.json + @echo 'Running: $(@D)' + @$(PYTHON3) $(TRAVIS) -d $(srcdir)/$(@D) \ + --nasm $(NASM) run --stop=n > $@ + +.PHONY: update +update: $(tests:.json=.update) + +.PHONY: %.update +%.update: + @echo 'Updating: $(@D)' + @$(PYTHON3) $(TRAVIS) -d $(srcdir)/$(@D) --nasm $(NASM) update + +# +# Generated files needed for some specific tests +# (If this ends up being a longer list, consider making subdirectory- +# specific Makefiles). +# +GENFILES = $(testdir)/_version/_version.stdout + +$(testdir)/_version/_version.stdout: version + printf 'NASM version %s compiled on ?\n' `cat version` > $@ + +$(testdir)/_version/_version.log: $(testdir)/_version/_version.stdout + +# XXX: need to clean up build artifacts, too +clean: + rm -f travis.log $(logs)