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
LOG_COMPILER = $(srcdir)/glib-tap-test.sh
SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = $(SHELL)
EXTRA_DIST += glib-tap-test.sh
46
EXTRA_DIST += tap-test.sh.in
47 48 49

TESTS =

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

63 64
## 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,
65 66 67 68 69
## 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
70

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

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)

$(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-syntax \
155
	test-syslog \
156
	test-uid-permissions \
157
	$(NULL)
158 159 160 161 162 163 164

if DBUS_UNIX
installable_tests += \
	test-sd-activation \
	$(NULL)
endif DBUS_UNIX

165 166 167
installable_manual_tests += \
	manual-authz \
	$(NULL)
168
endif DBUS_WITH_GLIB
169

170 171 172
installable_test_meta = $(installable_tests:=.test)
installable_test_meta_with_config = $(installable_tests:=_with_config.test)

173 174
installcheck_tests =
installcheck_environment = \
175 176 177
	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; \
178
	export DBUS_TEST_DATADIR=$(DESTDIR)$(datadir); \
179
	${NULL}
180

181
AM_TESTS_ENVIRONMENT = \
182 183 184 185 186
	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; \
187
	$(NULL)
188

189
manual_authz_SOURCES = manual-authz.c
190
manual_authz_LDADD = \
191
    libdbus-testutils.la \
192
    $(GLIB_LIBS) \
193
    $(NULL)
194

195
test_corrupt_SOURCES = corrupt.c
196
test_corrupt_LDADD = \
197
    libdbus-testutils.la \
198
    $(GLIB_LIBS) \
199
    $(NULL)
200

201
test_loopback_SOURCES = loopback.c
202
test_loopback_LDADD = \
203
    libdbus-testutils.la \
204
    $(GLIB_LIBS) \
205
    $(NULL)
206

207
test_relay_SOURCES = relay.c
208
test_relay_LDADD = \
209
    libdbus-testutils.la \
210
    $(GLIB_LIBS) \
211
    $(NULL)
212

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

219
test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
220
test_dbus_daemon_eavesdrop_LDADD = \
221
    libdbus-testutils.la \
222
    $(GLIB_LIBS) \
223
    $(NULL)
224

225
if DBUS_UNIX
226 227 228 229
test_sd_activation_SOURCES = \
    sd-activation.c \
    $(NULL)
test_sd_activation_LDADD = \
230
    libdbus-testutils.la \
231 232
    $(GLIB_LIBS) \
    $(NULL)
233
endif
234

235
test_marshal_SOURCES = marshal.c
236
test_marshal_LDADD = \
237
    libdbus-testutils.la \
238
    $(GLIB_LIBS) \
239
    $(NULL)
240

241 242 243 244
test_monitor_SOURCES = \
    monitor.c \
    $(NULL)
test_monitor_LDADD = \
245
    libdbus-testutils.la \
246 247 248
    $(GLIB_LIBS) \
    $(NULL)

249
test_syntax_SOURCES = syntax.c
250
test_syntax_LDADD = \
251
    libdbus-testutils.la \
252 253
    $(GLIB_LIBS) \
    $(NULL)
254

255 256 257 258
test_uid_permissions_SOURCES = \
    uid-permissions.c \
    $(NULL)
test_uid_permissions_LDADD = \
259
    libdbus-testutils.la \
260 261 262
    $(GLIB_LIBS) \
    $(NULL)

263 264 265 266
test_fdpass_SOURCES = \
    fdpass.c \
    $(NULL)
test_fdpass_LDADD = \
267
    libdbus-testutils.la \
268 269 270
    $(GLIB_LIBS) \
    $(NULL)

271
if DBUS_ENABLE_MODULAR_TESTS
272 273 274 275
TESTS += $(installable_tests)
installcheck_tests += $(installable_tests)

if DBUS_ENABLE_INSTALLED_TESTS
276
  testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests)
277 278 279

  testmeta_DATA += $(installable_test_meta)
  testmeta_DATA += $(installable_test_meta_with_config)
280
else !DBUS_ENABLE_INSTALLED_TESTS
281
  noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests)
