Makefile-tests.am 14.8 KB
Newer Older
Colin Walters's avatar
Colin Walters committed
1 2 3 4
# Makefile for tests code
#
# Copyright (C) 2013 Colin Walters <walters@verbum.org>
#
5 6
# SPDX-License-Identifier: LGPL-2.0+
#
Colin Walters's avatar
Colin Walters committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

22 23 24
EXTRA_DIST += \
	buildutil/tap-driver.sh \
	buildutil/tap-test \
25 26
	tests/glib.supp \
	tests/ostree.supp \
27 28
	$(NULL)

29 30 31
# We should probably consider flipping the default for DEBUG.  Also,
# include the builddir in $PATH so we find our just-built ostree
# binary.
32
AM_TESTS_ENVIRONMENT += OT_TESTS_DEBUG=1 \
33
  OSTREE_UNINSTALLED_SRCDIR=$(abs_top_srcdir) \
34
	OSTREE_UNINSTALLED=$(abs_top_builddir) \
35
	G_DEBUG=fatal-warnings \
36 37
	GI_TYPELIB_PATH=$$(cd $(top_builddir) && pwd)$${GI_TYPELIB_PATH:+:$$GI_TYPELIB_PATH} \
	LD_LIBRARY_PATH=$$(cd $(top_builddir)/.libs && pwd)$${LD_LIBRARY_PATH:+:$${LD_LIBRARY_PATH}} \
38
	PATH=$$(cd $(top_builddir)/tests && pwd):$${PATH} \
39
	OSTREE_FEATURES="$(OSTREE_FEATURES)" \
40
	PYTHONUNBUFFERED=1 \
41
	$(NULL)
42
if BUILDOPT_ASAN
43
AM_TESTS_ENVIRONMENT += OT_SKIP_READDIR_RAND=1 G_SLICE=always-malloc
44
endif
45

46
uninstalled_test_data = tests/ostree-symlink-stamp tests/ostree-prepare-root-symlink-stamp \
47
			tests/ostree-remount-symlink-stamp
48

49 50 51 52 53 54 55 56
dist_uninstalled_test_scripts = tests/test-symbols.sh tests/coccinelle.sh

# This logic implements ENABLE_INSTALLED_TESTS_EXCLUSIVE; see below.
# The goal here if installed tests are enabled, we explicitly make the
# tests *only* run installed, to avoid having to run them twice in CI.
# This overrides the glib-tap.mk emphasis on doing both, if we'd
# used e.g. `dist_test_scripts`.
dist_test_scripts = $(NULL)
57 58 59 60 61
test_programs = \
	tests/test-bloom \
	tests/test-repo-finder-config \
	tests/test-repo-finder-mount \
	$(NULL)
62
_installed_or_uninstalled_test_scripts = \
63
	tests/test-basic.sh \
64
	tests/test-basic-user.sh \
65
	tests/test-basic-user-only.sh \
66
	tests/test-basic-root.sh \
67 68 69
	tests/test-pull-subpath.sh \
	tests/test-archivez.sh \
	tests/test-remote-add.sh \
70
	tests/test-remote-headers.sh \
71 72 73 74 75
	tests/test-remote-gpg-import.sh \
	tests/test-commit-sign.sh \
	tests/test-export.sh \
	tests/test-help.sh \
	tests/test-libarchive.sh \
76
	tests/test-parent.sh \
77 78
	tests/test-pull-bare.sh \
	tests/test-pull-bareuser.sh \
79
	tests/test-pull-bareuseronly.sh \
80
	tests/test-pull2-bareuseronly.sh \
81 82 83 84 85 86 87
	tests/test-pull-commit-only.sh \
	tests/test-pull-depth.sh \
	tests/test-pull-mirror-summary.sh \
	tests/test-pull-large-metadata.sh \
	tests/test-pull-metalink.sh \
	tests/test-pull-summary-sigs.sh \
	tests/test-pull-resume.sh \
88
	tests/test-pull-repeated.sh \
89
	tests/test-pull-untrusted.sh \
90
	tests/test-pull-override-url.sh \
91
	tests/test-pull-localcache.sh \
Alexander Larsson's avatar
Alexander Larsson committed
92
	tests/test-local-pull.sh \
93 94 95
	tests/test-local-pull-depth.sh \
	tests/test-gpg-signed-commit.sh \
	tests/test-admin-upgrade-unconfigured.sh \
96
	tests/test-admin-upgrade-endoflife.sh \
97
	tests/test-admin-upgrade-systemd-update.sh \
