rpm-ostree/Makefile-tests.am
Jonathan Lebon 5479ed5240 tests: refactor rpm building and add package foo
We're going to be create many different packages in the future. Let's
refactor and generalize the targets so that they can build anything.

We also add a package foo, which will be used soon for a basic test of
package layering.

Closes: #344
Approved by: cgwalters
2016-06-23 00:05:09 +00:00

113 lines
3.4 KiB
Plaintext

include $(top_srcdir)/buildutil/glib-tap.mk
AM_TESTS_ENVIRONMENT = \
UNINSTALLEDTESTS=1 \
builddir=$(abs_builddir) \
topsrcdir=$(abs_top_srcdir) \
commondir=$(abs_top_srcdir)/tests/common
CLEANFILES += \
tests/common/compose/yum/repodata/repomd.xml \
tests/common/compose/test-repo.repo \
tests/common/compose/yum/repodata/*.bz2 \
tests/common/compose/yum/repodata/*.gz \
$(NULL)
testpackages = \
tests/common/compose/yum/x86_64/empty-1.0-1.x86_64.rpm \
tests/common/compose/yum/x86_64/foo-1.0-1.x86_64.rpm \
$(NULL)
# Create a rule for each testpkg with their respective spec file as dep.
# The static pattern feature is almost a fit for this, but does not allow string
# substitutions and wildcards in the patterns to allow rpm-filename -->
# spec-filename without also encoding the arch, release, and rev.
define testpkgbuild_template =
$(1): tests/common/compose/yum/$(2).spec
(cd tests/common/compose/yum && \
rm -rf .build && \
rpmbuild -ba $$$$(basename $$<) \
--define "_sourcedir $$$$PWD" \
--define "_specdir $$$$PWD" \
--define "_builddir $$$$PWD/.build" \
--define "_srcrpmdir $$$$PWD" \
--define "_rpmdir $$$$PWD" \
--define "_buildrootdir $$$$PWD" && \
rm -rf .build && \
rm -f *.src.rpm)
endef
$(foreach pkg,$(testpackages),$(eval $(call testpkgbuild_template,$(pkg),$(shell basename $(pkg) | cut -d- -f1))))
tests/common/compose/yum/repodata/repomd.xml: $(testpackages)
(cd tests/common/compose/yum && \
createrepo_c --no-database $$PWD)
tests/common/compose/test-repo.repo: tests/common/compose/test-repo.repo.in tests/common/compose/yum/repodata/repomd.xml
cat $< | sed -e "s|%WHERE%|$(abs_top_srcdir)|" > $@
CLEANFILES += \
tests/common/compose/test-repo-local.repo \
$(NULL)
tests_check_jsonutil_CPPFLAGS = -I $(srcdir)/src/libpriv
tests_check_jsonutil_CFLAGS = $(PKGDEP_RPMOSTREE_CFLAGS)
tests_check_jsonutil_LDADD = $(PKGDEP_RPMOSTREE_LIBS) librpmostreepriv.la
tests/check/test-compose.sh: tests/common/compose/test-repo.repo
tests/check/test-ucontainer.sh: tests/common/compose/test-repo.repo
uninstalled_test_programs = \
tests/check/jsonutil \
$(NULL)
uninstalled_test_scripts = \
tests/check/test-basic.sh \
tests/check/test-compose.sh \
tests/check/test-ucontainer.sh \
$(NULL)
uninstalled_test_extra_programs = dbus-run-session
dbus_run_session_SOURCES = tests/utils/dbus-run-session.c
check-local:
@echo " *** NOTE ***"
@echo " *** NOTE ***"
@echo " \"make check\" only runs a subset of rpm-ostree's tests."
@echo " Use \"make vmcheck\" to run remaining tests in a VM."
@echo " *** NOTE ***"
@echo " *** NOTE ***"
vmbuild:
@if [ -z "$(SKIP_VMBUILD)" ]; then \
vagrant up && \
vagrant rsync && \
vagrant ssh -c "cd sync/vagrant && \
make install VERSION=$$(git describe)" && \
( vagrant ssh -c "sudo systemctl reboot" || : ) && \
sleep 2; \
fi
vmshell: vmbuild
vagrant ssh
# set up test environment to somewhat resemble uninstalled tests
vmcheck: vmbuild
@env VMTESTS=1 \
builddir="$(abs_builddir)" \
topsrcdir="$(abs_top_srcdir)" \
commondir="$(abs_top_srcdir)/tests/common" \
sh tests/vmcheck/test.sh
testenv:
@echo "===== ENTERING TESTENV ====="
test_tmpdir=$$(mktemp -d test.XXXXXX) && \
cd $$test_tmpdir && \
env $(AM_TESTS_ENVIRONMENT) TESTENV=1 \
sh ../tests/utils/setup-session.sh bash && \
cd .. && \
rm -rf $$test_tmpdir
@echo "===== LEAVING TESTENV ====="