Makefile.am 15.7 KB
Newer Older
1 2
## the "name-test" subdir in fact contains a bunch of tests now that need a temporary bus 
## to be running to do stuff with. The directory should be renamed.
3 4
## We want to build the current directory first to pick up the testutils lib
SUBDIRS= . name-test 
John Palmieri's avatar
John Palmieri committed
5
DIST_SUBDIRS=name-test
6

7 8 9
CLEANFILES =
EXTRA_DIST =

10 11
AM_CPPFLAGS = \
	-I$(top_srcdir) \
12
	$(DBUS_STATIC_BUILD_CPPFLAGS) \
13
	-DDBUS_COMPILATION \
14 15
	$(GLIB_CFLAGS) \
	$(NULL)
16

17 18 19
# improve backtraces from test stuff
AM_LDFLAGS = @R_DYNAMIC_LDFLAG@

20
noinst_LTLIBRARIES = libdbus-testutils.la
21

22 23 24 25 26 27 28 29 30 31 32 33
libdbus_testutils_la_SOURCES = \
	test-utils.c \
	test-utils.h \
	$(NULL)

if DBUS_WITH_GLIB
libdbus_testutils_la_SOURCES += \
	test-utils-glib.c \
	test-utils-glib.h \
	$(NULL)
endif

34
libdbus_testutils_la_LIBADD = \
35
	$(top_builddir)/dbus/libdbus-1.la \
36 37
	$(top_builddir)/dbus/libdbus-internal.la \
	$(NULL)
38

39 40
TEST_EXTENSIONS = .sh

41
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-driver.sh
42 43 44 45 46 47 48
LOG_COMPILER = $(srcdir)/glib-tap-test.sh
SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = $(SHELL)
EXTRA_DIST += glib-tap-test.sh

TESTS =

49
if DBUS_ENABLE_EMBEDDED_TESTS
50
## break-loader removed for now
51
## these binaries are used in tests but are not themselves tests
52
TEST_BINARIES = \
53
	test-spawn \
54 55 56 57 58 59 60
	test-exit \
	test-names \
	test-segfault \
	test-service \
	test-shell-service \
	test-sleep-forever \
	$(NULL)
61

62 63
## These are conceptually part of directories that come earlier in SUBDIRS
## order, but we don't want to run them til we arrive in this directory,
64 65 66 67 68
## since they depend on stuff from this directory. We wrap them in a
## simple shell script to get TAP output.

wrap_bus_tests = test-bus.sh
wrap_dbus_tests = test-dbus.sh
69

70
if DBUS_UNIX
71 72
wrap_bus_tests += test-bus-launch-helper.sh
wrap_bus_tests += test-bus-system.sh
73 74
endif

75 76 77 78 79 80 81 82 83 84 85 86
TESTS += $(wrap_bus_tests) $(wrap_dbus_tests)
CLEANFILES += $(wrap_bus_tests) $(wrap_dbus_tests)
EXTRA_DIST += tap-test.sh.in

$(wrap_bus_tests): test-bus%.sh: ../bus/test-bus%$(EXEEXT) tap-test.sh.in Makefile
	sed -e 's![@]RUN[@]!$<!' \
		< $(srcdir)/tap-test.sh.in > $@

$(wrap_dbus_tests): test-dbus%.sh: ../dbus/test-dbus%$(EXEEXT) tap-test.sh.in Makefile
	sed -e 's![@]RUN[@]!$<!' \
		< $(srcdir)/tap-test.sh.in > $@

87
else !DBUS_ENABLE_EMBEDDED_TESTS
88

89
TEST_BINARIES=
90

91
endif !DBUS_ENABLE_EMBEDDED_TESTS
92

93
noinst_PROGRAMS= $(TEST_BINARIES)
94

95 96
test_service_LDADD = libdbus-testutils.la
test_names_LDADD = libdbus-testutils.la
97
## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
98
test_shell_service_LDADD = libdbus-testutils.la
99
test_shell_SOURCES = shell-test.c
100
test_shell_LDADD = libdbus-testutils.la
101 102
test_spawn_SOURCES = spawn-test.c
test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la
103

