TEST="${TEST} ghtests"
fi
+# Determine emulator to use when running tests
+if test -z "$EMU_RUN" && test $QEMU_ARCH; then
+ EMU_RUN="qemu-$QEMU_ARCH -L /usr/${CHOST}/"
+fi
+if test -n "$EMU_RUN"; then
+ echo "Using cross-compile emulator: $EMU_RUN"
+fi
+
# Generate Makefile in test dir
mkdir -p test
-if test $QEMU_ARCH; then QEMU_RUN="qemu-$QEMU_ARCH -L /usr/${CHOST}/"; fi
sed < $SRCDIR/test/Makefile.in "
/^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^alltests: */s#:.*#: $TEST#
/^SRCDIR *=/s#=.*#=$SRCDIR/test#
/^SRCTOP *=/s#=.*#=$SRCDIR#
-/^QEMU_RUN *=/s#=.*#=$QEMU_RUN#
+/^EMU_RUN *=/s#=.*#=$EMU_RUN#
/^LIBNAME *=/s#=.*#=$LIBNAME#
" > test/Makefile
LIBNAME=
TEST_LDFLAGS=-L.. ../$(LIBNAME).a
-QEMU_RUN=
-QEMU_VER:=$(shell command -v $(QEMU_RUN) --version 2> /dev/null)
+EMU_RUN=
all: alltests
alltests: #set by ../configure
check_cross_dep:
-ifneq (,$(QEMU_RUN))
+ifneq (,$(findstring qemu,$(EMU_RUN)))
+QEMU_VER:=$(shell command -v $(EMU_RUN) --version 2> /dev/null)
ifeq (,$(QEMU_VER))
- $(error "You need QEMU to run tests on non-native platform")
+ $(error You need QEMU to run tests on non-native platform)
endif
endif
teststatic: check_cross_dep
@TMPST=tmpst_$$$$; \
HELLOST=tmphellost_$$$$; \
- if echo hello world | ${QEMU_RUN} ../minigzip$(EXE) > $$HELLOST && ${QEMU_RUN} ../minigzip$(EXE) -d < $$HELLOST && ${QEMU_RUN} ../example$(EXE) $$TMPST; then \
+ if echo hello world | ${EMU_RUN} ../minigzip$(EXE) > $$HELLOST && ${EMU_RUN} ../minigzip$(EXE) -d < $$HELLOST && ${EMU_RUN} ../example$(EXE) $$TMPST; then \
echo ' *** zlib test OK ***'; \
else \
echo ' *** zlib test FAILED ***'; exit 1; \
SHLIB_PATH=`pwd`/..:$(SHLIB_PATH) ; export SHLIB_PATH; \
TMPSH=tmpsh_$$$$; \
HELLOSH=tmphellosh_$$$$; \
- if echo hello world | ${QEMU_RUN} ../minigzipsh$(EXE) > $$HELLOSH && ${QEMU_RUN} ../minigzipsh$(EXE) -d < $$HELLOSH && ${QEMU_RUN} ../examplesh$(EXE) $$TMPSH; then \
+ if echo hello world | ${EMU_RUN} ../minigzipsh$(EXE) > $$HELLOSH && ${EMU_RUN} ../minigzipsh$(EXE) -d < $$HELLOSH && ${EMU_RUN} ../examplesh$(EXE) $$TMPSH; then \
echo ' *** zlib shared test OK ***'; \
else \
echo ' *** zlib shared test FAILED ***'; exit 1; \
.PHONY: testGH-361
testGH-361:
- $(QEMU_RUN) ../minigzip$(EXE) -4 <$(SRCDIR)/GH-361/test.txt >/dev/null
+ $(EMU_RUN) ../minigzip$(EXE) -4 <$(SRCDIR)/GH-361/test.txt >/dev/null
switchlevels$(EXE): $(SRCDIR)/switchlevels.c
$(CC) $(CFLAGS) -I.. -I$(SRCTOP) -o $@ $< $(TEST_LDFLAGS)
.PHONY: testGH-364
testGH-364: switchlevels$(EXE)
- $(QEMU_RUN) ./switchlevels$(EXE) 1 5 9 3 <$(SRCDIR)/GH-364/test.bin >/dev/null
+ $(EMU_RUN) ./switchlevels$(EXE) 1 5 9 3 <$(SRCDIR)/GH-364/test.bin >/dev/null
.PHONY: testGH-751
testGH-751:
- $(QEMU_RUN) ../minigzip$(EXE) <$(SRCDIR)/GH-751/test.txt | $(QEMU_RUN) ../minigzip$(EXE) -d >/dev/null
+ $(EMU_RUN) ../minigzip$(EXE) <$(SRCDIR)/GH-751/test.txt | $(EMU_RUN) ../minigzip$(EXE) -d >/dev/null
gh1235$(EXE): $(SRCDIR)/gh1235.c
$(CC) $(CFLAGS) -I.. -I$(SRCTOP) -o $@ $< $(TEST_LDFLAGS)
.PHONY: testGH-1235
testGH-1235: gh1235$(EXE)
- $(QEMU_RUN) ./gh1235$(EXE)
+ $(EMU_RUN) ./gh1235$(EXE)
clean:
rm -f *.o *.gcda *.gcno *.gcov