[build-path-prefix-map-spec] 28/50: Move most of the test code into a separate shell script
Ximin Luo
infinity0 at debian.org
Fri Mar 10 15:17:21 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository build-path-prefix-map-spec.
commit 7547b46cec1a0368a3b202909ebaa0439f7a1e79
Author: Ximin Luo <infinity0 at debian.org>
Date: Mon Feb 13 17:08:49 2017 +0100
Move most of the test code into a separate shell script
---
consume/Makefile | 40 ++++++----------------------------------
consume/check-generic.sh | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/consume/Makefile b/consume/Makefile
index a313ca4..b63eeb1 100644
--- a/consume/Makefile
+++ b/consume/Makefile
@@ -16,6 +16,7 @@ AFL_MEMLIM = none
CC ?= cc
RUSTC ?= rustc
+# Args:
# 1 key, e.g. "0" or "pecsplit.0"
# 2 suffix that indicates a test, e.g. "in" or "env"
find_testcases = \
@@ -37,43 +38,14 @@ all: $(ALL_SOURCE:%=%.out)
.PHONY: check
check: $(ALL_FORMATS:%=check-%)
-# 1 progname
-# 2 format
-# 3 expected exit code
-# 4 prefix for .in, .out
-# 5 prefix for .env
-# 6 prefix for .in, .out if $(4) doesn't exist
-check-generic = \
- for i in $(1); do \
- if test -f "$(T)$(4).in.ignore-$$i"; then \
- set +x; \
- printf >&2 "\033[1;31m================================================================\033[0m\n"; \
- printf >&2 "\033[1;31mvvvv IGNORING $$i for $(4).in because: vvvv\033[0m\n"; \
- cat >&2 "$(T)$(4).in.ignore-$$i"; \
- printf >&2 "\033[1;31m^^^^ IGNORING $$i for $(4).in because: ^^^^\033[0m\n"; \
- printf >&2 "\033[1;31m================================================================\033[0m\n"; \
- set -x; \
- continue; \
- fi; \
- if [ -f "$(T)$(4).in" ]; then input="$(T)$(4).in"; else input="$(T)$(6).in"; fi; \
- if [ -f "$(T)$(4).out" ]; then output="$(T)$(4).out"; else output="$(T)$(6).out"; fi; \
- set -x; \
- ./$$i $$(cat "$$input") | diff -ru - "$$input" || exit 1; \
- tmpout="$(T)$(5).env.tmpout"; \
- BUILD_PATH_PREFIX_MAP="$$(cat $(T)$(5).env)" \
- ./$$i $$(cat "$$input") > "$$tmpout"; \
- test $$? = $(3) && diff -ru "$$tmpout" "$$output" && \
- rm -f "$$tmpout" || { rm -f "$$tmpout"; exit 1; }; \
- set +x 2>/dev/null; \
- done;
-
+export TESTDIR = $(T)
.PHONY: check-%
check-%:
$(MAKE) $(ALLCHECK_$*)
- $(foreach case,$(TESTCASES_0),$(call check-generic,$(ALLCHECK_$*),$*,0,$(case),$(case).$*,$(case)))
- $(foreach case,$(TESTCASES_1),$(call check-generic,$(ALLCHECK_$*),$*,1,$(case),$(case).$*,$(case)))
- $(foreach case,$(TESTCASES_$*.0),$(call check-generic,$(ALLCHECK_$*),$*,0,$(case),$(case),$*.0))
- $(foreach case,$(TESTCASES_$*.1),$(call check-generic,$(ALLCHECK_$*),$*,1,$(case),$(case),$*.1))
+ for case in $(TESTCASES_0); do ./check-generic.sh "$(ALLCHECK_$*)" $* 0 $$case $$case.$* $$case; done
+ for case in $(TESTCASES_1); do ./check-generic.sh "$(ALLCHECK_$*)" $* 1 $$case $$case.$* $$case; done
+ for case in $(TESTCASES_$*.0); do ./check-generic.sh "$(ALLCHECK_$*)" $* 0 $$case $$case $*.0; done
+ for case in $(TESTCASES_$*.1); do ./check-generic.sh "$(ALLCHECK_$*)" $* 1 $$case $$case $*.1; done
make-afl-test-case = \
cat testcases/$(3).$(1).env testcases/$(3).in > afl-in-$(1)/$(3).in;
diff --git a/consume/check-generic.sh b/consume/check-generic.sh
new file mode 100755
index 0000000..3855dac
--- /dev/null
+++ b/consume/check-generic.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# Args:
+# 1 programs to run, whitespace-separated
+# 2 format name
+# 3 expected exit code
+# 4 prefix for .in, .out
+# 5 prefix for .env
+# 6 prefix for .in, .out if $4 doesn't exist
+
+T="$TESTDIR"
+
+for i in $1; do
+ if test -f "${T}${4}.in.ignore-$i"; then
+ set +x
+ printf >&2 "\033[1;31m================================================================\033[0m\n"
+ printf >&2 "\033[1;31mvvvv IGNORING $i for ${4}.in because: vvvv\033[0m\n"
+ cat >&2 "${T}${4}.in.ignore-$i"
+ printf >&2 "\033[1;31m^^^^ IGNORING $i for ${4}.in because: ^^^^\033[0m\n"
+ printf >&2 "\033[1;31m================================================================\033[0m\n"
+ set -x
+ continue
+ fi
+ if [ -f "${T}${4}.in" ]; then input="${T}${4}.in"; else input="${T}${6}.in"; fi
+ if [ -f "${T}${4}.out" ]; then output="${T}${4}.out"; else output="${T}${6}.out"; fi
+
+ set -x
+ ./$i $(cat "$input") | diff -ru - "$input" || exit 1
+ tmpout="${T}${5}.env.tmpout"
+
+ BUILD_PATH_PREFIX_MAP="$(cat ${T}${5}.env)" \
+ ./$i $(cat "$input") > "$tmpout"
+ test $? = "${3}" && diff -ru "$tmpout" "$output" && \
+ rm -f "$tmpout" || { rm -f "$tmpout"; exit 1; }
+ set +x 2>/dev/null
+done;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/build-path-prefix-map-spec.git
More information about the Reproducible-commits
mailing list