104 105 106
test_printf_SOURCES = internals/printf.c
test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la

107
test_refs_SOURCES = internals/refs.c
108
test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
109

110
test_syslog_SOURCES = internals/syslog.c
111
test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS)
112

113 114 115
manual_dir_iter_SOURCES = manual-dir-iter.c
manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la

116 117 118
manual_paths_SOURCES = manual-paths.c
manual_paths_LDADD = $(top_builddir)/dbus/libdbus-internal.la

119 120 121
manual_tcp_SOURCES = manual-tcp.c
manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la

122
EXTRA_DIST += dbus-test-runner
123

124 125
testexecdir = $(libexecdir)/installed-tests/dbus
testmetadir = $(datadir)/installed-tests/dbus
126 127

testexec_PROGRAMS =
128
testmeta_DATA =
129 130

installable_tests = \
131
	test-shell \
132
	test-printf \
133
	$(NULL)
Ralf Habacker's avatar
Ralf Habacker committed
134
installable_manual_tests = \
135
	manual-dir-iter \
136 137
        manual-tcp \
        $(NULL)
138

139 140 141 142
if DBUS_WIN
installable_manual_tests += manual-paths
endif

143 144
if DBUS_WITH_GLIB
installable_tests += \
145
	test-corrupt \
146
	test-dbus-daemon \
147
	test-dbus-daemon-eavesdrop \
148
	test-fdpass \
149
	test-monitor \
150
	test-loopback \
151
	test-marshal \
152
	test-refs \
153
	test-relay \
154
	test-sd-activation \
155
	test-syntax \
156
	test-syslog \
157
	test-uid-permissions \
158
	$(NULL)
159 160 161
installable_manual_tests += \
	manual-authz \
	$(NULL)
162
endif DBUS_WITH_GLIB
163

164 165 166
installable_test_meta = $(installable_tests:=.test)
installable_test_meta_with_config = $(installable_tests:=_with_config.test)

167 168
installcheck_tests =
installcheck_environment = \
169 170 171 172 173
	export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
	export DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT); \
	export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \
	export DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir); \
	${NULL}
174

175
AM_TESTS_ENVIRONMENT = \
176 177 178 179 180
	export XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR; \
	export DBUS_FATAL_WARNINGS=1; \
	export DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT); \
	export DBUS_TEST_DATA=@abs_top_builddir@/test/data; \
	export DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus; \
181
	$(NULL)
182

183
manual_authz_SOURCES = manual-authz.c
184
manual_authz_LDADD = \
185
    libdbus-testutils.la \
186
    $(GLIB_LIBS) \
187
    $(NULL)
188

189
test_corrupt_SOURCES = corrupt.c
190
test_corrupt_LDADD = \
191
    libdbus-testutils.la \
192
    $(GLIB_LIBS) \
193
    $(NULL)
194

195
test_loopback_SOURCES = loopback.c
196
test_loopback_LDADD = \
197
    libdbus-testutils.la \
198
    $(GLIB_LIBS) \
199
    $(NULL)
200

201
test_relay_SOURCES = relay.c
202
test_relay_LDADD = \
203
    libdbus-testutils.la \
204
    $(GLIB_LIBS) \
205
    $(NULL)
206

207
test_dbus_daemon_SOURCES = dbus-daemon.c
208
test_dbus_daemon_LDADD = \
209
    libdbus-testutils.la \
210
    $(GLIB_LIBS) \
211
    $(NULL)
212

213
test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
214
test_dbus_daemon_eavesdrop_LDADD = \
215
    libdbus-testutils.la \
216
    $(GLIB_LIBS) \
217
    $(NULL)
218

219 220 221 222
test_sd_activation_SOURCES = \
    sd-activation.c \
    $(NULL)
test_sd_activation_LDADD = \
223
    libdbus-testutils.la \
