tests/tcg: clean up calls to run-test

Almost all invocations of run-test have either "$* on $(TARGET_NAME)"
or "$< on $(TARGET_NAME)" as the last argument.  So provide a default
test name, while allowing an escape hatch for custom names.

As an additional simplification, remove the need to do shell quoting.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220929114231.583801-24-alex.bennee@linaro.org>
This commit is contained in:
Paolo Bonzini 2022-09-29 12:42:03 +01:00 committed by Alex Bennée
parent 37b0dba45c
commit c6cf8a2052
11 changed files with 34 additions and 43 deletions

View File

@ -41,14 +41,16 @@ endif
# for including , in command strings # for including , in command strings
COMMA := , COMMA := ,
quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) quiet-@ = $(if $(V),,@$(if $1,printf " %-7s %s\n" "$(strip $1)" "$(strip $2)" && ))
quiet-command = $(call quiet-@,$2,$3)$1
# $1 = test name, $2 = cmd, $3 = desc # $1 = test name, $2 = cmd, $3 = desc
ifeq ($(filter %-softmmu, $(TARGET)),) ifeq ($(filter %-softmmu, $(TARGET)),)
run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2 > $1.out, \ run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2 > $1.out, \
"TEST",$3) TEST,$(or $3, $*, $<) on $(TARGET_NAME))
else else
run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2,"TEST",$3) run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2, \
TEST,$(or $3, $*, $<) on $(TARGET_NAME))
endif endif
# $1 = test name, $2 = reference # $1 = test name, $2 = reference
@ -56,7 +58,7 @@ endif
# we know it failed and then force failure at the end. # we know it failed and then force failure at the end.
diff-out = $(call quiet-command, diff -q $1.out $2 || \ diff-out = $(call quiet-command, diff -q $1.out $2 || \
(diff -u $1.out $2 | head -n 10 && false), \ (diff -u $1.out $2 | head -n 10 && false), \
"DIFF","$1.out with $2") DIFF,$1.out with $2)
# $1 = test name, $2 = reason # $1 = test name, $2 = reason
skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2 skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2
@ -155,21 +157,19 @@ RUN_TESTS+=$(EXTRA_RUNS)
ifeq ($(filter %-softmmu, $(TARGET)),) ifeq ($(filter %-softmmu, $(TARGET)),)
run-%: % run-%: %
$(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<)
run-plugin-%: run-plugin-%:
$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
-d plugin -D $*.pout \ -d plugin -D $*.pout \
$(call strip-plugin,$<), \ $(call strip-plugin,$<))
"$* on $(TARGET_NAME)")
else else
run-%: % run-%: %
$(call run-test, $<, \ $(call run-test, $<, \
$(QEMU) -monitor none -display none \ $(QEMU) -monitor none -display none \
-chardev file$(COMMA)path=$<.out$(COMMA)id=output \ -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
$(QEMU_OPTS) $<, \ $(QEMU_OPTS) $<)
"$< on $(TARGET_NAME)")
run-plugin-%: run-plugin-%:
$(call run-test, $@, \ $(call run-test, $@, \
@ -177,8 +177,7 @@ run-plugin-%:
-chardev file$(COMMA)path=$@.out$(COMMA)id=output \ -chardev file$(COMMA)path=$@.out$(COMMA)id=output \
-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
-d plugin -D $*.pout \ -d plugin -D $*.pout \
$(QEMU_OPTS) $(call strip-plugin,$<), \ $(QEMU_OPTS) $(call strip-plugin,$<))
"$* on $(TARGET_NAME)")
endif endif
gdb-%: % gdb-%: %

View File

@ -50,8 +50,7 @@ run-memory-record: memory-record memory
$(QEMU) -monitor none -display none \ $(QEMU) -monitor none -display none \
-chardev file$(COMMA)path=$<.out$(COMMA)id=output \ -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
-icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \ -icount shift=5$(COMMA)rr=record$(COMMA)rrfile=record.bin \
$(QEMU_OPTS) memory, \ $(QEMU_OPTS) memory)
"$< on $(TARGET_NAME)")
.PHONY: memory-replay .PHONY: memory-replay
run-memory-replay: memory-replay run-memory-record run-memory-replay: memory-replay run-memory-record
@ -59,8 +58,7 @@ run-memory-replay: memory-replay run-memory-record
$(QEMU) -monitor none -display none \ $(QEMU) -monitor none -display none \
-chardev file$(COMMA)path=$<.out$(COMMA)id=output \ -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
-icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \ -icount shift=5$(COMMA)rr=replay$(COMMA)rrfile=record.bin \
$(QEMU_OPTS) memory, \ $(QEMU_OPTS) memory)
"$< on $(TARGET_NAME)")
EXTRA_RUNS+=run-memory-replay EXTRA_RUNS+=run-memory-replay

View File

