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 10LEVEL = .. 11DIRS = 12 13all:: check-local 14 15# Include other test rules 16include Makefile.tests 17 18#===------------------------------------------------------------------------===# 19# DejaGNU testing support 20#===------------------------------------------------------------------------===# 21 22ifneq ($(GREP_OPTIONS),) 23$(warning GREP_OPTIONS environment variable may interfere with test results) 24endif 25 26ifdef VERBOSE 27LIT_ARGS := -v 28else 29LIT_ARGS := -s -v 30endif 31 32ifdef TESTSUITE 33LIT_TESTSUITE := $(TESTSUITE) 34CLEANED_TESTSUITE := $(patsubst %/,%,$(TESTSUITE)) 35CLEANED_TESTSUITE := $(patsubst test/%,%,$(CLEANED_TESTSUITE)) 36else 37LIT_TESTSUITE := . 38endif 39 40ifdef VG 41VALGRIND := valgrind --tool=memcheck --quiet --trace-children=yes --error-exitcode=3 --leak-check=full $(VALGRIND_EXTRA_ARGS) 42endif 43 44# Check what to run for -all. 45LIT_ALL_TESTSUITES := $(LIT_TESTSUITE) 46 47extra-site-cfgs:: 48.PHONY: extra-site-cfgs 49 50ifneq ($(strip $(filter check-local-all,$(MAKECMDGOALS))),) 51ifndef TESTSUITE 52ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/Makefile && echo OK), OK) 53LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/test 54 55# Force creation of Clang's lit.site.cfg. 56clang-site-cfg: FORCE 57 $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/test lit.site.cfg Unit/lit.site.cfg 58extra-site-cfgs:: clang-site-cfg 59endif 60 61ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/Makefile && echo OK), OK) 62LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test 63 64# Force creation of Clang Tools' lit.site.cfg. 65clang-tools-site-cfg: FORCE 66 $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/clang/tools/extra/test lit.site.cfg 67extra-site-cfgs:: clang-tools-site-cfg 68endif 69 70ifeq ($(shell test -f $(PROJ_OBJ_DIR)/../tools/polly/Makefile && echo OK), OK) 71LIT_ALL_TESTSUITES += $(PROJ_OBJ_DIR)/../tools/polly/test 72 73# Force creation of Polly's lit.site.cfg. 74polly-tools-site-cfg: FORCE 75 $(MAKE) -C $(PROJ_OBJ_DIR)/../tools/polly/test lit.site.cfg 76extra-site-cfgs:: polly-tools-site-cfg 77endif 78endif 79endif 80 81# ulimits like these are redundantly enforced by the buildbots, so 82# just removing them here won't work. 83# Both AuroraUX & Solaris do not have the -m flag for ulimit 84ifeq ($(HOST_OS),SunOS) 85ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ; 86else # !SunOS 87ifeq ($(HOST_OS),AuroraUX) 88ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -v 512000 ; 89else # !AuroraUX 90# Newer versions of python try to allocate an insane amount of address space for 91# its thread-local storage, don't set a limit here. 92# When -v is not used, then -s has to be used to limit the stack size. 93# FIXME: Those limits should be enforced by lit instead of globally. 94ULIMIT=ulimit -t 600 ; ulimit -d 512000 ; ulimit -m 512000 ; ulimit -s 8192 ; 95endif # AuroraUX 96endif # SunOS 97 98check-local:: lit.site.cfg Unit/lit.site.cfg 99 ( $(ULIMIT) \ 100 $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_TESTSUITE) ) 101 102# This is a legacy alias dating from when both DejaGNU and lit were in use. 103check-local-lit:: check-local 104 105check-local-all:: lit.site.cfg Unit/lit.site.cfg extra-site-cfgs 106 ( $(ULIMIT) \ 107 $(PYTHON) $(LLVM_SRC_ROOT)/utils/lit/lit.py $(LIT_ARGS) $(LIT_ALL_TESTSUITES) ) 108 109clean:: 110 $(RM) -rf `find $(LLVM_OBJ_ROOT)/test -name Output -type d -print` 111 112ifneq ($(OCAMLOPT),) 113CC_FOR_OCAMLOPT := $(shell $(OCAMLOPT) -config | grep native_c_compiler | sed -e 's/native_c_compiler: //') 114CXX_FOR_OCAMLOPT := $(subst gcc,g++,$(CC_FOR_OCAMLOPT)) 115endif 116 117FORCE: 118 119ifeq ($(DISABLE_ASSERTIONS),1) 120ENABLE_ASSERTIONS=0 121else 122ENABLE_ASSERTIONS=1 123endif 124 125# Derive whether or not LTO is enabled by checking the extra options. 126LTO_IS_ENABLED := 0 127ifneq ($(findstring -flto,$(CompileCommonOpts)),) 128LTO_IS_ENABLED := 1 129else 130ifneq ($(findstring -O4,$(CompileCommonOpts)),) 131LTO_IS_ENABLED := 1 132endif 133endif 134 135lit.site.cfg: FORCE 136 @echo "Making LLVM 'lit.site.cfg' file..." 137 @$(ECHOPATH) s=@LLVM_HOST_TRIPLE@=$(HOST_TRIPLE)=g > lit.tmp 138 @$(ECHOPATH) s=@TARGET_TRIPLE@=$(TARGET_TRIPLE)=g >> lit.tmp 139 @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g >> lit.tmp 140 @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> lit.tmp 141 @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> lit.tmp 142 @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> lit.tmp 143 @$(ECHOPATH) s=@SHLIBEXT@=$(SHLIBEXT)=g >> lit.tmp 144 @$(ECHOPATH) s=@PYTHON_EXECUTABLE@=$(PYTHON)=g >> lit.tmp 145 @$(ECHOPATH) s=@OCAMLOPT@=$(OCAMLOPT) -cc $(subst *,'\\\"',*$(subst =,"\\=",$(CXX_FOR_OCAMLOPT))*) -I $(LibDir)/ocaml=g >> lit.tmp 146 @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> lit.tmp 147 @$(ECHOPATH) s=@ENABLE_ASSERTIONS@=$(ENABLE_ASSERTIONS)=g >> lit.tmp 148 @$(ECHOPATH) s=@LTO_IS_ENABLED@=$(LTO_IS_ENABLED)=g >> lit.tmp 149 @$(ECHOPATH) s=@TARGETS_TO_BUILD@=$(TARGETS_TO_BUILD)=g >> lit.tmp 150 @$(ECHOPATH) s=@LLVM_BINDINGS@=$(BINDINGS_TO_BUILD)=g >> lit.tmp 151 @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> lit.tmp 152 @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp 153 @$(ECHOPATH) s=@HAVE_LIBZ@=$(HAVE_LIBZ)=g >> lit.tmp 154 @sed -f lit.tmp $(PROJ_SRC_DIR)/lit.site.cfg.in > $@ 155 @-rm -f lit.tmp 156 157Unit/lit.site.cfg: $(PROJ_OBJ_DIR)/Unit/.dir FORCE 158 @echo "Making LLVM unittest 'lit.site.cfg' file..." 159 @$(ECHOPATH) s=@LLVM_SOURCE_DIR@=$(LLVM_SRC_ROOT)=g > unit.tmp 160 @$(ECHOPATH) s=@LLVM_BINARY_DIR@=$(LLVM_OBJ_ROOT)=g >> unit.tmp 161 @$(ECHOPATH) s=@LLVM_TOOLS_DIR@=$(ToolDir)=g >> unit.tmp 162 @$(ECHOPATH) s=@LLVM_BUILD_MODE@=$(BuildMode)=g >> unit.tmp 163 @$(ECHOPATH) s=@ENABLE_SHARED@=$(ENABLE_SHARED)=g >> unit.tmp 164 @$(ECHOPATH) s=@SHLIBDIR@=$(SharedLibDir)=g >> unit.tmp 165 @$(ECHOPATH) s=@SHLIBPATH_VAR@=$(SHLIBPATH_VAR)=g >> unit.tmp 166 @$(ECHOPATH) s=@HOST_OS@=$(HOST_OS)=g >> unit.tmp 167 @$(ECHOPATH) s=@HOST_ARCH@=$(HOST_ARCH)=g >> lit.tmp 168 @sed -f unit.tmp $(PROJ_SRC_DIR)/Unit/lit.site.cfg.in > $@ 169 @-rm -f unit.tmp 170