Skip to contentSkip to conversation

make check infrastructure

PATCH In review Tony Breeds 1 participant 1 message Dec 9, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 make check infrastructure

----- Forwarded message from Rusty Russell <[email protected]> -----

To: Tony Breeds <[email protected]>
From: Rusty Russell <[email protected]>
Subject: [PATCH 1/3] make check infrastructure
Date: Fri, 09 Dec 2005 16:44:15 +1100

This patch adds a top level "make check" and "make fullcheck" on which we can implement unit tests.

"make -s check" is designed to take much less time than a xen compile, so no excuse for not running it.

"make fullcheck" requires valgrind, and takes longer than make -s check, but is designed for more thorough tests.

Makefile +4 -0
diff -urN --exclude=.hg --exclude='*~' --exclude='*.aux' xen-unstable.hg-mainline/Makefile xen-unstable.hg-check/Makefile
@@ -41,6 +41,10 @@
 test:
 	$(MAKE) -C tools/python test
 
+# Code checking
+check fullcheck:
+	$(MAKE) -C xen $@
+
 # build and install everything into local dist directory
 dist: DESTDIR=$(DISTDIR)/install
 dist: dist-xen dist-kernels dist-tools dist-docs
xen/Makefile +6 -0
diff -urN --exclude=.hg --exclude='*~' --exclude='*.aux' xen-unstable.hg-mainline/xen/Makefile xen-unstable.hg-check/xen/Makefile
@@ -25,6 +25,11 @@
 
 build: $(TARGET).gz
 
+# Code Check
+check fullcheck:
+	$(MAKE) -C test $@
+	$(MAKE) -C common $@
+
 install: $(TARGET).gz
 	[ -d $(DESTDIR)/boot ] || $(INSTALL_DIR) $(DESTDIR)/boot
 	$(INSTALL_DATA) $(TARGET).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_FULLVERSION).gz
@@ -40,6 +45,7 @@
 
 clean: delete-unfresh-files
 	$(MAKE) -C tools clean
+	$(MAKE) -C test clean
 	$(MAKE) -C common clean
 	$(MAKE) -C drivers clean
 	$(MAKE) -C acm clean
xen/common/Makefile +5 -0
diff -urN --exclude=.hg --exclude='*~' --exclude='*.aux' xen-unstable.hg-mainline/xen/common/Makefile xen-unstable.hg-check/xen/common/Makefile
@@ -9,8 +9,13 @@
 common.o: $(OBJS)
 	$(LD) $(LDFLAGS) -r -o common.o $(OBJS)
 
+# Run the code checks
+check fullcheck:
+	$(MAKE) -C test $@
+
 clean:
 	rm -f *.o *~ core
+	$(MAKE) -C test clean
 
 # Object file contains changeset and compiler information.
 kernel.o: $(BASEDIR)/include/xen/compile.h
xen/common/test/Makefile +26 -0
diff -urN --exclude=.hg --exclude='*~' --exclude='*.aux' xen-unstable.hg-mainline/xen/common/test/Makefile xen-unstable.hg-check/xen/common/test/Makefile
@@ -0,0 +1,26 @@
+TEST_C_FILES=$(wildcard *.c)
+TESTS=$(TEST_C_FILES:.c=)
+COV_FLAGS=
+
+include ../../../Config.mk
+
+.PHONY: check
+check: $(TESTS)
+	@echo -n `pwd`:
+	@for f in $(TESTS); do if $(VALGRIND) ./$$f; then echo -n .; else echo $$f failed.; exit 1; fi; done
+	@echo
+
+fullcheck:
+	$(MAKE) VALGRIND="valgrind -q" check
+clean:
+	-rm -f $(TESTS) .*.d *gc*
+
+$(TESTS): ../../test/fake.o
+
+$(TESTS): %: %.c
+	$(HOSTCC) -g -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -I../../test -MD -MF $(@D)/.$(@F).d $(COV_FLAGS) -o $@ $< ../../test/fake.o
+
+coverage: clean 
+	$(MAKE) COV_FLAGS=-fprofile-arcs check
+
+-include .*.d
xen/test/Makefile +13 -0
diff -urN --exclude=.hg --exclude='*~' --exclude='*.aux' xen-unstable.hg-mainline/xen/test/Makefile xen-unstable.hg-check/xen/test/Makefile
@@ -0,0 +1,13 @@
+LINKS:=asm/types.h asm/uaccess.h asm/system.h asm/desc.h xen/config.h xen/types.h xen/errno.h xen/bitmap.h xen/bitops.h xen/lib.h xen/spinlock.h xen/time.h xen/string.h xen/init.h xen/sched.h xen/smp.h xen/perfc.h xen/softirq.h xen/ac_timer.h xen/keyhandler.h xen/mm.h public/acm.h public/acm_ops.h xen/event.h xen/trace.h xen/console.h asm/shadow.h public/sched_ctl.h acm/acm_hooks.h xen/domain.h xen/domain_page.h asm/debugger.h public/dom0_ops.h public/sched.h public/vcpu.h xen/irq.h asm/current.h public/xen.h public/event_chnnel.h
+
+
+clean:
+	rm -f $(LINKS) fake.o
+
+check fullcheck: $(LINKS) fake.o
+
+fake.o: CFLAGS=-Wall -g -I .
+
+$(LINKS):
+	mkdir -p $(dir $@)
+	ln -s `pwd`/fake-include.h $@
Signature · 8 lines
 ccontrol: http://freshmeat.net/projects/ccontrol

----- End forwarded message -----

Yours Tony

   linux.conf.au       http://linux.conf.au/ || http://lca2006.linux.org.au/
   Jan 23-28 2006      The Australian Linux Technical Conference!