282 283
endif !DBUS_ENABLE_INSTALLED_TESTS

284 285
endif DBUS_ENABLE_MODULAR_TESTS

286 287 288
# 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.
289 290
installcheck-local:
	$(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
291
		AM_TESTS_ENVIRONMENT='$$(installcheck_environment)'
292
if DBUS_ENABLE_INSTALLED_TESTS
293
	test -n "$(DESTDIR)" || { \
294 295 296
	$(installcheck_environment) \
		$(srcdir)/dbus-test-runner \
		$(testexecdir) \
297
		$(testexec_PROGRAMS) }
298
endif DBUS_ENABLE_INSTALLED_TESTS
299

300 301 302 303 304
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 \
305
	data/valid-config-files/finite-timeout.conf.in \
306
	data/valid-config-files/forbidding.conf.in \
307
	data/valid-config-files/incoming-limit.conf.in \
308
	data/valid-config-files/multi-user.conf.in \
309
	data/valid-config-files/systemd-activation.conf.in \
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 370 371 372 373 374 375 376 377
	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 \
378 379 380 381
	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 \
382 383 384
	data/valid-config-files/basic.conf \
	data/valid-config-files/basic.d/basic.conf \
	data/valid-config-files/entities.conf \
385
	data/valid-config-files/listen-unix-runtime.conf \
386
	data/valid-config-files/many-rules.conf \
387
	data/valid-config-files-system/system.d/test.conf \
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
	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
408
## are all in one place.
409 410 411 412
all-local: copy-config-local uninstalled-config-local
	@:

copy-config-local:
413
	$(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
414
	$(AM_V_GEN)set -e; \
415 416 417 418
	if test $(srcdir) = . || test $(srcdir) -ef .; then \
		echo '-- No need to copy test data as srcdir = builddir'; \
	else \
		for F in $(static_data); do \
419 420 421
			$(MKDIR_P) "$${F%/*}"; \
			rm -f "$$F"; \
			cp $(srcdir)/"$$F" "$$F"; \
422 423 424
		done; \
	fi

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 453 454 455 456 457 458 459 460
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
461
	$(AM_V_GEN)set -e; \
462
	for F in $(static_data); do \
463 464 465
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "$(srcdir)/$$F" "$(DESTDIR)$(testexecdir)/$$F"; \
	done; \
466
	for F in $(in_data); do \
467 468
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
469
	done
470
	ln -nfs $(datadir)/dbus-1/session.conf $(DESTDIR)$(testexecdir)/data/valid-config-files/session.conf
471
	ln -nfs $(datadir)/dbus-1/system.conf $(DESTDIR)$(testexecdir)/data/valid-config-files-system/system.conf
472 473 474 475
else
	@:
endif

476
## this doesn't clean most copied test data files when srcdir=builddir
477
clean-local:
478 479 480 481
	$(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); \
482 483 484
		for F in $(in_data); do \
			rm -f "$${F%.in}"; \
		done; \
485
	fi
486 487 488

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

noinst_DATA = $(imported_data)
493
CLEANFILES += \
494 495 496 497
	$(noinst_DATA) \
	XDG_RUNTIME_DIR \
	installable \
	$(NULL)
498

499
data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf
500 501
	$(AM_V_at)$(MKDIR_P) data/valid-config-files
	$(AM_V_GEN)cp $< $@
502

503 504 505 506
data/valid-config-files-system/system.conf: $(top_builddir)/bus/system.conf
	$(AM_V_at)$(MKDIR_P) data/valid-config-files-system
	$(AM_V_GEN)cp $< $@

507
$(installable_test_meta): %.test: %$(EXEEXT) Makefile
508 509 510
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
511
		echo 'Output=TAP'; \
512
		echo 'Exec=env $(testexecdir)/$* --tap'; \
513 514
	) > $@.tmp && mv $@.tmp $@

515
$(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
516 517 518
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
519
		echo 'Output=TAP'; \
520
		echo 'Exec=env DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \
521
	) > $@.tmp && mv $@.tmp $@