98 99 100 101 102 103
	tests/test-admin-deploy-syslinux.sh \
	tests/test-admin-deploy-2.sh \
	tests/test-admin-deploy-karg.sh \
	tests/test-admin-deploy-switch.sh \
	tests/test-admin-deploy-etcmerge-cornercases.sh \
	tests/test-admin-deploy-uboot.sh \
104
	tests/test-admin-deploy-grub2.sh \
105
	tests/test-admin-deploy-bootid-gc.sh \
106 107 108
	tests/test-admin-instutil-set-kargs.sh \
	tests/test-admin-upgrade-not-backwards.sh \
	tests/test-admin-pull-deploy-commit.sh \
109
	tests/test-admin-pull-deploy-split.sh \
110 111
	tests/test-admin-locking.sh \
	tests/test-admin-deploy-clean.sh \
112
	tests/test-admin-gpg.sh \
113 114 115 116 117 118
	tests/test-reset-nonlinear.sh \
	tests/test-oldstyle-partial.sh \
	tests/test-delta.sh \
	tests/test-xattrs.sh \
	tests/test-auto-summary.sh \
	tests/test-prune.sh \
119
	tests/test-concurrency.py \
120
	tests/test-refs.sh \
121
	tests/test-demo-buildsystem.sh \
122
	tests/test-switchroot.sh \
123 124
	tests/test-pull-contenturl.sh \
	tests/test-pull-mirrorlist.sh \
125
	tests/test-summary-update.sh \
126
	tests/test-summary-view.sh \
127
	tests/test-no-initramfs.sh \
128
	tests/test-create-usb.sh \
129 130 131 132 133 134
	tests/test-find-remotes.sh \
	tests/test-fsck-collections.sh \
	tests/test-init-collections.sh \
	tests/test-prune-collections.sh \
	tests/test-refs-collections.sh \
	tests/test-remote-add-collections.sh \
135
	tests/test-repo-finder-mount-integration.sh \
136
	tests/test-summary-collections.sh \
137
	tests/test-pull-collections.sh \
138
	tests/test-config.sh \
139
	$(NULL)
140 141 142

experimental_test_scripts = \
	$(NULL)
143 144
test_extra_programs = \
	tests/get-byte-order \
145
	tests/repo-finder-mount \
146 147 148 149 150
	$(NULL)

tests_get_byte_order_SOURCES = tests/get-byte-order.c
tests_get_byte_order_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
tests_get_byte_order_LDADD = $(GLIB_LIBS)
151 152 153 154

tests_repo_finder_mount_SOURCES = tests/repo-finder-mount.c
tests_repo_finder_mount_CFLAGS = $(common_tests_cflags)
tests_repo_finder_mount_LDADD = $(common_tests_ldadd) libostreetest.la
155 156 157 158 159

if ENABLE_EXPERIMENTAL_API
_installed_or_uninstalled_test_scripts += $(experimental_test_scripts)
else
EXTRA_DIST += $(experimental_test_scripts)
160 161
endif

Colin Walters's avatar
Colin Walters committed
162
if BUILDOPT_FUSE
163
_installed_or_uninstalled_test_scripts += tests/test-rofiles-fuse.sh
164
uninstalled_test_data += tests/rofiles-fuse-symlink-stamp
165 166
else
EXTRA_DIST += tests/test-rofiles-fuse.sh
Colin Walters's avatar
Colin Walters committed
167 168
endif

169
if USE_LIBSOUP
170
_installed_or_uninstalled_test_scripts += tests/test-remote-cookies.sh
171 172
endif

173
# These call into gjs scripts
174
js_tests = tests/test-corruption.sh tests/test-pull-corruption.sh
175
if BUILDOPT_GJS
176
_installed_or_uninstalled_test_scripts += $(js_tests)
177 178
else
EXTRA_DIST += $(js_tests)
179 180
endif

181
dist_installed_test_data = tests/archive-test.sh \
Colin Walters's avatar
Colin Walters committed
182
	tests/pull-test.sh \
183
	tests/pull-test2.sh \
184
	tests/admin-test.sh \
185
	tests/basic-test.sh \
186 187
	tests/pre-endian-deltas-repo-big.tar.xz \
	tests/pre-endian-deltas-repo-little.tar.xz \
188 189
	tests/fah-deltadata-old.tar.xz \
	tests/fah-deltadata-new.tar.xz \
190
	tests/ostree-path-traverse.tar.gz \
191
	tests/libtest-core.sh \
Colin Walters's avatar
Colin Walters committed
192 193
	$(NULL)