@ -55,7 +55,7 @@ sha1-vector: CFLAGS=-O3
sha1-vector: sha1.c sha1-vector: sha1.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
run-sha1-vector: sha1-vector run-sha1 run-sha1-vector: sha1-vector run-sha1
$(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<)
$(call diff-out, sha1-vector, sha1.out) $(call diff-out, sha1-vector, sha1.out)
TESTS += sha1-vector TESTS += sha1-vector
@ -75,14 +75,14 @@ run-gdbstub-sysregs: sysregs
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve.py, \
"basic gdbstub SVE support") basic gdbstub SVE support)
run-gdbstub-sve-ioctls: sve-ioctls run-gdbstub-sve-ioctls: sve-ioctls
$(call run-test, $@, $(GDB_SCRIPT) \ $(call run-test, $@, $(GDB_SCRIPT) \
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \
"basic gdbstub SVE ZLEN support") basic gdbstub SVE ZLEN support)
EXTRA_RUNS += run-gdbstub-sysregs run-gdbstub-sve-ioctls EXTRA_RUNS += run-gdbstub-sysregs run-gdbstub-sve-ioctls
endif endif

View File

@ -26,7 +26,7 @@ ARM_TESTS += fcvt
fcvt: LDFLAGS+=-lm fcvt: LDFLAGS+=-lm
# fcvt: CFLAGS+=-march=armv8.2-a+fp16 -mfpu=neon-fp-armv8 # fcvt: CFLAGS+=-march=armv8.2-a+fp16 -mfpu=neon-fp-armv8
run-fcvt: fcvt run-fcvt: fcvt
$(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") $(call run-test,fcvt,$(QEMU) $<)
$(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref)
# PC alignment test # PC alignment test
@ -44,13 +44,12 @@ semihosting-arm: semihosting.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
run-semihosting-arm: semihosting-arm run-semihosting-arm: semihosting-arm
$(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") $(call run-test,$<,$(QEMU) $< 2> $<.err)
run-plugin-semihosting-arm-with-%: run-plugin-semihosting-arm-with-%:
$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
$(call strip-plugin,$<) 2> $<.err, \ $(call strip-plugin,$<) 2> $<.err)
"$< on $(TARGET_NAME) with $*")
ARM_TESTS += semiconsole-arm ARM_TESTS += semiconsole-arm
@ -75,7 +74,7 @@ sha1-vector: CFLAGS=-O3
sha1-vector: sha1.c sha1-vector: sha1.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
run-sha1-vector: sha1-vector run-sha1 run-sha1-vector: sha1-vector run-sha1
$(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<)
$(call diff-out, sha1-vector, sha1.out) $(call diff-out, sha1-vector, sha1.out)
ARM_TESTS += sha1-vector ARM_TESTS += sha1-vector

View File

@ -56,4 +56,4 @@ SIMG:=cris-axis-linux-gnu-run
# e.g.: make -f ../../tests/tcg/Makefile run-check_orm-on-sim # e.g.: make -f ../../tests/tcg/Makefile run-check_orm-on-sim
run-%-on-sim: run-%-on-sim:
$(call run-test, $<, $(SIMG) $<, "$< on $(TARGET_NAME) with SIM") $(call run-test, $<, $(SIMG) $<)

View File

@ -40,8 +40,7 @@ run-plugin-%-with-libinsn.so:
-chardev file$(COMMA)path=$@.out$(COMMA)id=output \ -chardev file$(COMMA)path=$@.out$(COMMA)id=output \
-plugin ../../plugin/libinsn.so$(COMMA)inline=on \ -plugin ../../plugin/libinsn.so$(COMMA)inline=on \
-d plugin -D $*-with-libinsn.so.pout \ -d plugin -D $*-with-libinsn.so.pout \
$(QEMU_OPTS) $*, \ $(QEMU_OPTS) $*)
"$* on $(TARGET_NAME)")
# Running # Running
QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel

View File

@ -53,7 +53,7 @@ test-i386-fprem.ref: test-i386-fprem
run-test-i386-fprem: TIMEOUT=60 run-test-i386-fprem: TIMEOUT=60
run-test-i386-fprem: test-i386-fprem test-i386-fprem.ref run-test-i386-fprem: test-i386-fprem test-i386-fprem.ref
$(call run-test,test-i386-fprem, $(QEMU) $<,"$< on $(TARGET_NAME)") $(call run-test,test-i386-fprem, $(QEMU) $<)
$(call diff-out,test-i386-fprem, test-i386-fprem.ref) $(call diff-out,test-i386-fprem, test-i386-fprem.ref)
else else
SKIP_I386_TESTS+=test-i386-fprem SKIP_I386_TESTS+=test-i386-fprem
@ -63,8 +63,7 @@ endif
run-plugin-%-with-libinsn.so: run-plugin-%-with-libinsn.so:
$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-plugin ../../plugin/libinsn.so$(COMMA)inline=on \ -plugin ../../plugin/libinsn.so$(COMMA)inline=on \
-d plugin -D $*-with-libinsn.so.pout $*, \ -d plugin -D $*-with-libinsn.so.pout $*)
"$* (inline) on $(TARGET_NAME)")
# Update TESTS # Update TESTS
I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) I386_TESTS:=$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS))

