2010-06-15 15:14:18 +00:00
|
|
|
-include conf.mk
|
2010-06-15 13:30:12 +00:00
|
|
|
|
|
|
|
repos := repo1 repo2
|
|
|
|
|
|
|
|
tmproot := /tmp/apk-test
|
|
|
|
testroot = $(tmproot)/$(basename $@)
|
|
|
|
|
|
|
|
SUDO := sudo
|
|
|
|
APK := ../src/apk --keys-dir /etc/apk/keys
|
2010-06-15 15:14:18 +00:00
|
|
|
|
2017-06-09 23:42:01 +00:00
|
|
|
SYSREPO ?= http://nl.alpinelinux.org/alpine/edge/main
|
2010-06-15 13:30:12 +00:00
|
|
|
|
2017-06-10 21:33:54 +00:00
|
|
|
# Absolute path to QEMU user-mode emulation binary to be copied into every
|
|
|
|
# $testroot before running test. This is used when running root-tests in
|
|
|
|
# emulation using QEMU and binfmt (apk --root uses chroot to run pre/post
|
|
|
|
# install scripts).
|
|
|
|
QEMU_EMULATOR ?=
|
|
|
|
|
2010-06-15 13:30:12 +00:00
|
|
|
LD_LIBRARY_PATH = ../src
|
|
|
|
export LD_LIBRARY_PATH SYSREPO
|
|
|
|
|
2011-07-26 13:56:55 +00:00
|
|
|
all: tests
|
2010-06-15 13:30:12 +00:00
|
|
|
|
|
|
|
$(repos):
|
|
|
|
@echo "Building $@"
|
|
|
|
@rm -f repos.out
|
|
|
|
@cd $@ &&\
|
2017-06-10 11:01:47 +00:00
|
|
|
for i in */APKBUILD; do \
|
|
|
|
( cd $${i%/*} && REPODEST="$$PWD/../.." abuild -R ) \
|
|
|
|
>> ../repos.out 2>&1 || { cat ../repos.out >&2; exit 1; } \
|
2010-06-15 13:30:12 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(SUDO) rm -rf $(addsuffix /*.apk,$(repos)) $(tmproot) *.ok *.out *.stamp
|
|
|
|
|
|
|
|
|
|
|
|
repos: repos.stamp
|
|
|
|
|
|
|
|
repos.stamp: $(repos)
|
|
|
|
@touch $@
|
|
|
|
|
|
|
|
|
|
|
|
%.ok: %.sh
|
|
|
|
@echo -n "$<"; \
|
|
|
|
rm -rf "$(testroot)" ;\
|
|
|
|
mkdir -p "$(testroot)"; \
|
2017-06-10 21:33:54 +00:00
|
|
|
if [ -n "$(QEMU_EMULATOR)" ]; then \
|
|
|
|
$(SUDO) install -Dm755 "$(QEMU_EMULATOR)" "$(testroot)$(QEMU_EMULATOR)"; \
|
|
|
|
fi; \
|
2017-06-10 13:57:45 +00:00
|
|
|
if ! APK="$(APK)" ROOT="$(testroot)" SYSREPO="$(SYSREPO)" sh -ex ./$< > $(basename $@).out 2>&1; then\
|
2010-06-15 13:30:12 +00:00
|
|
|
echo " FAIL";\
|
2021-08-07 12:33:23 +00:00
|
|
|
printf '%s\n' "------------- output -------------" >&2;\
|
2017-06-10 11:01:47 +00:00
|
|
|
cat $(basename $@).out >&2;\
|
2021-08-07 12:33:23 +00:00
|
|
|
printf '%s\n' "----------------------------------" >&2;\
|
2010-06-15 13:30:12 +00:00
|
|
|
exit 1;\
|
|
|
|
fi ;\
|
|
|
|
echo " OK" ;\
|
|
|
|
$(SUDO) rm -rf $(testroot); \
|
|
|
|
touch $@
|
|
|
|
|
2011-07-26 13:56:55 +00:00
|
|
|
root-tests: repos.stamp
|
|
|
|
@echo "== Testing `$(APK) --version` (tests that require root permission) =="
|
2017-06-10 12:57:47 +00:00
|
|
|
@failed=0; for i in test*.sh; do \
|
2010-06-15 13:30:12 +00:00
|
|
|
rm -f $${i%.sh}.ok ;\
|
2017-06-10 21:33:54 +00:00
|
|
|
$(SUDO) $(MAKE) --no-print-directory $${i%.sh}.ok \
|
|
|
|
SYSREPO=$(SYSREPO) \
|
|
|
|
QEMU_EMULATOR=$(QEMU_EMULATOR) || failed=1; \
|
2017-06-10 12:57:47 +00:00
|
|
|
done; \
|
|
|
|
return $$failed
|
2010-06-15 13:30:12 +00:00
|
|
|
|
2011-07-26 13:56:55 +00:00
|
|
|
tests:
|
|
|
|
@echo "== Testing `$(APK) --version` =="
|
|
|
|
@for i in $(sort $(filter-out test%.sh,$(wildcard *.sh))); do \
|
|
|
|
./$$i || exit 1 ; \
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: $(repos) tests
|