194
EXTRA_DIST += tests/libtest.sh
195

196 197 198 199 200
dist_test_extra_scripts = \
	tests/bootloader-entries-crosscheck.py \
	tests/corrupt-repo-ref.js \
	tests/ostree-grub-generator \
	$(NULL)
201

202 203 204
# We can't use nobase_ as we need to strip off the tests/, can't
# use plain installed_ as we do need the gpghome/ prefix.
if ENABLE_INSTALLED_TESTS
205
gpginsttestdir = $(installed_testdir)/gpghome
206
dist_gpginsttest_DATA = tests/gpghome/secring.gpg \
207
	tests/gpghome/pubring.gpg \
208 209 210 211
	tests/gpghome/trustdb.gpg \
	tests/gpghome/key1.asc \
	tests/gpghome/key2.asc \
	tests/gpghome/key3.asc
212
gpginsttest_trusteddir = $(installed_testdir)/gpghome/trusted
213
dist_gpginsttest_trusted_DATA = tests/gpghome/trusted/pubring.gpg
214

215
gpgvinsttestdir = $(installed_testdir)/gpg-verify-data
216
dist_gpgvinsttest_DATA = $(addprefix tests/gpg-verify-data/, \
217
	gpg.conf lgpl2 lgpl2.sig pubring.gpg secring.gpg trustdb.gpg)
218
endif
219

220 221
js_installed_tests = \
	tests/test-core.js \
222
	tests/test-remotes-config-dir.js \
223
	tests/test-sizes.js \
224
	tests/test-sysroot.js \
225
	$(NULL)
226 227

if BUILDOPT_GJS
228
_installed_or_uninstalled_test_scripts += $(js_installed_tests)
229 230
else
EXTRA_DIST += $(js_installed_tests)
231 232
endif

233
test_ltlibraries = libreaddir-rand.la
234
libreaddir_rand_la_SOURCES = tests/readdir-rand.c
235
libreaddir_rand_la_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS)
236 237 238 239
libreaddir_rand_la_LIBADD = \
	-ldl \
	$(OT_INTERNAL_GIO_UNIX_LIBS) \
	$(NULL)
240
libreaddir_rand_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
241 242 243
if !ENABLE_INSTALLED_TESTS
libreaddir_rand_la_LDFLAGS += -rpath $(abs_builddir)
endif
244

245
_installed_or_uninstalled_test_programs = tests/test-varint tests/test-ot-unix-utils tests/test-bsdiff tests/test-mutable-tree \
246
	tests/test-keyfile-utils tests/test-ot-opt-utils tests/test-ot-tool-util \
247
	tests/test-gpg-verify-result tests/test-checksum tests/test-lzma tests/test-rollsum \
248
	tests/test-basic-c tests/test-sysroot-c tests/test-pull-c tests/test-repo tests/test-include-ostree-h
249

250 251 252
if USE_AVAHI
test_programs += tests/test-repo-finder-avahi
endif
253

254 255 256
# An interactive tool
noinst_PROGRAMS += tests/test-rollsum-cli

257
if USE_LIBARCHIVE
258
_installed_or_uninstalled_test_programs += tests/test-libarchive-import
259 260
endif

261 262 263 264
common_tests_cflags = $(ostree_bin_shared_cflags) $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I$(srcdir)/libglnx
common_tests_ldadd = $(ostree_bin_shared_ldadd) $(OT_INTERNAL_GIO_UNIX_LIBS)

noinst_LTLIBRARIES += libostreetest.la
265
libostreetest_la_SOURCES = tests/libostreetest.c tests/test-mock-gio.c tests/test-mock-gio.h
266 267 268 269 270
libostreetest_la_CFLAGS = $(common_tests_cflags) -I $(srcdir)/tests
libostreetest_la_LIBADD = $(common_tests_ldadd)

TESTS_CFLAGS = $(common_tests_cflags)
TESTS_LDADD = $(common_tests_ldadd) libostreetest.la
271

272 273
tests_test_rollsum_cli_SOURCES = src/libostree/ostree-rollsum.c tests/test-rollsum-cli.c
tests_test_rollsum_cli_CFLAGS = $(TESTS_CFLAGS) $(OT_DEP_ZLIB_CFLAGS)
274
tests_test_rollsum_cli_LDADD = $(bupsplitpath) $(TESTS_LDADD) $(OT_DEP_ZLIB_LIBS)
275

