Make infrastructure for better organized user testing
authorKevin Klues <klueska@cs.berkeley.edu>
Wed, 30 Apr 2014 23:20:52 +0000 (16:20 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 5 May 2014 23:23:30 +0000 (16:23 -0700)
Makefile
user/tests/Makefile [new file with mode: 0644]
user/tests/example.c [new file with mode: 0644]
user/tests/include/testing.h [new file with mode: 0644]

index 607596d..f1df434 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,10 @@ MAKEFLAGS += -rR --no-print-directory
 PHONY := all
 all: akaros-kernel
 
+# Export the location of this top level directory
+AKAROS_ROOT = $(CURDIR)
+export AKAROS_ROOT
+
 # Setup dumping ground for object files and any temporary files we need to
 # generate for non-kbuild targets
 OBJDIR ?= obj
diff --git a/user/tests/Makefile b/user/tests/Makefile
new file mode 100644 (file)
index 0000000..0e3c1fe
--- /dev/null
@@ -0,0 +1,51 @@
+ARCH ?= none # catch bugs
+CFLAGS_USER += -g
+CXXFLAGS_USER += -g
+
+SRCDIR := 
+OBJDIR := $(SRCDIR)obj
+INCDIR = $(SRCDIR)include
+
+LDLIBS := -lpthread -lbenchutil -lm -liplib -lndb -lbsd
+
+SRCS_C := $(wildcard $(SRCDIR)*.c)
+SRCS_CPP := $(wildcard $(SRCDIR)*.cc)
+HEADERS := $(shell find $(INCDIR) -name *.h)
+
+EXECS_C = $(patsubst $(SRCDIR)%.c, $(OBJDIR)/%, $(SRCS_C))
+EXECS_CPP = $(patsubst $(SRCDIR)%.cc, $(OBJDIR)/%, $(SRCS_CPP))
+EXECS = $(EXECS_C) $(EXECS_CPP)
+
+STATIC := $(findstring static,$(CFLAGS_USER))
+$(OBJDIR)/%: $(SRCS_C)
+       @echo + cc [TESTS] $<
+       @mkdir -p $(@D)
+       $(Q)$(CC) $(CFLAGS_USER) -I$(INCDIR) -o $@ $< $(LDLIBS)
+       @if [ "$(STATIC)" != "static" ]; then \
+               $(OBJDUMP) -S $@ > $@.asm; \
+               $(NM) -n $@ > $@.sym; \
+       fi
+
+# Note that we don't disassemble CPPs by default, even if they aren't static.
+# The files are pretty large regardless (9MB for a simple stream test asm).
+$(OBJDIR)/%: $(SRCS_CPP)
+       @echo + cc [TESTS] $<
+       @mkdir -p $(@D)
+       $(Q)$(CPP) $(CXXFLAGS_USER) -I$(INCDIR) -o $@ $< $(LDLIBS)
+
+all: $(EXECS)
+
+install: $(EXECS)
+       @mkdir -p $(AKAROS_ROOT)/$(FIRST_KFS_PATH)/bin
+       $(Q)cp -uP $^ $(AKAROS_ROOT)/$(FIRST_KFS_PATH)/bin
+
+uninstall: $(EXECS)
+       @for i in $(EXECS); do \
+               rm -rf $(AKAROS_ROOT)/$(FIRST_KFS_PATH)/bin/$i; \
+       done;
+
+clean:
+       @echo + clean [TESTS]
+       $(Q)rm -rf $(OBJDIR)
+
+.PHONY: $(PHONY)
diff --git a/user/tests/example.c b/user/tests/example.c
new file mode 100644 (file)
index 0000000..f4b6a2b
--- /dev/null
@@ -0,0 +1,3 @@
+#include <testing.h>
+
+void main() {}
diff --git a/user/tests/include/testing.h b/user/tests/include/testing.h
new file mode 100644 (file)
index 0000000..3bbdeb2
--- /dev/null
@@ -0,0 +1,5 @@
+#ifndef TESTS_TESTING_H
+#define TESTS_TESTING_H
+
+#endif // TESTS_TESTING_H
+