#
# Makefile to run tests with system binaries
# USE: make -f Makefile.localtest tests CRYPTSETUP_PATH=/sbin
#
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
LDLIBS=-lcryptsetup -ldevmapper
TESTS=$(wildcard *-test *-test2) api-test api-test-2

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)

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

clean:
	rm -f *.o differ api-test api-test-2

.PHONY: clean
