summaryrefslogtreecommitdiffstats
path: root/tests/Makefile.localtest
blob: 89ce2c395976380aa96989329c87caca0b7cb970 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#
# Makefile to run tests with system binaries
# USE: make -f Makefile.localtest tests CRYPTSETUP_PATH=/sbin
#      (append TESTSUITE_NOSKIP=y to avoid treating skipped tests as success)
#
CPPFLAGS=-I../lib/ -I../lib/luks1 -DHAVE_DECL_DM_TASK_RETRY_REMOVE -DKERNEL_KEYRING \
	-DHAVE_SYS_SYSMACROS_H -DNO_CRYPTSETUP_PATH
CFLAGS=-O2 -g -Wall -D_GNU_SOURCE
LDLIBS=-lcryptsetup -ldevmapper
TESTS=$(wildcard *-test *-test2) api-test api-test-2 all-symbols-test unit-utils-crypt-test
TESTS_UTILS=differ unit-utils-io unit-wipe

ifneq ($(RUN_SSH_PLUGIN_TEST),)
TESTS += ssh-test-plugin
endif

ifneq ($(RUN_SYSTEMD_PLUGIN_TEST),)
TESTS += systemd-test-plugin
TESTS_UTILS += fake_systemd_tpm_path.so
endif

check-programs: $(TESTS_UTILS) $(TESTS)

differ: differ.o
	$(CC) -o $@ $^

api-test: api-test.o test_utils.o
	$(CC) -o $@ $^ $(LDLIBS)

api-test-2: api-test-2.o test_utils.o
	$(CC) -o $@ $^ $(LDLIBS)

unit-wipe: unit-wipe.o
	$(CC) -o $@ $^ $(LDLIBS)

unit-utils-io: unit-utils-io.o ../lib/utils_io.o
	$(CC) -o $@ $^

unit-utils-crypt-test: unit-utils-crypt.o ../lib/utils_crypt.o
	$(CC) -o $@ $^ $(LDLIBS)

test-symbols-list.h: generate-symbols-list
	./generate-symbols-list ../lib/libcryptsetup.sym > test-symbols-list.h

all-symbols-test.o: test-symbols-list.h
	$(CC) -c $*.c

all-symbols-test: all-symbols-test.o
	$(CC) -o $@ $^ -ldl

fake_systemd_tpm_path.so: fake_systemd_tpm_path.c
	$(CC) -fPIC -shared -D_GNU_SOURCE -o fake_systemd_tpm_path.so fake_systemd_tpm_path.c

tests: $(TESTS_UTILS) $(TESTS)
	@for test in $(sort $(TESTS)); do \
		echo [$$test]; \
		./$$test; \
		[ $(if $(TESTSUITE_NOSKIP),,$$? -ne 77 -a) $$? -ne 0 ] && exit 1; \
		true; \
	done;

clean:
	rm -f *.o $(TESTS_UTILS) api-test api-test-2 unit-utils-crypt-test \
		all-symbols-test test-symbols-list.h

.PHONY: clean