View File

@ -26,7 +26,7 @@ float_%: float_%.c libs/float_helpers.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< $(MULTIARCH_SRC)/libs/float_helpers.c -o $@ $(LDFLAGS) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< $(MULTIARCH_SRC)/libs/float_helpers.c -o $@ $(LDFLAGS)
run-float_%: float_% run-float_%: float_%
$(call run-test,$<, $(QEMU) $(QEMU_OPTS) $<,"$< on $(TARGET_NAME)") $(call run-test,$<, $(QEMU) $(QEMU_OPTS) $<)
$(call conditional-diff-out,$<,$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/$<.ref) $(call conditional-diff-out,$<,$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/$<.ref)
@ -42,13 +42,11 @@ signals: LDFLAGS+=-lrt -lpthread
# default case (host page size) # default case (host page size)
run-test-mmap: test-mmap run-test-mmap: test-mmap
$(call run-test, test-mmap, $(QEMU) $<, \ $(call run-test, test-mmap, $(QEMU) $<, $< (default))
"$< (default) on $(TARGET_NAME)")
# additional page sizes (defined by each architecture adding to EXTRA_RUNS) # additional page sizes (defined by each architecture adding to EXTRA_RUNS)
run-test-mmap-%: test-mmap run-test-mmap-%: test-mmap
$(call run-test, test-mmap-$*, $(QEMU) -p $* $<,\ $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages))
"$< ($* byte pages) on $(TARGET_NAME)")
ifneq ($(HAVE_GDB_BIN),) ifneq ($(HAVE_GDB_BIN),)
GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
@ -58,21 +56,21 @@ run-gdbstub-sha1: sha1
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
"basic gdbstub support") basic gdbstub support)
run-gdbstub-qxfer-auxv-read: sha1 run-gdbstub-qxfer-auxv-read: sha1
$(call run-test, $@, $(GDB_SCRIPT) \ $(call run-test, $@, $(GDB_SCRIPT) \
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
"basic gdbstub qXfer:auxv:read support") basic gdbstub qXfer:auxv:read support)
run-gdbstub-thread-breakpoint: testthread run-gdbstub-thread-breakpoint: testthread
$(call run-test, $@, $(GDB_SCRIPT) \ $(call run-test, $@, $(GDB_SCRIPT) \
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \
"hitting a breakpoint on non-main thread") hitting a breakpoint on non-main thread)
else else
run-gdbstub-%: run-gdbstub-%:
@ -94,13 +92,13 @@ VPATH += $(MULTIARCH_SRC)/arm-compat-semi
semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
run-semihosting: semihosting run-semihosting: semihosting
$(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") $(call run-test,$<,$(QEMU) $< 2> $<.err)
run-plugin-semihosting-with-%: run-plugin-semihosting-with-%:
$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
$(call strip-plugin,$<) 2> $<.err, \ $(call strip-plugin,$<) 2> $<.err, \
"$< on $(TARGET_NAME) with $*") $< with $*)
semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME) semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)

View File

@ -25,7 +25,7 @@ run-gdbstub-memory: memory
--qargs \ --qargs \
"-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \
--bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \
"softmmu gdbstub support") softmmu gdbstub support)
else else
run-gdbstub-%: run-gdbstub-%:

View File

@ -41,7 +41,7 @@ run-gdbstub-signals-s390x: signals-s390x
--gdb $(HAVE_GDB_BIN) \ --gdb $(HAVE_GDB_BIN) \
--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
--bin $< --test $(S390X_SRC)/gdbstub/test-signals-s390x.py, \ --bin $< --test $(S390X_SRC)/gdbstub/test-signals-s390x.py, \
"mixing signals and debugging on s390x") mixing signals and debugging)
EXTRA_RUNS += run-gdbstub-signals-s390x EXTRA_RUNS += run-gdbstub-signals-s390x
endif endif

View File

@ -40,8 +40,7 @@ run-plugin-%-with-libinsn.so:
-chardev file$(COMMA)path=$@.out$(COMMA)id=output \ -chardev file$(COMMA)path=$@.out$(COMMA)id=output \
-plugin ../../plugin/libinsn.so$(COMMA)inline=on \ -plugin ../../plugin/libinsn.so$(COMMA)inline=on \
-d plugin -D $*-with-libinsn.so.pout \ -d plugin -D $*-with-libinsn.so.pout \
$(QEMU_OPTS) $*, \ $(QEMU_OPTS) $*)
"$* on $(TARGET_NAME)")
# Running # Running
QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel