Call doInitialization(), releaseMemory(), and doFinalization() for on-the-fly passes...
[oota-llvm.git] / test / Makefile
1 #===- test/Makefile ----------------------------------------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===------------------------------------------------------------------------===#
9
10 LEVEL = ..
11 DIRS  =
12
13 #
14 # Make Dejagnu the default for testing
15 #
16 all:: check-local
17
18 # Include other test rules
19 include Makefile.tests
20
21 #===------------------------------------------------------------------------===#
22 # DejaGNU testing support
23 #===------------------------------------------------------------------------===#
24
25 ifneq ($(GREP_OPTIONS),)
26 $(warning GREP_OPTIONS environment variable may interfere with test results)
27 endif
28
29 ifdef VERBOSE
30 RUNTESTFLAGS := $(VERBOSE)
31 endif
32
33 ifdef TESTSUITE
34 CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE))
35 CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE))
36 RUNTESTFLAGS += --tool $(CLEANED_TESTSUITE)
37 endif
38
39 ifdef VG
40 VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full
41 endif
42
43 IGNORE_TESTS :=
44
45 ifndef RUNLLVM2CPP
46 IGNORE_TESTS += llvm2cpp.exp
47 endif
48
49 IGNORE_TESTS += $(filter-out $(BINDINGS_TO_BUILD:=.exp),$(ALL_BINDINGS:=.exp))
50
51 ifdef IGNORE_TESTS
52 RUNTESTFLAGS += --ignore "$(strip $(IGNORE_TESTS))"
53 endif
54
55 ifneq ($(RUNTEST),)
56 check-local:: site.exp
57         ( ulimit -t 600 ; ulimit -d 512000 ; \
58           ulimit -m 512000 ; ulimit -v 512000 ; \
59           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
60           $(RUNTEST) $(RUNTESTFLAGS) )
61 else
62 check-local:: site.exp
63         @echo "*** dejagnu not found.  Make sure 'runtest' is in your PATH, then reconfigure LLVM."
64 endif
65
66 ifdef TESTONE
67 CLEANED_TESTONE := $(patsubst %/,%,$(TESTONE))
68 CLEANED_TESTONE := $(patsubst test/%,%,$(CLEANED_TESTONE))
69 SUBDIR := $(shell dirname $(CLEANED_TESTONE))
70 TESTPATH := $(LLVM_SRC_ROOT)/test/$(CLEANED_TESTONE)
71 check-one: site.exp $(TCLSH)
72         $(Verb)( echo "source $(LLVM_OBJ_ROOT)/test/site.exp" ; \
73           echo "set subdir $(SUBDIR)" ; \
74           echo "proc pass  { msg } { puts \"PASS: \$$msg\" } "; \
75           echo "proc fail  { msg } { puts \"FAIL: \$$msg\" }" ; \
76           echo "proc xfail { msg } { puts \"XFAIL: \$$msg\" }" ; \
77           echo "proc xpass { msg } { puts \"XPASS: \$$msg\" }" ; \
78           echo "proc verbose args { }" ; \
79           echo "source $(LLVM_SRC_ROOT)/test/lib/llvm.exp" ; \
80           echo "RunLLVMTests $(TESTPATH)" ) | \
81         ( ulimit -t 600 ; ulimit -d 512000 ; \
82           ulimit -m 512000 ; ulimit -v 512000 ; \
83           PATH="$(LLVMToolDir):$(LLVM_SRC_ROOT)/test/Scripts:$(PATH)" \
84           $(TCLSH) )
85 endif
86
87 clean::
88         $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print`
89
90 # dsymutil is used on the Darwin to manipulate DWARF debugging information.
91 ifeq ($(OS),Darwin)
92 DSYMUTIL=dsymutil
93 else
94 DSYMUTIL=true
95 endif
96 ifdef TargetCommonOpts
97 BUGPOINT_TOPTS="-gcc-tool-args $(TargetCommonOpts)"
98 else
99 BUGPOINT_TOPTS=""
100 endif
101
102 FORCE:
103
104 site.exp: FORCE
105         @echo 'Making a new site.exp file...'
106         @echo '## these variables are automatically generated by make ##' >site.tmp
107         @echo '# Do not edit here.  If you wish to override these values' >>site.tmp
108         @echo '# edit the last section' >>site.tmp
109         @echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
110         @echo 'set TARGETS_TO_BUILD "$(TARGETS_TO_BUILD)"' >> site.tmp
111         @echo 'set llvmgcc_langs "$(LLVMGCC_LANGS)"' >> site.tmp
112         @echo 'set llvmgcc_version "$(LLVMGCC_VERSION)"' >> site.tmp
113         @echo 'set prcontext "$(TCLSH) $(LLVM_SRC_ROOT)/test/Scripts/prcontext.tcl"' >> site.tmp
114         @echo 'set llvmtoolsdir "$(ToolDir)"' >>site.tmp
115         @echo 'set llvmlibsdir "$(LibDir)"' >>site.tmp
116         @echo 'set srcroot "$(LLVM_SRC_ROOT)"' >>site.tmp
117         @echo 'set objroot "$(LLVM_OBJ_ROOT)"' >>site.tmp
118         @echo 'set srcdir "$(LLVM_SRC_ROOT)/test"' >>site.tmp
119         @echo 'set objdir "$(LLVM_OBJ_ROOT)/test"' >>site.tmp
120         @echo 'set gccpath "$(CC)"' >>site.tmp
121         @echo 'set gxxpath "$(CXX)"' >>site.tmp
122         @echo 'set compile_c "' $(CC) $(CPP.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >>site.tmp
123         @echo 'set compile_cxx "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) -c '"' >> site.tmp
124         @echo 'set link "' $(CXX) $(CPP.Flags) $(CXX.Flags) $(TargetCommonOpts) $(CompileCommonOpts) $(LD.Flags) '"' >>site.tmp
125         @echo 'set llvmgcc "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
126         @echo 'set llvmgxx "$(LLVMGCC) $(TargetCommonOpts) $(EXTRA_OPTIONS)"' >> site.tmp
127         @echo 'set llvmgccmajvers "$(LLVMGCC_MAJVERS)"' >> site.tmp
128         @echo 'set bugpoint_topts $(BUGPOINT_TOPTS)' >> site.tmp
129         @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp
130         @echo 'set ocamlc "$(OCAMLC) -cc $(CXX) -I $(LibDir)/ocaml"' >> site.tmp
131         @echo 'set valgrind "$(VALGRIND)"' >> site.tmp
132         @echo 'set grep "$(GREP)"' >>site.tmp
133         @echo 'set gas "$(GAS)"' >>site.tmp
134         @echo 'set llvmdsymutil "$(DSYMUTIL)"' >>site.tmp
135         @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
136         @test ! -f site.exp || \
137         sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
138         @-rm -f site.bak
139         @test ! -f site.exp || mv site.exp site.bak
140         @mv site.tmp site.exp