+
+# Tests
+
+test: tests/gr tests/pw tests/group.nsscash tests/passwd.nsscash
+ LD_LIBRARY_PATH=./tests LD_PRELOAD= ./tests/gr
+ LD_LIBRARY_PATH=./tests LD_PRELOAD= ./tests/pw
+
+tests/%: tests/%.c tests/libcash_test.so
+ $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \
+ $(TEST_CFLAGS) $(TEST_LDFLAGS) -Ltests \
+ $< $(LDLIBS) -lcash_test
+
+tests/passwd.nsscash: tests/passwd
+ ../nsscash convert passwd $< $@
+tests/group.nsscash: tests/group
+ ../nsscash convert group $< $@
+
+tests/libcash_test.so: CFLAGS += $(TEST_CFLAGS)
+tests/libcash_test.so: CPPFLAGS += -DNSSCASH_GROUP_FILE='"./tests/group.nsscash"' \
+ -DNSSCASH_PASSWD_FILE='"./tests/passwd.nsscash"'
+tests/libcash_test.so: LDFLAGS += $(TEST_LDFLAGS)
+
+.PHONY: all clean test