276 277
tests_test_rollsum_SOURCES = src/libostree/ostree-rollsum.c tests/test-rollsum.c
tests_test_rollsum_CFLAGS = $(TESTS_CFLAGS) $(OT_DEP_ZLIB_CFLAGS)
278
tests_test_rollsum_LDADD = $(bupsplitpath) $(TESTS_LDADD) $(OT_DEP_ZLIB_LIBS)
279

280 281 282 283
tests_test_bloom_SOURCES = src/libostree/ostree-bloom.c tests/test-bloom.c
tests_test_bloom_CFLAGS = $(TESTS_CFLAGS)
tests_test_bloom_LDADD = $(TESTS_LDADD)

284 285 286 287 288 289 290
tests_test_include_ostree_h_SOURCES = tests/test-include-ostree-h.c
# Don't use TESTS_CFLAGS so we test if the public header can be included by external programs
tests_test_include_ostree_h_CFLAGS = $(AM_CFLAGS) $(OT_INTERNAL_GIO_UNIX_CFLAGS) -I$(srcdir)/src/libostree -I$(builddir)/src/libostree
# Don't define OSTREE_COMPILATION so that we're compiling as if it's an external program
tests_test_include_ostree_h_CPPFLAGS = $(AM_CPPFLAGS) -UOSTREE_COMPILATION
tests_test_include_ostree_h_LDADD = $(TESTS_LDADD)

291 292 293 294 295 296
if USE_AVAHI
tests_test_repo_finder_avahi_SOURCES = src/libostree/ostree-repo-finder-avahi-parser.c tests/test-repo-finder-avahi.c
tests_test_repo_finder_avahi_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_avahi_LDADD = $(TESTS_LDADD)
endif

297 298 299 300
tests_test_repo_finder_config_SOURCES = tests/test-repo-finder-config.c
tests_test_repo_finder_config_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_config_LDADD = $(TESTS_LDADD)

301 302 303 304
tests_test_repo_finder_mount_SOURCES = tests/test-repo-finder-mount.c
tests_test_repo_finder_mount_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_finder_mount_LDADD = $(TESTS_LDADD)

305 306 307
tests_test_mutable_tree_CFLAGS = $(TESTS_CFLAGS)
tests_test_mutable_tree_LDADD = $(TESTS_LDADD)

308 309 310
tests_test_basic_c_CFLAGS = $(TESTS_CFLAGS)
tests_test_basic_c_LDADD = $(TESTS_LDADD)

311 312 313
tests_test_sysroot_c_CFLAGS = $(TESTS_CFLAGS)
tests_test_sysroot_c_LDADD = $(TESTS_LDADD)

314 315 316
tests_test_pull_c_CFLAGS = $(TESTS_CFLAGS)
tests_test_pull_c_LDADD = $(TESTS_LDADD)

317 318 319
tests_test_repo_CFLAGS = $(TESTS_CFLAGS)
tests_test_repo_LDADD = $(TESTS_LDADD)

320 321
tests_test_ot_unix_utils_CFLAGS = $(TESTS_CFLAGS)
tests_test_ot_unix_utils_LDADD = $(TESTS_LDADD)
322

323 324 325
tests_test_varint_SOURCES = src/libostree/ostree-varint.c tests/test-varint.c
tests_test_varint_CFLAGS = $(TESTS_CFLAGS)
tests_test_varint_LDADD = $(TESTS_LDADD)
326

327 328
tests_test_bsdiff_CFLAGS = $(TESTS_CFLAGS)
tests_test_bsdiff_LDADD = libbsdiff.la $(TESTS_LDADD)
329

330 331 332 333
tests_test_checksum_SOURCES = src/libostree/ostree-core.c tests/test-checksum.c
tests_test_checksum_CFLAGS = $(TESTS_CFLAGS) $(libglnx_cflags)
tests_test_checksum_LDADD = $(TESTS_LDADD)

334
tests_test_libarchive_import_SOURCES = tests/test-libarchive-import.c
335 336
tests_test_libarchive_import_CFLAGS = $(TESTS_CFLAGS) $(libglnx_cflags) $(OT_DEP_LIBARCHIVE_CFLAGS)
tests_test_libarchive_import_LDADD = $(TESTS_LDADD) $(OT_DEP_LIBARCHIVE_LIBS)
337

338 339
tests_test_keyfile_utils_CFLAGS = $(TESTS_CFLAGS)
tests_test_keyfile_utils_LDADD = $(TESTS_LDADD)
340 341 342

tests_test_ot_opt_utils_CFLAGS = $(TESTS_CFLAGS)
tests_test_ot_opt_utils_LDADD = $(TESTS_LDADD)
343 344 345