224 225 226
    $(GLIB_LIBS) \
    $(NULL)

227
test_marshal_SOURCES = marshal.c
228
test_marshal_LDADD = \
229
    libdbus-testutils.la \
230
    $(GLIB_LIBS) \
231
    $(NULL)
232

233 234 235 236
test_monitor_SOURCES = \
    monitor.c \
    $(NULL)
test_monitor_LDADD = \
237
    libdbus-testutils.la \
238 239 240
    $(GLIB_LIBS) \
    $(NULL)

241
test_syntax_SOURCES = syntax.c
242
test_syntax_LDADD = \
243
    libdbus-testutils.la \
244 245
    $(GLIB_LIBS) \
    $(NULL)
246

247 248 249 250
test_uid_permissions_SOURCES = \
    uid-permissions.c \
    $(NULL)
test_uid_permissions_LDADD = \
251
    libdbus-testutils.la \
252 253 254
    $(GLIB_LIBS) \
    $(NULL)

255 256 257 258
test_fdpass_SOURCES = \
    fdpass.c \
    $(NULL)
test_fdpass_LDADD = \
259
    libdbus-testutils.la \
260 261 262
    $(GLIB_LIBS) \
    $(NULL)

263
if DBUS_ENABLE_MODULAR_TESTS
264 265 266 267
TESTS += $(installable_tests)
installcheck_tests += $(installable_tests)

if DBUS_ENABLE_INSTALLED_TESTS
268
  testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests)
269 270 271

  testmeta_DATA += $(installable_test_meta)
  testmeta_DATA += $(installable_test_meta_with_config)
272
else !DBUS_ENABLE_INSTALLED_TESTS
273
  noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests)
274 275
endif !DBUS_ENABLE_INSTALLED_TESTS

276 277
endif DBUS_ENABLE_MODULAR_TESTS

