Imported Upstream version 2.6.1
[platform/upstream/cryptsetup.git] / tests / Makefile.localtest
1 #
2 # Makefile to run tests with system binaries
3 # USE: make -f Makefile.localtest tests CRYPTSETUP_PATH=/sbin
4 #      (append TESTSUITE_NOSKIP=y to avoid treating skipped tests as success)
5 #
6 CPPFLAGS=-I../lib/ -I../lib/luks1 -DHAVE_DECL_DM_TASK_RETRY_REMOVE -DKERNEL_KEYRING \
7         -DHAVE_SYS_SYSMACROS_H -DNO_CRYPTSETUP_PATH
8 CFLAGS=-O2 -g -Wall -D_GNU_SOURCE
9 LDLIBS=-lcryptsetup -ldevmapper
10 TESTS=$(wildcard *-test *-test2) api-test api-test-2 all-symbols-test unit-utils-crypt-test
11 TESTS_UTILS=differ unit-utils-io unit-wipe
12
13 ifneq ($(RUN_SSH_PLUGIN_TEST),)
14 TESTS += ssh-test-plugin
15 endif
16
17 ifneq ($(RUN_SYSTEMD_PLUGIN_TEST),)
18 TESTS += systemd-test-plugin
19 TESTS_UTILS += fake_systemd_tpm_path.so
20 endif
21
22 check-programs: $(TESTS_UTILS) $(TESTS)
23
24 differ: differ.o
25         $(CC) -o $@ $^
26
27 api-test: api-test.o test_utils.o
28         $(CC) -o $@ $^ $(LDLIBS)
29
30 api-test-2: api-test-2.o test_utils.o
31         $(CC) -o $@ $^ $(LDLIBS)
32
33 unit-wipe: unit-wipe.o
34         $(CC) -o $@ $^ $(LDLIBS)
35
36 unit-utils-io: unit-utils-io.o ../lib/utils_io.o
37         $(CC) -o $@ $^
38
39 unit-utils-crypt-test: unit-utils-crypt.o ../lib/utils_crypt.o
40         $(CC) -o $@ $^ $(LDLIBS)
41
42 test-symbols-list.h: generate-symbols-list
43         ./generate-symbols-list ../lib/libcryptsetup.sym > test-symbols-list.h
44
45 all-symbols-test.o: test-symbols-list.h
46         $(CC) -c $*.c
47
48 all-symbols-test: all-symbols-test.o
49         $(CC) -o $@ $^ -ldl
50
51 fake_systemd_tpm_path.so: fake_systemd_tpm_path.c
52         $(CC) -fPIC -shared -D_GNU_SOURCE -o fake_systemd_tpm_path.so fake_systemd_tpm_path.c
53
54 tests: $(TESTS_UTILS) $(TESTS)
55         @for test in $(sort $(TESTS)); do \
56                 echo [$$test]; \
57                 ./$$test; \
58                 [ $(if $(TESTSUITE_NOSKIP),,$$? -ne 77 -a) $$? -ne 0 ] && exit 1; \
59                 true; \
60         done;
61
62 clean:
63         rm -f *.o $(TESTS_UTILS) api-test api-test-2 unit-utils-crypt-test \
64                 all-symbols-test test-symbols-list.h
65
66 .PHONY: clean