[llvm-commits] [poolalloc] r106176 - /poolalloc/trunk/test/Makefile

Will Dietz wdietz2 at illinois.edu
Wed Jun 16 16:48:42 PDT 2010


Author: wdietz2
Date: Wed Jun 16 18:48:42 2010
New Revision: 106176

URL: http://llvm.org/viewvc/llvm-project?rev=106176&view=rev
Log:
poolalloc: added support for running dejagnu tests

Modified:
    poolalloc/trunk/test/Makefile

Modified: poolalloc/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/Makefile?rev=106176&r1=106175&r2=106176&view=diff
==============================================================================
--- poolalloc/trunk/test/Makefile (original)
+++ poolalloc/trunk/test/Makefile Wed Jun 16 18:48:42 2010
@@ -7,6 +7,8 @@
 
 # The default target in this directory is the test:: target
 test::
+#Eventually we'll want to automatically run the dejagnu tests too
+#test:: unit
 
 LEVEL = ..
 include $(LEVEL)/Makefile.common
@@ -318,3 +320,80 @@
                    report report.csv)
 	@printf "\a"; sleep 1; printf "\a"; sleep 1; printf "\a"
 
+##===----------------------------------------------------------------------===##
+# Unit tests
+##===----------------------------------------------------------------------===##
+
+#DISCLAIMER
+#I would prefer being able to do something like above, by setting
+#some "PROJECT_DIR" variable, but alas I don't see that for the dejagnu
+#test framework.  So for now we hijack the existing framework as much as
+#possible--feel free to replace this if you know a cleaner way.
+
+.PHONY: check_runtest unit
+
+#Path to dejagnu's runtest binary.
+RUNTEST=runtest
+
+#Figure out what our configuration is
+#Better way?
+ifeq ($(ENABLE_OPTIMIZED),1)
+CONFIGURATION := "Release"
+else
+CONFIGURATION := "Debug"
+endif
+
+# Pathname to poolalloc object tree
+PADIR   := $(LLVM_OBJ_ROOT)/projects/poolalloc
+# Pathame to the DSA pass dynamic library
+DSA_SO   := $(PADIR)/$(CONFIGURATION)/lib/libLLVMDataStructure$(SHLIBEXT)
+
+DSAOPT := $(PROJ_OBJ_ROOT)/test/tools/dsaopt
+
+TOOLS= $(DSAOPT)
+
+#Check that our RUNTEST variable points to a runtest we can use
+check_runtest:
+	@which runtest; \
+	if [ $$? -ne 0 ]; then \
+		echo \"$(RUNTEST)\" is not valid. Please put runtest on your PATH; \
+		echo or set the RUNTEST variable correctly.; \
+		exit 1; \
+	fi
+
+#Grab site.exp per normal llvm testing, but modify it to run in this project
+site.exp:
+	@echo "Generating site.exp..."
+	@make -C $(LLVM_OBJ_ROOT)/test site.exp
+	@cp $(LLVM_OBJ_ROOT)/test/site.exp     site.tmp
+	@echo "set srcdir $(PROJ_SRC_DIR)"  >> site.tmp
+	@echo "set srcroot $(PROJ_SRC_DIR)" >> site.tmp
+	@echo "set objdir $(PROJ_OBJ_DIR)"  >> site.tmp
+	@echo "set objroot $(PROJ_OBJ_DIR)" >> site.tmp
+	@cp site.tmp $@
+
+#wrapper script for 'opt' so we can avoid manually loading the dsa lib
+$(DSAOPT):
+	@mkdir -p `dirname $@`
+	@echo "#!/bin/sh" >> $@.tmp
+	@echo 'opt -load $(DSA_SO) $$@' >> $@.tmp
+	@chmod +x $@.tmp
+	@mv $@.tmp $@
+
+#We need this locally, might be able to avoid this by modifying site.exp
+llvm.exp:
+	cp $(LLVM_SRC_ROOT)/test/lib/llvm.exp $@
+
+#Build up the runtest command by making sure useful tools are on its path
+RUNTEST_CMD = \
+	PATH=$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(LLVMGCCDIR)/bin:$(PATH):$(PROJ_OBJ_ROOT)/test/tools \
+	$(RUNTEST)
+
+#Run the dejagnu tests for this project
+unit: check_runtest site.exp llvm.exp $(TOOLS)
+	$(RUNTEST_CMD)
+
+clean::
+	-$(RM) -rf  `find $(PROJ_OBJ_DIR) -name Output -type d -print`
+	-$(RM) $(PROJ_OBJ_ROOT)/test/site.exp $(PROJ_OBJ_ROOT)/test/llvm.exp
+	-$(RM) -rf tools





More information about the llvm-commits mailing list