278 279 280
# If we're installing the tests into a DESTDIR we can't run them
# again using the installed copy, because we don't know how to
# do a portable equivalent of setting LD_LIBRARY_PATH.
281 282
installcheck-local:
	$(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
283
		AM_TESTS_ENVIRONMENT='$$(installcheck_environment)'
284
if DBUS_ENABLE_INSTALLED_TESTS
285
	test -n "$(DESTDIR)" || { \
286 287 288
	$(installcheck_environment) \
		$(srcdir)/dbus-test-runner \
		$(testexecdir) \
289
		$(testexec_PROGRAMS) }
290
endif DBUS_ENABLE_INSTALLED_TESTS
291

292 293 294 295 296
in_data = \
	data/valid-config-files-system/debug-allow-all-fail.conf.in \
	data/valid-config-files-system/debug-allow-all-pass.conf.in \
	data/valid-config-files/debug-allow-all-sha1.conf.in \
	data/valid-config-files/debug-allow-all.conf.in \
297
	data/valid-config-files/finite-timeout.conf.in \
298
	data/valid-config-files/forbidding.conf.in \
299
	data/valid-config-files/incoming-limit.conf.in \
300
	data/valid-config-files/multi-user.conf.in \
301
	data/valid-config-files/systemd-activation.conf.in \
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
	data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \
	data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
	data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
	data/valid-service-files-system/org.freedesktop.DBus.TestSuiteEchoService.service.in \
	data/valid-service-files-system/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
	data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
	data/valid-service-files-system/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuiteEchoService.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuiteForkingEchoService.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuiteSegfaultService.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceFail.service.in \
	data/valid-service-files/org.freedesktop.DBus.TestSuiteShellEchoServiceSuccess.service.in \
	$(NULL)

EXTRA_DIST += $(in_data)

static_data = \
	name-test/tmp-session-like-system.conf \
	data/auth/anonymous-client-successful.auth-script \
	data/auth/anonymous-server-successful.auth-script \
	data/auth/cancel.auth-script \
	data/auth/client-out-of-mechanisms.auth-script \
	data/auth/external-failed.auth-script \
	data/auth/external-root.auth-script \
	data/auth/external-silly.auth-script \
	data/auth/external-successful.auth-script \
	data/auth/extra-bytes.auth-script \
	data/auth/fail-after-n-attempts.auth-script \
	data/auth/fallback.auth-script \
	data/auth/invalid-command-client.auth-script \
	data/auth/invalid-command.auth-script \
	data/auth/invalid-hex-encoding.auth-script \
	data/auth/mechanisms.auth-script \
	data/equiv-config-files/basic/basic-1.conf \
	data/equiv-config-files/basic/basic-2.conf \
	data/equiv-config-files/basic/basic.d/basic.conf \
	data/equiv-config-files/entities/basic.d/basic.conf \
	data/equiv-config-files/entities/entities-1.conf \
	data/equiv-config-files/entities/entities-2.conf \
	data/incomplete-messages/missing-body.message \
	data/invalid-config-files/badselinux-1.conf \
	data/invalid-config-files/badselinux-2.conf \
	data/invalid-config-files/circular-1.conf \
	data/invalid-config-files/circular-2.conf \
	data/invalid-config-files/circular-3.conf \
	data/invalid-config-files/not-well-formed.conf \
	data/invalid-config-files/truncated-file.conf \
	data/invalid-messages/array-of-nil.message \
	data/invalid-messages/array-with-mixed-types.message \
	data/invalid-messages/bad-boolean-array.message \
	data/invalid-messages/bad-boolean.message \
	data/invalid-messages/bad-endian.message \
	data/invalid-messages/bad-header-field-alignment.message \
	data/invalid-messages/boolean-has-no-value.message-raw \
	data/invalid-messages/local-namespace.message \
	data/invalid-messages/no-dot-in-name.message \
	data/invalid-messages/not-nul-header-padding.message \
	data/invalid-messages/overlong-name.message \
	data/invalid-messages/too-little-header-padding.message \
	data/invalid-messages/too-much-header-padding-by-far.message \
	data/invalid-messages/too-much-header-padding.message \
	data/invalid-messages/too-short-dict.message \
	data/sha-1/Readme.txt \
	data/sha-1/bit-hashes.sha1 \
	data/sha-1/bit-messages.sha1 \
	data/sha-1/byte-hashes.sha1 \
	data/sha-1/byte-messages.sha1 \
370 371 372 373
	data/systemd-activation/com.example.SystemdActivatable1.service \
	data/systemd-activation/com.example.SystemdActivatable2.service \
	data/systemd-activation/com.example.SystemdActivatable3.service \
	data/systemd-activation/org.freedesktop.systemd1.service \
374 375 376
	data/valid-config-files/basic.conf \
	data/valid-config-files/basic.d/basic.conf \
	data/valid-config-files/entities.conf \
377
	data/valid-config-files/listen-unix-runtime.conf \
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
	data/valid-config-files/many-rules.conf \
	data/valid-config-files/system.d/test.conf \
	data/valid-messages/array-of-array-of-uint32.message \
	data/valid-messages/dict-simple.message \
	data/valid-messages/dict.message \
	data/valid-messages/emptiness.message \
	data/valid-messages/lots-of-arguments.message \
	data/valid-messages/no-padding.message \
	data/valid-messages/opposite-endian.message \
	data/valid-messages/recursive-types.message \
	data/valid-messages/simplest-manual.message \
	data/valid-messages/simplest.message \
	data/valid-messages/standard-acquire-service.message \
	data/valid-messages/standard-hello.message \
	data/valid-messages/standard-list-services.message \
	data/valid-messages/standard-service-exists.message \
	data/valid-messages/unknown-header-field.message \
	$(NULL)

EXTRA_DIST += $(static_data)

## copy tests to builddir so that generated tests and static tests
400
## are all in one place.
401 402 403 404
all-local: copy-config-local uninstalled-config-local
	@:

copy-config-local:
405
	$(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
406
	$(AM_V_GEN)set -e; \
407 408 409 410
	if test $(srcdir) = . || test $(srcdir) -ef .; then \
		echo '-- No need to copy test data as srcdir = builddir'; \
	else \
		for F in $(static_data); do \
411 412 413
			$(MKDIR_P) "$${F%/*}"; \
			rm -f "$$F"; \
			cp $(srcdir)/"$$F" "$$F"; \
414 415 416
		done; \
	fi

417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
uninstalled-config-local:
	$(AM_V_GEN)set -e; \
	for F in $(in_data); do \
		$(MKDIR_P) "$${F%/*}"; \
		sed \
			-e 's,[@]DBUS_TEST_DATA[@],@abs_builddir@/data,' \
			-e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
			-e 's,[@]EXEEXT[@],$(EXEEXT),' \
			-e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],@abs_top_builddir@/bus/dbus-daemon-launch-helper-test$(EXEEXT),' \
			-e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
			< $(srcdir)/"$$F" > "$${F%.in}"; \
	done

installable-config-local:
if DBUS_ENABLE_INSTALLED_TESTS
	$(AM_V_GEN)set -e; \
	for F in $(in_data); do \
		$(MKDIR_P) "installable/$${F%/*}"; \
		sed \
			-e 's,[@]DBUS_TEST_DATA[@],$(testexecdir)/data,' \
			-e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
			-e 's,[@]EXEEXT[@],$(EXEEXT),' \
			-e 's,[@]TEST_LAUNCH_HELPER_BINARY[@],/bin/false,' \
			-e 's,[@]TEST_LISTEN[@],$(TEST_LISTEN),' \
			< $(srcdir)/"$$F" > "installable/$${F%.in}"; \
	done
else
	@:
endif


install-data-local: install-config-local
	@:

install-config-local: installable-config-local
if DBUS_ENABLE_INSTALLED_TESTS
453
	$(AM_V_GEN)set -e; \
454
	for F in $(static_data); do \
455 456 457
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "$(srcdir)/$$F" "$(DESTDIR)$(testexecdir)/$$F"; \
	done; \
458
	for F in $(in_data); do \
459 460
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
461
	done
462 463 464 465
	ln -nfs $(sysconfdir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf
	ln -nfs $(sysconfdir)/dbus-1/session.d $(DESTDIR)$(testexecdir)/data/valid-config-files/session.d
	ln -nfs $(sysconfdir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/system.conf
	ln -nfs $(sysconfdir)/dbus-1/system.d $(DESTDIR)$(testexecdir)/data/valid-config-files/system.d
466 467 468 469
else
	@:
endif

470
## this doesn't clean most copied test data files when srcdir=builddir
471
clean-local:
472 473 474 475
	$(AM_V_at)if test $(srcdir) = . || test $(srcdir) -ef .; then \
		echo '-- No need to clean test data as srcdir = builddir'; \
	else \
		rm -f $(static_data); \
476 477 478
		for F in $(in_data); do \
			rm -f "$${F%.in}"; \
		done; \
479
	fi
480 481 482 483 484 485 486

imported_data = \
	data/valid-config-files/session.conf \
	data/valid-config-files/system.conf \
	$(NULL)

noinst_DATA = $(imported_data)
487
CLEANFILES += \
488 489 490 491
	$(noinst_DATA) \
	XDG_RUNTIME_DIR \
	installable \
	$(NULL)
492

493
$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf
494 495
	$(AM_V_at)$(MKDIR_P) data/valid-config-files
	$(AM_V_GEN)cp $< $@
496

497
$(installable_test_meta): %.test: %$(EXEEXT) Makefile
498 499 500
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
501
		echo 'Output=TAP'; \
502
		echo 'Exec=env $(testexecdir)/$* --tap'; \
503 504
	) > $@.tmp && mv $@.tmp $@

505
$(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
506 507 508
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
509
		echo 'Output=TAP'; \
510
		echo 'Exec=env DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \
511
	) > $@.tmp && mv $@.tmp $@