tests_test_ot_tool_util_CFLAGS = $(TESTS_CFLAGS)
tests_test_ot_tool_util_LDADD = $(TESTS_LDADD)
346

347 348
tests_test_lzma_SOURCES = src/libostree/ostree-lzma-common.c src/libostree/ostree-lzma-compressor.c \
	src/libostree/ostree-lzma-decompressor.c tests/test-lzma.c
349 350
tests_test_lzma_CFLAGS = $(TESTS_CFLAGS) $(OT_DEP_LZMA_CFLAGS)
tests_test_lzma_LDADD = $(TESTS_LDADD) $(OT_DEP_LZMA_LIBS)
351

352 353 354
tests_test_gpg_verify_result_SOURCES = \
	src/libostree/ostree-gpg-verify-result-private.h \
	tests/test-gpg-verify-result.c
355 356
tests_test_gpg_verify_result_CFLAGS = $(TESTS_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS)
tests_test_gpg_verify_result_LDADD = $(TESTS_LDADD) $(OT_INTERNAL_GPGME_LIBS)
357 358

EXTRA_DIST += \
359
	tests/libostreetest.h \
360
	tests/libtest.sh \
361
	tests/gpg-verify-data/README.md \
362
	$(NULL)
363

364
tests/libreaddir-rand.so: Makefile
365 366
	mkdir -p tests/
	$(AM_V_GEN) ln -fns ../.libs/libreaddir-rand.so tests/
367
ALL_LOCAL_RULES += tests/libreaddir-rand.so
368 369 370
CLEANFILES += tests/libreaddir-rand.so tests/ostree-symlink-stamp \
		tests/ostree-prepare-root-symlink-stamp tests/ostree-remount-symlink-stamp \
		tests/rofiles-fuse-symlink-stamp tests/ostree
Colin Walters's avatar
Colin Walters committed
371
CLEANFILES += tests/ostree-prepare-root tests/ostree-remount tests/rofiles-fuse
372

373 374
tests/%-symlink-stamp: % Makefile
	$(AM_V_GEN) set -e; \
375 376 377 378 379 380 381
	lt_bin=`cd $(top_builddir) && ./libtool --mode=execute echo $*`; \
	if test "$${lt_bin}" = "$*"; then \
		real_bin=$(abs_top_builddir)/$*; \
	else \
		real_bin="$${lt_bin}"; \
	fi; \
	ln -sf "$${real_bin}" tests/$*; \
382
	touch $@
383

384 385 386 387 388 389 390 391 392 393 394
# See above comment on binding the tests to be either installed or not.
if ENABLE_INSTALLED_TESTS_EXCLUSIVE
dist_installed_test_scripts = $(_installed_or_uninstalled_test_scripts)
installed_test_programs = $(_installed_or_uninstalled_test_programs)
check-local:
	echo "NOTE: Exclusive installed tests are enabled; to run them, make install, then: gnome-desktop-testing-runner -p 0 libostree/"
else
dist_test_scripts += $(_installed_or_uninstalled_test_scripts)
test_programs += $(_installed_or_uninstalled_test_programs)
endif

395 396 397 398 399 400 401 402
if !USE_LIBSOUP
no-soup-for-you-warning:
	@echo "WARNING: $(PACKAGE) was built without libsoup, which is currently" 1>&2
	@echo "WARNING: required for many unit tests." 1>&2
	sleep 10
check: no-soup-for-you-warning
endif

403 404 405
# Unfortunately the glib test data APIs don't actually handle
# non-recursive Automake, so we change our code to canonically look
# for tests/ which is just a symlink when installed.
406
if ENABLE_INSTALLED_TESTS
407
install-installed-tests-extra:
408 409 410 411
	if test -L $(DESTDIR)$(installed_testdir)/tests; then \
	  rm $(DESTDIR)$(installed_testdir)/tests; \
	fi
	ln -s . $(DESTDIR)$(installed_testdir)/tests
412 413 414 415 416
if BUILDOPT_ASAN
	sed -e 's,^BUILT_WITH_ASAN=.*,BUILT_WITH_ASAN=1,' < $(srcdir)/tests/libtest.sh > $(DESTDIR)$(installed_testdir)/tests/libtest.sh
else
	install -m 0644 $(srcdir)/tests/libtest.sh $(DESTDIR)$(installed_testdir)/tests/libtest.sh
endif
417
INSTALL_DATA_HOOKS += install-installed-tests-extra
418
endif