Makefile.am 14.9 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
AM_CPPFLAGS = \
	-I$(top_srcdir) \
9
	$(DBUS_STATIC_BUILD_CPPFLAGS) \
10
	-DDBUS_COMPILATION \
11 12
	$(GLIB_CFLAGS) \
	$(NULL)
13

14 15 16
# improve backtraces from test stuff
AM_LDFLAGS = @R_DYNAMIC_LDFLAG@

17
noinst_LTLIBRARIES = libdbus-testutils.la
18

19 20 21 22 23 24 25 26 27 28 29 30
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

31
libdbus_testutils_la_LIBADD = \
32
	$(top_builddir)/dbus/libdbus-1.la \
33 34
	$(top_builddir)/dbus/libdbus-internal.la \
	$(NULL)
35

36
if DBUS_ENABLE_EMBEDDED_TESTS
37
## break-loader removed for now
38
## these binaries are used in tests but are not themselves tests
39
TEST_BINARIES = \
40
	test-spawn \
41 42 43 44 45 46 47
	test-exit \
	test-names \
	test-segfault \
	test-service \
	test-shell-service \
	test-sleep-forever \
	$(NULL)
48

49 50 51
## 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,
## since they depend on stuff from this directory
52
TESTS = \
53
	../bus/test-bus$(EXEEXT) \
54
	../dbus/test-dbus$(EXEEXT) \
55 56
	$(NULL)

57
if DBUS_UNIX
58
TESTS += ../bus/test-bus-launch-helper$(EXEEXT)
59
TESTS += ../bus/test-bus-system$(EXEEXT)
60 61
endif

62
else !DBUS_ENABLE_EMBEDDED_TESTS
63

64
TEST_BINARIES=
65
TESTS=
66

67
endif !DBUS_ENABLE_EMBEDDED_TESTS
68

69
noinst_PROGRAMS= $(TEST_BINARIES)
70

71 72
test_service_LDADD = libdbus-testutils.la
test_names_LDADD = libdbus-testutils.la
73
## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
74
test_shell_service_LDADD = libdbus-testutils.la
75
test_shell_SOURCES = shell-test.c
76
test_shell_LDADD = libdbus-testutils.la
77 78
test_spawn_SOURCES = spawn-test.c
test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la
79

80 81 82
test_printf_SOURCES = internals/printf.c
test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la

83
test_refs_SOURCES = internals/refs.c
84
test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
85

86
test_syslog_SOURCES = internals/syslog.c
87
test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS)
88

89 90 91
manual_dir_iter_SOURCES = manual-dir-iter.c
manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la

92 93 94
manual_paths_SOURCES = manual-paths.c
manual_paths_LDADD = $(top_builddir)/dbus/libdbus-internal.la

Ralf Habacker's avatar
Ralf Habacker committed
95 96 97
manual_tcp_SOURCES = manual-tcp.c
manual_tcp_LDADD = $(top_builddir)/dbus/libdbus-internal.la

98
EXTRA_DIST = dbus-test-runner
99

100 101
testexecdir = $(libexecdir)/installed-tests/dbus
testmetadir = $(datadir)/installed-tests/dbus
102 103

testexec_PROGRAMS =
104
testmeta_DATA =
105 106

installable_tests = \
107
	test-shell \
108
	test-printf \
109
	$(NULL)
Ralf Habacker's avatar
Ralf Habacker committed
110
installable_manual_tests = \
111
	manual-dir-iter \
Ralf Habacker's avatar
Ralf Habacker committed
112 113
        manual-tcp \
        $(NULL)
114

115 116 117 118
if DBUS_WIN
installable_manual_tests += manual-paths
endif

119 120
if DBUS_WITH_GLIB
installable_tests += \
121
	test-corrupt \
122
	test-dbus-daemon \
123
	test-dbus-daemon-eavesdrop \
124
	test-fdpass \
125
	test-monitor \
126
	test-loopback \
127
	test-marshal \
128
	test-refs \
