mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-07 09:55:08 -05:00
test: add support for unit testing
This commit is contained in:
42
test/unit/Makefile.in
Normal file
42
test/unit/Makefile.in
Normal file
@@ -0,0 +1,42 @@
|
||||
TEST_WRAPPER =
|
||||
CHRONY_SRCDIR = ../..
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = -I$(CHRONY_SRCDIR) @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@ @LIBS@ @EXTRA_LIBS@
|
||||
|
||||
SHARED_OBJS = test.o
|
||||
|
||||
TEST_OBJS := $(sort $(patsubst %.c,%.o,$(wildcard *.c)))
|
||||
TESTS := $(patsubst %.o,%.test,$(filter-out $(SHARED_OBJS),$(TEST_OBJS)))
|
||||
|
||||
FILTER_OBJS = %/main.o %/client.o %/getdate.o
|
||||
CHRONY_OBJS := $(filter-out $(FILTER_OBJS),$(wildcard $(CHRONY_SRCDIR)/*.o))
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
%.test: %.o $(SHARED_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(CHRONY_OBJS:%/$*.o=) $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
check: $(TESTS)
|
||||
@ret=0; \
|
||||
for t in $^; do \
|
||||
$(TEST_WRAPPER) ./$$t || ret=1; \
|
||||
done; \
|
||||
exit $$ret
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TESTS)
|
||||
rm -rf .deps
|
||||
|
||||
.deps:
|
||||
@mkdir .deps
|
||||
|
||||
.deps/%.d: %.c | .deps
|
||||
@$(CC) -MM $(CPPFLAGS) -MT '$(<:%.c=%.o) $@' $< -o $@
|
||||
|
||||
-include $(TEST_OBJS:%.o=.deps/%.d)
|
||||
Reference in New Issue
Block a user