1# -*- mode: makefile-gmake -*- 2-include petscdir.mk 3 4.SUFFIXES: .F .F90 .f90 ${SUFFIXES} .PETSc .C .cc .cpp .cxx .r .rm .so .html .ad .m .tex .make .fig .svg .eps .pdf .jpg .png .dvi .ps .F95 .f95 .fiat .cu .kokkos.cxx .raja.cxx .hip.cpp .sycl.cxx 5 6CONFIGDIR := $(PETSC_DIR)/config 7 8# TESTSRCDIR is always relative to gmakefile.test 9# This must be before includes 10mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) 11TESTSRCDIR := $(dir $(mkfile_path))src 12 13-include $(PETSC_DIR)/$(PETSC_ARCH)/lib/petsc/conf/petscvariables 14-include $(PETSC_DIR)/lib/petsc/conf/variables 15 16TESTDIR ?= ./$(PETSC_ARCH)/tests 17MODDIR := $(PETSC_DIR)/$(PETSC_ARCH)/include 18TESTLOGTAPFILE ?= $(TESTDIR)/test_$(PETSC_ARCH)_tap.log 19TESTLOGERRFILE ?= $(TESTDIR)/test_$(PETSC_ARCH)_err.log 20EXAMPLESDIR := $(TESTSRCDIR) 21 22pkgs := sys vec mat dm ksp snes ts tao 23 24petscconf := $(PETSC_DIR)/$(PETSC_ARCH)/include/petscconf.h 25petscvariables := $(PETSC_DIR)/$(PETSC_ARCH)/lib/petsc/conf/petscvariables 26generatedtest := $(TESTDIR)/testfiles 27 28.SECONDEXPANSION: # to expand $$(@D)/.DIR 29 30TESTFLAGS := # Initialize as simple variable 31 32#workaround old cygwin versions 33ifeq ($(PETSC_CYGWIN_BROKEN_PIPE),1) 34ifeq ($(shell basename $(AR)),ar) 35 V ?=1 36endif 37endif 38V ?= $(if $(findstring s,$(MAKEFLAGS)),0) 39ifeq ($(V),) # Default 40 quiet_HELP := "Use \"$(MAKE) V=1\" to see verbose compile lines, \"$(MAKE) V=0\" to suppress.\n" 41 quiet = @printf $(quiet_HELP)$(eval quiet_HELP:=)" %10s %s\n" "$1$2" "$@"; $($1) 42 quiettest = @printf " %10s %s\n" "TEST" "$(@:$(TESTDIR)/counts/%.counts=%)"; 43else ifeq ($(V),0) # Suppress entire command 44 quiet = @$($1) 45 quiettest = @ 46 TESTFLAGS += -o err_only 47else # Show the full command line 48 quiet = $($1) 49 quiettest = 50 TESTFLAGS += -v 51endif 52 53ifeq ($(FORCE),1) 54 TESTFLAGS += -f # force test execution 55endif 56ifeq ($(CUDAMEMCHECK),1) 57 TESTFLAGS += -U # Add cuda-memcheck option to the flags 58endif 59ifeq ($(VALGRIND),1) 60 TESTFLAGS += -V # Add valgrind option to the flags 61endif 62ifeq ($(DEBUG),1) 63 TESTFLAGS += -d # Launch test in debugger 64endif 65ifeq ($(REPLACE),1) 66 TESTFLAGS += -m # Replace results by passing -m to petscdiff 67endif 68ifeq ($(OUTPUT),1) 69 TESTFLAGS += -o 'err_only' # Show only the errors on stdout 70endif 71ifeq ($(ALT),1) 72 TESTFLAGS += -M # Replace alt files by passing -M to petscdiff 73endif 74PRINTONLY ?= 0 75ifeq ($(PRINTONLY),1) 76 TESTFLAGS += -p # Pass -p to petscdiff to print only command 77endif 78ifeq ($(DIFF_NUMBERS),1) 79 TESTFLAGS += -j # Pass -j to petscdiff to diff the actual numbers 80endif 81ifdef OPTIONS 82 TESTFLAGS += -a '$(OPTIONS)' # override arguments 83endif 84ifdef EXTRA_OPTIONS 85 TESTFLAGS += -e '$(EXTRA_OPTIONS)' # add extra arguments 86endif 87ifdef NP 88 TESTFLAGS += -n $(NP) # set number of processes 89endif 90# Override the default timeout that may be found at the top of config/petsc_harness.sh 91# This must be an integer. It is given in seconds. 92ifdef TIMEOUT 93 TESTFLAGS += -t $(TIMEOUT) # Override the default timeout 94endif 95 96$(generatedtest) : $(petscconf) $(petscvariables) $(CONFIGDIR)/gmakegentest.py $(TESTDIR)/.DIR | $$(@D)/.DIR 97 $(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR) 98 99ifneq ($(filter-out clean check info,$(MAKECMDGOALS:clean%=clean)),) 100include $(generatedtest) 101endif 102 103ifeq ($(PETSC_LANGUAGE),CXXONLY) 104 cc_name := CXX 105else 106 cc_name := CC 107endif 108 109PETSC_COMPILE.c = $(call quiet,$(cc_name)) -c $(PCC_FLAGS) $($(CLANGUAGE)FLAGS) $(CCPPFLAGS) $(C_DEPFLAGS) 110PETSC_COMPILE.cxx = $(call quiet,CXX) -c $(CXX_FLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(CXX_DEPFLAGS) 111PETSC_COMPILE.cu = $(call quiet,CUDAC) -c $(MPICXX_INCLUDES) $(CUDAC_FLAGS) $(CUFLAGS) --compiler-options="${PETSC_CCPPFLAGS} $(CUDACPPFLAGS) $(CUDA_CXXFLAGS)" 112PETSC_COMPILE.hip.cpp = $(call quiet,HIPC) -c $(MPICXX_INCLUDES) $(HIPC_FLAGS) $(HIPPP_FLAGS) $(HIPFLAGS) $(HIPPPFLAGS) $(HIPOPTFLAGS) $(HIPC_DEPFLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(HIP_DEPFLAGS) 113PETSC_COMPILE.sycl.cxx = $(call quiet,SYCLC) -c $(MPICXX_INCLUDES) $(SYCLC_FLAGS) $(SYCLPP_FLAGS) $(SYCLFLAGS) $(SYCLPPFLAGS) $(SYCLOPTFLAGS) $(CXXFLAGS) $(CXXCPPFLAGS) $(SYCL_DEPFLAGS) 114PETSC_GENDEPS.cu = $(call quiet,CUDAC,.dep) --generate-dependencies --output-directory=$(@D) $(MPICXX_INCLUDES) $(CUDAC_FLAGS) $(CUFLAGS) --compiler-options="${PETSC_CCPPFLAGS} $(CUDA_CXXFLAGS)" 115PETSC_COMPILE.F = $(call quiet,FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) 116 117ifneq ($(KOKKOS_USE_CUDA_COMPILER),) 118 # Kokkos requires nvcc to be in PATH and the C++ compiler to be given in an environmental variable 119 PETSC_COMPILE.kokkos.cxx = PATH=`dirname $(CUDAC)`:$(PATH) NVCC_WRAPPER_DEFAULT_COMPILER="$(CUDA_CXX)" $(KOKKOS_BIN)/nvcc_wrapper --expt-extended-lambda -c $(CUDAC_FLAGS) ${PETSC_CCPPFLAGS} $(CUDACPPFLAGS) $(CUDA_CXXFLAGS) $(MPICXX_INCLUDES) 120 PETSC_LINK.kokkos.cxx = PATH=`dirname $(CUDAC)`:$(PATH) NVCC_WRAPPER_DEFAULT_COMPILER="$(CUDA_CXX)" $(KOKKOS_BIN)/nvcc_wrapper --expt-extended-lambda $(CUDAC_FLAGS) $(MPICXX_INCLUDES) ${PETSC_CCPPFLAGS} $(CUDA_CXXFLAGS) $(CUDA_CXXLIBS) $(MPICXX_LIBS) $(LDFLAGS) 121else ifneq ($(KOKKOS_USE_HIP_COMPILER),) 122 PETSC_COMPILE.kokkos.cxx = $(PETSC_COMPILE.hip.cpp) 123 PETSC_LINK.kokkos.cxx = $(HIPC) $(HIPFLAGS) $(CXXFLAGS) $(PETSC_CCPPFLAGS) $(CPPFLAGS) $(LDFLAGS) $(MPICXX_INCLUDES) $(MPICXX_LIBS) 124else ifneq ($(KOKKOS_USE_SYCL_COMPILER),) 125 PETSC_COMPILE.kokkos.cxx = $(PETSC_COMPILE.sycl.cxx) 126 PETSC_LINK.kokkos.cxx = $(SYCLC) $(SYCLFLAGS) $(CXXFLAGS) $(PETSC_CCPPFLAGS) $(CPPFLAGS) $(LDFLAGS) $(MPICXX_INCLUDES) $(MPICXX_LIBS) 127else 128 PETSC_COMPILE.kokkos.cxx = $(PETSC_COMPILE.cxx) 129 PETSC_LINK.kokkos.cxx = $(CXXLINKER) $(CXXFLAGS) $(PETSC_CCPPFLAGS) $(CPPFLAGS) $(LDFLAGS) 130endif 131 132ifneq ($(RAJA_USE_CUDA_COMPILER),) 133 PETSC_COMPILE.raja.cxx = ${CUDAC} $(MPICXX_INCLUDES) ${CUDAC_FLAGS} ${CUFLAGS} -x cu -Xcudafe "--display_error_number" -c --compiler-options="${PETSC_CCPPFLAGS} ${PETSC_CC_INCLUDES} ${CUDA_CXXFLAGS}" --expt-extended-lambda --expt-relaxed-constexpr 134else 135 PETSC_COMPILE.raja.cxx = ${CXX} -o $*.o -c ${CXX_FLAGS} ${CXXFLAGS} ${CXXCPPFLAGS} 136endif 137 138testlangs := c cu cxx F F90 kokkos.cxx hip.cpp sycl.cxx raja.cxx 139$(foreach lang, $(testlangs), $(eval \ 140 testexe.$(lang) = $(foreach pkg, $(pkgs), $(testsrcs-$(pkg).$(lang):%.$(lang)=$(TESTDIR)/%)))) 141concattestlang = $(foreach lang, $(2), $(testsrcs-$(1).$(lang):%.$(lang)=$(TESTDIR)/%.o)) 142testsrcs.o := $(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),$(testlangs))) 143testsrcs-rel := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), $(testsrcs-$(pkg).$(lang)))) 144testsrcs := $(foreach sfile, $(testsrcs-rel), $(TESTSRCDIR)/$(sfile)) 145 146# workaround win32fe failure 147ifneq (,$(findstring win32fe,$(call quiet,$(cc_name)))) 148$(TESTDIR)/ts/tutorials/multirate/ex6: | $(TESTDIR)/ts/tutorials/multirate/ex5 149$(TESTDIR)/ts/tutorials/multirate/ex8: | $(TESTDIR)/ts/tutorials/multirate/ex6 150endif 151 152# Refresh testfiles when sources change, but don't balk if the source file is nonexistent (deleted) 153$(generatedtest) : $(testsrcs) 154$(testsrcs) : 155 156$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.c | $$(@D)/.DIR 157 $(PETSC_COMPILE.c) $(abspath $<) -o $@ 158 159$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.kokkos.cxx | $$(@D)/.DIR 160 $(PETSC_COMPILE.kokkos.cxx) $(abspath $<) -o $@ 161 162$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.sycl.cxx | $$(@D)/.DIR 163 $(PETSC_COMPILE.sycl.cxx) $(abspath $<) -o $@ 164 165$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.raja.cxx | $$(@D)/.DIR 166 $(PETSC_COMPILE.raja.cxx) $(abspath $<) -o $@ 167 168$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cxx | $$(@D)/.DIR 169 $(PETSC_COMPILE.cxx) $(abspath $<) -o $@ 170 171$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cu | $$(@D)/.DIR 172 $(PETSC_COMPILE.cu) $(abspath $<) -o $@ # Compile first so that if there is an error, it comes from a normal compile 173 @$(PETSC_GENDEPS.cu) $(abspath $<) -o $(@:%.o=%.d) # Generate the dependencies for later 174 175$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.hip.cpp | $$(@D)/.DIR 176 $(PETSC_COMPILE.hip.cpp) $(abspath $<) -o $@ 177 178# Test modules go in the same directory as the target *.o 179TESTMODDIR = $(@D) 180FCMOD = cd 181$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F | $$(@D)/.DIR 182ifeq ($(FC_MODULE_OUTPUT_FLAG),) 183 $(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@) 184else 185 $(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR) 186endif 187 -@$(GFORTRAN_DEP_CLEANUP) 188 189$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F90 | $$(@D)/.DIR 190ifeq ($(FC_MODULE_OUTPUT_FLAG),) 191 $(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@) 192else 193 $(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR) 194endif 195 -@$(GFORTRAN_DEP_CLEANUP) 196 197# This is a hack to fix a broken gfortran. 198define GFORTRAN_DEP_CLEANUP 199 if test -e "$(@:%.o=%.d)" && head -1 "$(@:%.o=%.d)" | fgrep -q -v : ; then\ 200 echo "$(@): \\" > $(@:%.o=%.dtemp) ; \ 201 tr '\n' '@' < $(@:%.o=%.d) | cut -d: -f2- | tr '@' '\n' >> $(@:%.o=%.dtemp) ; \ 202 mv $(@:%.o=%.dtemp) $(@:%.o=%.d); \ 203 fi 204endef 205 206# link line constructed differently for gmakefile vs gmakefile.test invocation 207ifeq ($(libpetscall),) 208PETSC_TEST_LIB = $(PETSC_LIB) 209else 210PETSC_TEST_LIB = $(C_SH_LIB_PATH) $(PETSC_EXTERNAL_LIB_BASIC) 211endif 212 213# manually list some some library dependencies to check for circular dependencies 214$(TESTDIR)/sys/tests/ex9: PETSC_TEST_LIB = $(PETSC_SYS_LIB) 215$(TESTDIR)/vec/vec/tests/ex1: PETSC_TEST_LIB = $(PETSC_VEC_LIB) 216$(TESTDIR)/mat/tests/ex1: PETSC_TEST_LIB = $(PETSC_MAT_LIB) 217$(TESTDIR)/dm/tests/ex1: PETSC_TEST_LIB = $(PETSC_DM_LIB) 218$(TESTDIR)/ksp/ksp/tests/ex1: PETSC_TEST_LIB = $(PETSC_KSP_LIB) 219$(TESTDIR)/snes/tests/ex1: PETSC_TEST_LIB = $(PETSC_SNES_LIB) 220$(TESTDIR)/ts/tests/ex2: PETSC_TEST_LIB = $(PETSC_TS_LIB) 221$(TESTDIR)/tao/tutorials/ex1: PETSC_TEST_LIB = $(PETSC_TAO_LIB) 222 223# MACOS FIREWALL HANDLING 224# - if run with MACOS_FIREWALL=1 225# (automatically set in $PETSC_ARCH/lib/petsc/conf/petscvariables if configured --with-macos-firewall-rules), 226# ensure mpiexec and test executable is on firewall list 227# 228ifeq ($(MACOS_FIREWALL),1) 229FW := /usr/libexec/ApplicationFirewall/socketfilterfw 230# There is no reliable realpath command in macOS without need for 3rd party tools like homebrew coreutils 231# Using Python's realpath seems like the most robust way here 232realpath-py = $(shell $(PYTHON) -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' $(1)) 233# 234define macos-firewall-register 235 @APP=$(call realpath-py, $(1)); \ 236 if ! sudo -n true 2>/dev/null; then printf "Asking for sudo password to add new firewall rule for\n $$APP\n"; fi; \ 237 sudo $(FW) --remove $$APP --add $$APP --blockapp $$APP 238endef 239endif 240# 241macos-firewall-register-mpiexec: 242 -$(call macos-firewall-register, $(MPIEXEC)) 243 244# Test executables 245$(testexe.F) $(testexe.F90) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 246 $(call quiet,FLINKER) -o $@ $^ $(PETSC_TEST_LIB) 247 -$(call macos-firewall-register,$@) 248 249$(testexe.c) $(testexe.cu) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 250 $(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB) 251 -$(call macos-firewall-register,$@) 252 253$(testexe.hip.cpp) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 254 $(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB) 255 -$(call macos-firewall-register,$@) 256 257$(testexe.kokkos.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 258 $(call quiet,PETSC_LINK.kokkos.cxx) -o $@ $^ $(PETSC_TEST_LIB) 259 -$(call macos-firewall-register,$@) 260 261$(testexe.raja.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 262 $(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB) 263 -$(call macos-firewall-register,$@) 264 265$(testexe.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 266 $(call quiet,CXXLINKER) -o $@ $^ $(PETSC_TEST_LIB) 267 -$(call macos-firewall-register,$@) 268 269# Fortran source files need petsc*.mod, which isn't explicitly managed in the makefile. 270$(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),F F90)) : $(libpetscall) 271 272# Testing convenience targets 273.PHONY: test pre-clean 274 275test: report_tests 276 277pre-clean: 278 @$(RM) -rf $(TESTDIR)/counts $(TESTLOGTAPFILE) $(TESTLOGERRFILE) 279 @touch $(TESTLOGTAPFILE) $(TESTLOGERRFILE) 280 @echo "Using MAKEFLAGS:" ${MAKEFLAGS} 281 282check-test-errors: 283 @grep '^not ok' $(TESTLOGTAPFILE) | grep -v 'Exceeded timeout' | tee $(TESTDIR)/allgtests-tap-err.log 284 @test ! -s $(TESTDIR)/allgtests-tap-err.log 285 286.PHONY: $(foreach pkg, $(pkgs), test-$(pkg) $(foreach lang, $(testlangs), test-$(pkg).$(lang) test-rm-$(pkg).$(lang))) 287testpkgs := $(foreach pkg, $(pkgs), test-$(pkg)) 288# Targets to run tests in test-$pkg.$lang and delete the executables, language by language 289$(testpkgs) : test-% : $(foreach lang, $(testlangs), test-rm-%.$(lang)) 290# List of raw test run targets 291alltesttargets := $(foreach tp, $(testpkgs), $(foreach lang, $(testlangs), $($(tp).$(lang)))) 292 293# Run targets 294$(alltesttargets) : % : $(TESTDIR)/counts/%.counts 295.PHONY: $(alltesttargets) 296 297$(TESTDIR)/counts/%.counts : 298 $(quiettest) $< $(TESTFLAGS) 299 300# Targets to run tests and remove executables, by package-lang pairs. 301# Run the tests in each batch using recursive invocation of make because 302# we need all of them to complete before removing the executables. Make 303# doesn't guarantee an exploration order for the graph. Only recursive 304# if there is something to be done. 305alltest-rm := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), test-rm-$(pkg).$(lang))) 306$(alltest-rm) : test-rm-% : test-% 307ifneq ($(NO_RM),1) 308 $(call quiet,RM) $(addprefix $(TESTDIR)/,$(basename $($(@:test-rm-%=testsrcs-%)))) 309endif 310 311# Remove intermediate .o files 312# This only removes the files at the end which is insufficient 313#.INTERMEDIATE: $(testsrcs.o:%.o=%) 314 315# all sources should get recompiled when petscvariables changes (i.e when configure is rerun or when petscvariables is manually edited.) 316$(testsrcs.o) : $(petscvariables) 317 318%/.DIR : 319 @mkdir -p $(@D) 320 @touch $@ 321 322.PRECIOUS: %/.DIR 323 324.SUFFIXES: # Clear .SUFFIXES because we don't use implicit rules 325.DELETE_ON_ERROR: # Delete likely-corrupt target file if rule fails 326 327.PHONY: clean cleantest all 328 329cleantest: 330 ${RM} -r $(TESTDIR) $(generatedtest) 331 332clean: cleantest 333 334alltest.d := $(testsrcs.o:%.o=%.d) 335# Tell make that alltest.d are all up to date. Without this, the include 336# below has quadratic complexity, taking more than one second for a 337# do-nothing build of PETSc (much worse for larger projects) 338$(alltest.d) : ; 339 340-include $(alltest.d) 341 342# Tests can be generated by searching -- see documentation below 343showreport= 344ifndef searchin 345 searchin = " " 346endif 347ifdef i 348 searchin = $(i) 349endif 350ifdef gs 351 gmakesearch = $(gs) 352endif 353ifdef gmakesearch 354 TESTTARGETS := $(filter $(gmakesearch),$(alltesttargets)) 355 ifdef gmakesearchin 356 TESTTARGETS2 := $(foreach v,$(TESTTARGETS),$(if $(findstring $(gmakesearchin),$(v)),$(v))) 357 TESTTARGETS := $(TESTTARGETS2) 358 endif 359else ifdef gmakesearchin 360 TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(gmakesearchin),$(v)),$(v))) 361else ifdef argsearch 362 TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(argsearch),$($(v)_ARGS)),$(v))) 363else ifdef search 364 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(search)') 365else ifdef s 366 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(s)') 367else ifdef test-fail 368 TESTTARGETS := $(shell $(TESTDIR)/echofailures.sh) 369else ifdef query 370 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(query)' '$(queryval)') 371else ifdef q 372 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(q)' '$(qv)') 373else # No filter - run them all, but delete the executables as we go 374 TESTTARGETS := $(testpkgs) 375 ifneq ($(PRINTONLY),1) 376 showreport = "-s" # Only show full report when all tests are run 377 endif 378endif 379 380.PHONY: report_tests print-test 381 382print-test: 383 $(info $(TESTTARGETS)) 384 @true 385 386show-fail: 387 -@$(PYTHON) $(CONFIGDIR)/report_tests.py -d $(TESTDIR)/counts -f 388 389 390 391# Don't start running tests until starttime has completed 392$(alltesttargets:%=$(TESTDIR)/counts/%.counts) : starttime 393 394# Ensure that libpetsc (if it is a prerequisite) has been built and clean the counts/logs before starting timer 395starttime: pre-clean $(libpetscall) macos-firewall-register-mpiexec 396 @$(eval STARTTIME := $(shell date +%s)) 397 398report_tests: starttime $(TESTTARGETS) 399 @$(eval ENDTIME := $(shell date +%s)) 400 -@ elapsed_time=$$(($(ENDTIME)- $(STARTTIME))) && \ 401 $(PYTHON) $(CONFIGDIR)/report_tests.py -m $(MAKE) -d $(TESTDIR)/counts -t 5 -e $${elapsed_time} $(showreport) 402 403check_output: 404 $(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR) --check-output 405 406# Do not how how to invoke test from makefile 407HASGMAKEFILE := $(filter gmakefile,$(MAKEFILE_LIST)) 408ifeq ($(HASGMAKEFILE),gmakefile) 409helpdeps:=help-make help-targets 410makefile="gmakefile" 411other_help="To see full test help: make -f gmakefile.test help" 412else 413helpdeps:=help-make help-targets help-test 414makefile="gmakefile.test" 415other_help="" 416endif 417 418help: ${helpdeps} 419 -@echo "Above is from: ${helpdeps}" 420 -@echo "${other_help}" 421 422help-make: 423 -@echo 424 -@echo "Basic build usage:" 425 -@echo " make -f ${makefile} <options>" 426 -@echo 427 -@echo "Options:" 428 -@echo " V=0 Very quiet builds" 429 -@echo " V=1 Verbose builds" 430 -@echo 431 432help-targets: 433 -@echo "All makefile targets and their dependencies:" 434 -@grep ^[a-z] ${makefile} | grep : | grep -v = 435 -@echo 436 -@echo 437 438help-test: 439 -@echo "Basic test usage:" 440 -@echo " make -f ${makefile} test <options>" 441 -@echo 442 -@echo "Options:" 443 -@echo " V=1 Verbose output (-v to scripts)" 444 -@echo " NO_RM=1 Do not remove the executables after running" 445 -@echo " REPLACE=1 Replace the output in PETSC_DIR source tree (-m to test scripts)" 446 -@echo " OUTPUT=1 Show only the errors on stdout" 447 -@echo " ALT=1 Replace 'alt' output in PETSC_DIR source tree (-M to test scripts)" 448 -@echo " DIFF_NUMBERS=1 Diff the numbers in the output (-j to test scripts and petscdiff)" 449 -@echo " CUDAMEMCHECK=1 Execute the tests using cuda-memcheck (-U to test scripts)" 450 -@echo " VALGRIND=1 Execute the tests using valgrind (-V to test scripts)" 451 -@echo " DEBUG=1 Launch tests in the debugger (-d to the scripts)" 452 -@echo " NP=<num proc> Set a number of processors to pass to scripts." 453 -@echo " FORCE=1 Force SKIP or TODO tests to run" 454 -@echo " PRINTONLY=1 Print the command, but do not run. For loops print first command" 455 -@echo " TIMEOUT=<time> Test timeout limit in seconds (default in config/petsc_harness.sh)" 456 -@echo " TESTDIR='tests' Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}" 457 -@echo " or $${PREFIX_DIR}/$${TESTDIR}" 458 -@echo " or $${PREFIX_DIR}/share/petsc/examples/$${TESTDIR})" 459 -@echo " TESTBASE='tests' Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}" 460 -@echo " OPTIONS='<args>' Override options to scripts (-a to test scripts)" 461 -@echo " EXTRA_OPTIONS='<args>' Add options to scripts (-e to test scripts)" 462 -@echo 463 -@echo "Special options for macOS:" 464 -@echo " MACOS_FIREWALL=1 Add each built test to the macOS firewall list to prevent popups. Configure --with-macos-firewall-rules to make this default" 465 -@echo 466 -@echo "Tests can be generated by searching with multiple methods" 467 -@echo " For general searching (using config/query_test.py):" 468 -@echo " make -f ${makefile} test search='sys*ex2*'" 469 -@echo " or the shortcut using s" 470 -@echo " make -f ${makefile} test s='sys*ex2*'" 471 -@echo " You can also use the full path to a file directory" 472 -@echo " make -f ${makefile} test s='src/sys/tests/'" 473 -@echo 474 -@echo " To search for fields from the original test definitions:" 475 -@echo " make -f ${makefile} test query='requires' queryval='*MPI_PROCESS_SHARED_MEMORY*'" 476 -@echo " or the shortcut using q and qv" 477 -@echo " make -f ${makefile} test q='requires' qv='*MPI_PROCESS_SHARED_MEMORY*'" 478 -@echo " To filter results from other searches, use searchin" 479 -@echo " make -f ${makefile} test s='src/sys/tests/' searchin='*options*'" 480 -@echo 481 -@echo " To re-run the last tests which failed:" 482 -@echo " make -f ${makefile} test test-fail='1'" 483 -@echo 484 -@echo " To see which targets match a given pattern (useful for doing a specific target):" 485 -@echo " make -f ${makefile} print-test search=sys*" 486 -@echo 487 -@echo " To build an executable, give full path to location:" 488 -@echo ' make -f ${makefile} $${PETSC_ARCH}/tests/sys/tests/ex1' 489 -@echo " or make the test with NO_RM=1" 490 -@echo 491