129
	test-relay \
130
	test-sd-activation \
131
	test-syntax \
132
	test-syslog \
133
	test-uid-permissions \
134
	$(NULL)
135 136 137
installable_manual_tests += \
	manual-authz \
	$(NULL)
138
endif DBUS_WITH_GLIB
139

140 141 142
installable_test_meta = $(installable_tests:=.test)
installable_test_meta_with_config = $(installable_tests:=_with_config.test)

143 144
installcheck_tests =
installcheck_environment = \
145
	XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \
146
	DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
147
	DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
148
	DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
149

150
TESTS_ENVIRONMENT = \
151
	XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \
Simon McVittie's avatar
Simon McVittie committed
152
	DBUS_FATAL_WARNINGS=1 \
153
	DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
154 155 156
	DBUS_TEST_DATA=@abs_top_builddir@/test/data \
	DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
	$(NULL)
157

158
manual_authz_SOURCES = manual-authz.c
159
manual_authz_LDADD = \
160
    libdbus-testutils.la \
161
    $(GLIB_LIBS) \
162
    $(NULL)
163

164
test_corrupt_SOURCES = corrupt.c
165
test_corrupt_LDADD = \
166
    libdbus-testutils.la \
167
    $(GLIB_LIBS) \
168
    $(NULL)
169

170
test_loopback_SOURCES = loopback.c
171
test_loopback_LDADD = \
172
    libdbus-testutils.la \
173
    $(GLIB_LIBS) \
174
    $(NULL)
175

176
test_relay_SOURCES = relay.c
177
test_relay_LDADD = \
178
    libdbus-testutils.la \
179
    $(GLIB_LIBS) \
180
    $(NULL)
181

182
test_dbus_daemon_SOURCES = dbus-daemon.c
183
test_dbus_daemon_LDADD = \
184
    libdbus-testutils.la \
185
    $(GLIB_LIBS) \
186
    $(NULL)
187

188
test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
189
test_dbus_daemon_eavesdrop_LDADD = \
190
    libdbus-testutils.la \
191
    $(GLIB_LIBS) \
192
    $(NULL)
193

194 195 196 197
test_sd_activation_SOURCES = \
    sd-activation.c \
    $(NULL)
test_sd_activation_LDADD = \
198
    libdbus-testutils.la \
199 200 201
    $(GLIB_LIBS) \
    $(NULL)

202
test_marshal_SOURCES = marshal.c
203
test_marshal_LDADD = \
204
    libdbus-testutils.la \
205
    $(GLIB_LIBS) \
206
    $(NULL)
207

208 209 210 211
test_monitor_SOURCES = \
    monitor.c \
    $(NULL)
test_monitor_LDADD = \
212
    libdbus-testutils.la \
213 214 215
    $(GLIB_LIBS) \
    $(NULL)

216
test_syntax_SOURCES = syntax.c
217
test_syntax_LDADD = \
218
    libdbus-testutils.la \
219 220
    $(GLIB_LIBS) \
    $(NULL)
221

222 223 224 225
test_uid_permissions_SOURCES = \
    uid-permissions.c \
    $(NULL)
test_uid_permissions_LDADD = \
226
    libdbus-testutils.la \
227 228 229
    $(GLIB_LIBS) \
    $(NULL)

230 231 232 233
test_fdpass_SOURCES = \
    fdpass.c \
    $(NULL)
test_fdpass_LDADD = \
234
    libdbus-testutils.la \
235 236 237
    $(GLIB_LIBS) \
    $(NULL)

238
if DBUS_ENABLE_MODULAR_TESTS
239 240 241 242
TESTS += $(installable_tests)
installcheck_tests += $(installable_tests)

if DBUS_ENABLE_INSTALLED_TESTS
243
  testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests)
244 245 246

  testmeta_DATA += $(installable_test_meta)
  testmeta_DATA += $(installable_test_meta_with_config)
247
else !DBUS_ENABLE_INSTALLED_TESTS
248
  noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests)
