X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=nss%2FMakefile;h=bbc43ee4f35c4c57e3da632b26ea323af0f5daa3;hb=1254d2cd5f83548f0c2df436b40e4a8c73bb0b0e;hp=195cdc1614e6f8aa9b11103b89e9bca8163b25c2;hpb=b2b08613191a623b6b1ec522ec94b6bf7ca46569;p=nsscash%2Fnsscash.git diff --git a/nss/Makefile b/nss/Makefile index 195cdc1..bbc43ee 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -5,20 +5,43 @@ CFLAGS = -Wall -Wextra -Wconversion CFLAGS += -g -O2 -Werror=array-bounds -Werror=clobbered -Werror=volatile-register-var -Werror=implicit-function-declaration -fstack-protector-strong -Wformat -Werror=format-security CPPFLAGS += -Wdate-time -D_FORTIFY_SOURCE=2 LDFLAGS += -Wl,-z,relro -Wl,-z,now - -# During development -#CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -#LDFLAGS += -fsanitize=address -fsanitize=undefined +# For tests +TEST_CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined +TEST_LDFLAGS += -fsanitize=address -fsanitize=undefined all: libnss_cash.so.2 clean: - rm -f libnss_cash.so.2 + rm -f libnss_cash.so.2 \ + libcash_test.so tests/gr tests/pw \ + tests/group.nsscash tests/passwd.nsscash -libnss_cash.so.2: $(wildcard *.c) $(wildcard *.h) +libnss_cash.so.2 libcash_test.so: $(wildcard *.c) $(wildcard *.h) $(CC) -o $@ -shared -fPIC -Wl,-soname,$@ \ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \ - file.c pw.c search.c \ + file.c gr.c pw.c search.c \ $(LDLIBS) -.PHONY: all clean + +# Tests + +test: tests/gr tests/pw tests/group.nsscash tests/passwd.nsscash + LD_LIBRARY_PATH=. LD_PRELOAD= ./tests/gr + LD_LIBRARY_PATH=. LD_PRELOAD= ./tests/pw + +tests/%: tests/%.c libcash_test.so + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) \ + $(TEST_CFLAGS) $(TEST_LDFLAGS) -L. \ + $< $(LDLIBS) -lcash_test -lasan + +tests/passwd.nsscash: tests/passwd + ../nsscash convert passwd $< $@ +tests/group.nsscash: tests/group + ../nsscash convert group $< $@ + +libcash_test.so: CFLAGS += $(TEST_CFLAGS) +libcash_test.so: CPPFLAGS += -DNSSCASH_GROUP_FILE='"./tests/group.nsscash"' \ + -DNSSCASH_PASSWD_FILE='"./tests/passwd.nsscash"' +libcash_test.so: LDFLAGS += $(TEST_LDFLAGS) + +.PHONY: all clean test