249 250
endif !DBUS_ENABLE_INSTALLED_TESTS

251 252
endif DBUS_ENABLE_MODULAR_TESTS

253 254 255
# 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.
256 257 258
installcheck-local:
	$(MAKE) check-TESTS TESTS='$$(installcheck_tests)' \
		TESTS_ENVIRONMENT='$$(installcheck_environment)'
259
if DBUS_ENABLE_INSTALLED_TESTS
260
	test -n "$(DESTDIR)" || \
261 262 263 264 265
	$(installcheck_environment) \
		$(srcdir)/dbus-test-runner \
		$(testexecdir) \
		$(testexec_PROGRAMS)
endif DBUS_ENABLE_INSTALLED_TESTS
266

267 268 269 270 271
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 \
272
	data/valid-config-files/finite-timeout.conf.in \
273
	data/valid-config-files/forbidding.conf.in \
274
	data/valid-config-files/incoming-limit.conf.in \
275
	data/valid-config-files/multi-user.conf.in \
276
	data/valid-config-files/systemd-activation.conf.in \
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 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
	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 \
345 346 347 348
	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 \
349 350 351
	data/valid-config-files/basic.conf \
	data/valid-config-files/basic.d/basic.conf \
	data/valid-config-files/entities.conf \
352
	data/valid-config-files/listen-unix-runtime.conf \
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
	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
375
## are all in one place.
376 377 378 379
all-local: copy-config-local uninstalled-config-local
	@:

copy-config-local:
380
	$(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
381
	$(AM_V_GEN)set -e; \
382 383 384 385
	if test $(srcdir) = . || test $(srcdir) -ef .; then \
		echo '-- No need to copy test data as srcdir = builddir'; \
	else \
		for F in $(static_data); do \
386 387 388
			$(MKDIR_P) "$${F%/*}"; \
			rm -f "$$F"; \
			cp $(srcdir)/"$$F" "$$F"; \
389 390 391
		done; \
	fi

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
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
428
	$(AM_V_GEN)set -e; \
429
	for F in $(static_data); do \
430 431 432
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "$(srcdir)/$$F" "$(DESTDIR)$(testexecdir)/$$F"; \
	done; \
433
	for F in $(in_data); do \
434 435
		install -d "$(DESTDIR)$(testexecdir)/$${F%/*}"; \
		install -m644 "installable/$${F%.in}" "$(DESTDIR)$(testexecdir)/$${F%.in}"; \
436
	done
437 438 439 440
	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
441 442 443 444
else
	@:
endif

445
## this doesn't clean most copied test data files when srcdir=builddir
446
clean-local:
447 448 449 450
	$(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); \
451 452 453
		for F in $(in_data); do \
			rm -f "$${F%.in}"; \
		done; \
454
	fi
455 456 457 458 459 460 461

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

noinst_DATA = $(imported_data)
462 463 464 465 466
CLEANFILES = \
	$(noinst_DATA) \
	XDG_RUNTIME_DIR \
	installable \
	$(NULL)
467

468
$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf
469 470
	$(AM_V_at)$(MKDIR_P) data/valid-config-files
	$(AM_V_GEN)cp $< $@
471

472
$(installable_test_meta): %.test: %$(EXEEXT) Makefile
473 474 475
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
476 477
		echo 'Output=TAP'; \
		echo 'Exec=env DBUS_TEST_HOME=$$(pwd)/home.tmp $(testexecdir)/$* --tap'; \
478 479
	) > $@.tmp && mv $@.tmp $@

480
$(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
481 482 483
	$(AM_V_GEN) ( \
		echo '[Test]'; \
		echo 'Type=session'; \
484 485
		echo 'Output=TAP'; \
		echo 'Exec=env DBUS_TEST_HOME=$$(pwd)/home.tmp DBUS_TEST_DATA=$(testexecdir)/data $(testexecdir)/$* --tap'; \
486
	) > $@.tmp && mv $@.tmp $@