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 help clean check info libs all checkbadSource checkbadFileChange allfortranstubs alletags clangformat checkclangformat get%,$(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) $(CUDAPP_FLAGS) $(CUDA_HOSTFLAGS) 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 = ${CUDA_PETSC_GENDEPS} 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 KOKC = PATH=`dirname $(CUDAC)`:$(PATH) NVCC_WRAPPER_DEFAULT_COMPILER="$(CUDA_CXX)" $(KOKKOS_BIN)/nvcc_wrapper --expt-extended-lambda 120 KOKKOS_COMPILE = $(call quiet,KOKC) -c $(CUDAC_FLAGS) ${PETSC_CXXCPPFLAGS} $(CUDACPPFLAGS) $(CUDA_CXXFLAGS) $(MPICXX_INCLUDES) 121else ifneq ($(KOKKOS_USE_CUDACLANG_COMPILER),) 122 KOKKOS_COMPILE = $(PETSC_COMPILE.cu) 123else ifneq ($(KOKKOS_USE_HIP_COMPILER),) 124 KOKKOS_COMPILE = $(PETSC_COMPILE.hip.cpp) 125else ifneq ($(KOKKOS_USE_SYCL_COMPILER),) 126 KOKKOS_COMPILE = $(PETSC_COMPILE.sycl.cxx) 127else 128 KOKKOS_COMPILE = $(PETSC_COMPILE.cxx) 129endif 130# https://github.com/kokkos/kokkos/pull/5473 used a C++17 feature, inline static variables. 131# We found -fvisibility=hidden could hide these variables such that the supposed globally unique 132# variables become local to each file including them and thus have multiple copies (see an example 133# at the end of PR5473). It might be a gcc bug thus we also filed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107535 134# See also an older bug report related to visibility, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59693 135# 136# Our workaround here is to git rid of -fvisibility=hidden from Kokkos compiler options, so that petsc 137# files including Kokkos headers won't be affected by this flag. 138# 139# The solution is not ideal in the sense we have to duplicate the same workaround to any external libraries 140# using C++17 inline static variables. We have to wait for GNU to clarify this issue. 141PETSC_COMPILE.kokkos.cxx = $(filter-out -fvisibility=hidden,$(KOKKOS_COMPILE)) 142 143ifneq ($(RAJA_USE_CUDA_COMPILER),) 144 PETSC_COMPILE.raja.cxx = ${CUDAC} $(MPICXX_INCLUDES) ${CUDAC_FLAGS} -x cu -Xcudafe "--display_error_number" -c --compiler-options="${PETSC_CXXCPPFLAGS} ${PETSC_CC_INCLUDES} ${CUDA_CXXFLAGS}" --expt-extended-lambda --expt-relaxed-constexpr 145else 146 PETSC_COMPILE.raja.cxx = ${CXX} -o $*.o -c ${CXX_FLAGS} ${CXXFLAGS} ${CXXCPPFLAGS} 147endif 148 149testlangs := c cu cxx F F90 kokkos.cxx hip.cpp sycl.cxx raja.cxx 150$(foreach lang, $(testlangs), $(eval \ 151 testexe.$(lang) = $(foreach pkg, $(pkgs), $(testsrcs-$(pkg).$(lang):%.$(lang)=$(TESTDIR)/%)))) 152concattestlang = $(foreach lang, $(2), $(testsrcs-$(1).$(lang):%.$(lang)=$(TESTDIR)/%.o)) 153testsrcs.o := $(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),$(testlangs))) 154testsrcs-rel := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), $(testsrcs-$(pkg).$(lang)))) 155testsrcs := $(foreach sfile, $(testsrcs-rel), $(TESTSRCDIR)/$(sfile)) 156 157# workaround win32fe failure 158ifneq (,$(findstring win_,$(call quiet,$(cc_name)))) 159$(TESTDIR)/ts/tutorials/multirate/ex6: | $(TESTDIR)/ts/tutorials/multirate/ex5 160$(TESTDIR)/ts/tutorials/multirate/ex8: | $(TESTDIR)/ts/tutorials/multirate/ex6 161endif 162 163# Refresh testfiles when sources change, but don't balk if the source file is nonexistent (deleted) 164$(generatedtest) : $(testsrcs) 165$(testsrcs) : 166 167$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.c | $$(@D)/.DIR 168 $(PETSC_COMPILE.c) $(abspath $<) -o $@ 169 170$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.kokkos.cxx | $$(@D)/.DIR 171 $(PETSC_COMPILE.kokkos.cxx) $(abspath $<) -o $@ 172 173$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.sycl.cxx | $$(@D)/.DIR 174 $(PETSC_COMPILE.sycl.cxx) $(abspath $<) -o $@ 175 176$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.raja.cxx | $$(@D)/.DIR 177 $(PETSC_COMPILE.raja.cxx) $(abspath $<) -o $@ 178 179$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cxx | $$(@D)/.DIR 180 $(PETSC_COMPILE.cxx) $(abspath $<) -o $@ 181 182$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.cu | $$(@D)/.DIR 183 $(PETSC_COMPILE.cu) $(abspath $<) -o $@ # Compile first so that if there is an error, it comes from a normal compile 184 @$(PETSC_GENDEPS.cu) $(abspath $<) -o $(@:%.o=%.d) # Generate the dependencies for later 185 186$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.hip.cpp | $$(@D)/.DIR 187 $(PETSC_COMPILE.hip.cpp) $(abspath $<) -o $@ 188 189# Test modules go in the same directory as the target *.o 190TESTMODDIR = $(@D) 191FCMOD = cd 192$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F | $$(@D)/.DIR 193ifeq ($(FC_MODULE_OUTPUT_FLAG),) 194 $(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@) 195else 196 $(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR) 197endif 198 -@$(GFORTRAN_DEP_CLEANUP) 199 200$(TESTDIR)/%.o : $(EXAMPLESDIR)/%.F90 | $$(@D)/.DIR 201ifeq ($(FC_MODULE_OUTPUT_FLAG),) 202 $(call quiet,FCMOD) $(TESTMODDIR) && $(FC) -c $(FC_FLAGS) $(FFLAGS) $(FCPPFLAGS) $(FC_DEPFLAGS) -I$(dir $<) $(abspath $<) -o $(abspath $@) 203else 204 $(PETSC_COMPILE.F) -I$(dir $<) $(abspath $<) -o $@ $(FC_MODULE_OUTPUT_FLAG)$(TESTMODDIR) $(FC_MODULE_FLAG)$(TESTMODDIR) 205endif 206 -@$(GFORTRAN_DEP_CLEANUP) 207 208# This is a hack to fix a broken gfortran. 209define GFORTRAN_DEP_CLEANUP 210 if test -e "$(@:%.o=%.d)" && head -1 "$(@:%.o=%.d)" | grep -F -q -v : ; then\ 211 echo "$(@): \\" > $(@:%.o=%.dtemp) ; \ 212 tr '\n' '@' < $(@:%.o=%.d) | cut -d: -f2- | tr '@' '\n' >> $(@:%.o=%.dtemp) ; \ 213 mv $(@:%.o=%.dtemp) $(@:%.o=%.d); \ 214 fi 215endef 216 217# link line constructed differently for gmakefile vs gmakefile.test invocation 218ifeq ($(libpetscall),) 219PETSC_TEST_LIB = $(PETSC_LIB) 220else 221PETSC_TEST_LIB = $(C_SH_LIB_PATH) $(PETSC_EXTERNAL_LIB_BASIC) 222endif 223 224# manually list some some library dependencies to check for circular dependencies 225$(TESTDIR)/sys/tests/ex9: PETSC_TEST_LIB = $(PETSC_SYS_LIB) 226$(TESTDIR)/vec/vec/tests/ex1: PETSC_TEST_LIB = $(PETSC_VEC_LIB) 227$(TESTDIR)/mat/tests/ex1: PETSC_TEST_LIB = $(PETSC_MAT_LIB) 228$(TESTDIR)/dm/tests/ex1: PETSC_TEST_LIB = $(PETSC_DM_LIB) 229$(TESTDIR)/ksp/ksp/tests/ex1: PETSC_TEST_LIB = $(PETSC_KSP_LIB) 230$(TESTDIR)/snes/tests/ex1: PETSC_TEST_LIB = $(PETSC_SNES_LIB) 231$(TESTDIR)/ts/tests/ex2: PETSC_TEST_LIB = $(PETSC_TS_LIB) 232$(TESTDIR)/tao/tutorials/ex1: PETSC_TEST_LIB = $(PETSC_TAO_LIB) 233 234# MACOS FIREWALL HANDLING 235# - if run with MACOS_FIREWALL=1 236# (automatically set in $PETSC_ARCH/lib/petsc/conf/petscvariables if configured --with-macos-firewall-rules), 237# ensure mpiexec and test executable is on firewall list 238# 239ifeq ($(MACOS_FIREWALL),1) 240FW := /usr/libexec/ApplicationFirewall/socketfilterfw 241# There is no reliable realpath command in macOS without need for 3rd party tools like homebrew coreutils 242# Using Python's realpath seems like the most robust way here 243realpath-py = $(shell $(PYTHON) -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' $(1)) 244# 245define macos-firewall-register 246 @APP=$(call realpath-py, $(1)); \ 247 if ! sudo -n true 2>/dev/null; then printf "Asking for sudo password to add new firewall rule for\n $$APP\n"; fi; \ 248 sudo $(FW) --remove $$APP --add $$APP --blockapp $$APP 249endef 250endif 251# 252macos-firewall-register-mpiexec: 253 -$(call macos-firewall-register, $(MPIEXEC)) 254 255# Test executables 256$(testexe.F) $(testexe.F90) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 257 $(call quiet,FLINKER) -o $@ $^ $(PETSC_TEST_LIB) 258 -$(call macos-firewall-register,$@) 259 260ifneq (,$(findstring emcc,$(CC))) 261$(testexe.c) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 262 -@$(call quiet,CLINKER) -s MAIN_MODULE -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 -s ALLOW_MEMORY_GROWTH $(EXEFLAGS) -o $@.js $@.o $(PETSC_LIB) 263 -@printf '#!/usr/bin/env sh\nnode --redirect-warnings=/dev/null $$0.js $$* | grep -v "Heap resize call from"' > $@ 264 -@chmod u+x $@ 265else 266$(testexe.c) $(testexe.cu) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 267 $(call quiet,CLINKER) $(EXEFLAGS) -o $@ $^ $(PETSC_TEST_LIB) 268 -$(call macos-firewall-register,$@) 269 270endif 271 272$(testexe.hip.cpp) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 273 $(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB) 274 -$(call macos-firewall-register,$@) 275 276$(testexe.kokkos.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 277 $(call quiet,CLINKER) $(EXEFLAGS) -o $@ $^ $(PETSC_TEST_LIB) 278 -$(call macos-firewall-register,$@) 279 280$(testexe.raja.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 281 $(call quiet,CLINKER) -o $@ $^ $(PETSC_TEST_LIB) 282 -$(call macos-firewall-register,$@) 283 284$(testexe.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) 285 $(call quiet,CXXLINKER) -o $@ $^ $(PETSC_TEST_LIB) 286 -$(call macos-firewall-register,$@) 287 288# Fortran source files need petsc*.mod, which isn't explicitly managed in the makefile. 289$(foreach pkg, $(pkgs), $(call concattestlang,$(pkg),F F90)) : $(libpetscall) 290 291# Testing convenience targets 292.PHONY: test pre-clean 293 294test: report_tests 295 296pre-clean: 297 @$(RM) -rf $(TESTDIR)/counts $(TESTLOGTAPFILE) $(TESTLOGERRFILE) 298 @touch $(TESTLOGTAPFILE) $(TESTLOGERRFILE) 299 @echo "Using MAKEFLAGS:" ${MAKEFLAGS} 300 301check-test-errors: 302 @grep '^not ok' $(TESTLOGTAPFILE) | grep -v 'Exceeded timeout' | tee $(TESTDIR)/allgtests-tap-err.log 303 @test ! -s $(TESTDIR)/allgtests-tap-err.log 304 305.PHONY: $(foreach pkg, $(pkgs), test-$(pkg) $(foreach lang, $(testlangs), test-$(pkg).$(lang) test-rm-$(pkg).$(lang))) 306testpkgs := $(foreach pkg, $(pkgs), test-$(pkg)) 307# Targets to run tests in test-$pkg.$lang and delete the executables, language by language 308$(testpkgs) : test-% : $(foreach lang, $(testlangs), test-rm-%.$(lang)) 309# List of raw test run targets 310alltesttargets := $(foreach tp, $(testpkgs), $(foreach lang, $(testlangs), $($(tp).$(lang)))) 311 312# Run targets 313$(alltesttargets) : % : $(TESTDIR)/counts/%.counts 314.PHONY: $(alltesttargets) 315 316$(TESTDIR)/counts/%.counts : 317 $(quiettest) $< $(TESTFLAGS) 318 319# Targets to run tests and remove executables, by package-lang pairs. 320# Run the tests in each batch using recursive invocation of make because 321# we need all of them to complete before removing the executables. Make 322# doesn't guarantee an exploration order for the graph. Only recursive 323# if there is something to be done. 324alltest-rm := $(foreach pkg, $(pkgs), $(foreach lang, $(testlangs), test-rm-$(pkg).$(lang))) 325$(alltest-rm) : test-rm-% : test-% 326ifneq ($(NO_RM),1) 327 $(call quiet,RM) $(addprefix $(TESTDIR)/,$(basename $($(@:test-rm-%=testsrcs-%)))) 328endif 329 330# Remove intermediate .o files 331# This only removes the files at the end which is insufficient 332#.INTERMEDIATE: $(testsrcs.o:%.o=%) 333 334# all sources should get recompiled when petscvariables changes (i.e when configure is rerun or when petscvariables is manually edited.) 335$(testsrcs.o) : $(petscvariables) 336 337%/.DIR : 338 @mkdir -p $(@D) 339 @touch $@ 340 341.PRECIOUS: %/.DIR 342 343.SUFFIXES: # Clear .SUFFIXES because we don't use implicit rules 344.DELETE_ON_ERROR: # Delete likely-corrupt target file if rule fails 345 346.PHONY: clean cleantest all 347 348cleantest: 349 ${RM} -r $(TESTDIR) $(generatedtest) 350 351clean: cleantest 352 353alltest.d := $(testsrcs.o:%.o=%.d) 354# Tell make that alltest.d are all up to date. Without this, the include 355# below has quadratic complexity, taking more than one second for a 356# do-nothing build of PETSc (much worse for larger projects) 357$(alltest.d) : ; 358 359-include $(alltest.d) 360 361# Tests can be generated by searching -- see documentation below 362showreport= 363ifndef searchin 364 searchin = " " 365endif 366ifdef i 367 searchin = $(i) 368endif 369ifdef gs 370 gmakesearch = $(gs) 371endif 372ifdef gmakesearch 373 TESTTARGETS := $(filter $(gmakesearch),$(alltesttargets)) 374 ifdef gmakesearchin 375 TESTTARGETS2 := $(foreach v,$(TESTTARGETS),$(if $(findstring $(gmakesearchin),$(v)),$(v))) 376 TESTTARGETS := $(TESTTARGETS2) 377 endif 378else ifdef gmakesearchin 379 TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(gmakesearchin),$(v)),$(v))) 380else ifdef argsearch 381 TESTTARGETS := $(foreach v,$(alltesttargets),$(if $(findstring $(argsearch),$($(v)_ARGS)),$(v))) 382else ifdef search 383 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(search)') 384else ifdef s 385 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) 'name' '$(s)') 386else ifdef test-fail 387 TESTTARGETS := $(shell $(TESTDIR)/echofailures.sh) 388else ifdef query 389 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(query)' '$(queryval)') 390else ifdef q 391 TESTTARGETS := $(shell $(PYTHON) $(CONFIGDIR)/query_tests.py --testdir=$(TESTDIR) --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --searchin=$(searchin) '$(q)' '$(qv)') 392else # No filter - run them all, but delete the executables as we go 393 TESTTARGETS := $(testpkgs) 394 ifneq ($(PRINTONLY),1) 395 showreport = "-s" # Only show full report when all tests are run 396 endif 397endif 398 399.PHONY: report_tests print-test 400 401print-test: 402 $(info $(TESTTARGETS)) 403 @true 404 405show-fail: 406 -@$(PYTHON) $(CONFIGDIR)/report_tests.py -d $(TESTDIR)/counts -f 407 408 409 410# Don't start running tests until starttime has completed 411$(alltesttargets:%=$(TESTDIR)/counts/%.counts) : starttime 412 413# Ensure that libpetsc (if it is a prerequisite) has been built and clean the counts/logs before starting timer 414starttime: pre-clean $(libpetscall) macos-firewall-register-mpiexec 415 @$(eval STARTTIME := $(shell date +%s)) 416 417report_tests: starttime $(TESTTARGETS) 418 @$(eval ENDTIME := $(shell date +%s)) 419 -@ elapsed_time=$$(($(ENDTIME)- $(STARTTIME))) && \ 420 $(PYTHON) $(CONFIGDIR)/report_tests.py -m $(MAKE) -d $(TESTDIR)/counts -t 5 -e $${elapsed_time} $(showreport) 421 422check_output: 423 $(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR) --check-output 424 425# If users make is a gnumake then these messages are provided even if the user does not do make -f gmakefile.test 426HASGMAKEFILE := $(filter gmakefile,$(MAKEFILE_LIST)) 427ifeq ($(HASGMAKEFILE),gmakefile) 428helpdeps:= help-nontest 429else 430helpdeps:= help-test 431endif 432 433help: help-make ${helpdeps} 434 -@echo "" 435 436help-make: 437 -@echo 438 -@echo "PETSc makefile Basic usage:" 439 -@echo " make rule <V=1 for verbose output> <other options>" 440 -@echo 441 442help-nontest: 443 -@echo "Available rules:" 444 -@echo " all - build (update) the PETSc and related libraries in parallel" 445 -@echo " libs - build (update) the PETSc and related libraries" 446 -@echo " check - run a basic check that the libraries are built correctly and can be used" 447 -@echo " " 448 -@echo " getlinklibs - print the libraries that a PETSc application must link against" 449 -@echo " getincludedirs - print the include directories that a PETSc application must be compiled against" 450 -@echo " getcflags - print the C compiler flags PETSc is using" 451 -@echo " getcxxflags - print the C++ compiler flags PETSc is using" 452 -@echo " getfortranflags - print the Fortran compiler flags PETSc is using" 453 -@echo " " 454 -@echo " petsc4pytest - run the entire petsc4py test suite" 455 -@echo " alltests - run the entire PETSc test suite" 456 -@echo " test - use \"make -f gmakefile.test help\" for help on running the extensive tests" 457 -@echo 458 -@echo "Developer rules:" 459 -@echo " clean - delete libraries and Fortran module files" 460 -@echo " clangformat - run clangformat on the PETSc C/C++ source code" 461 -@echo " allfortranstubs - regenerate Fortran stubs/interface definitions, needed after git pulls or source code changes" 462 -@echo " deletefortranstubs - delete the generated Fortran stubs/interface definitions" 463 -@echo " checkbadSource - check the source code for violations of coding standards" 464 -@echo " abitest - Compare ABI/API of two versions of PETSc library with the old one defined by PETSC_{DIR,ARCH}_ABI_OLD" 465 -@echo " reconfigure - delete libraries and Fortran module files and run the previously run configure again" 466 -@echo " lint - run lint on the source code, including its embedded documentation" 467 -@echo " Run ${OMAKE} help-lint for lint options" 468 -@echo " " 469 -@echo "Building website: (run in the doc directory)" 470 -@cd doc; ${OMAKE} help 471 -@echo " " 472 473help-test: 474 -@echo "Test usage:" 475 -@echo " make -f gmakefile.test test <options>" 476 -@echo 477 -@echo "Options:" 478 -@echo " NO_RM=1 Do not remove the executables after running" 479 -@echo " REPLACE=1 Replace the output in PETSC_DIR source tree (-m to test scripts)" 480 -@echo " OUTPUT=1 Show only the errors on stdout" 481 -@echo " ALT=1 Replace 'alt' output in PETSC_DIR source tree (-M to test scripts)" 482 -@echo " DIFF_NUMBERS=1 Diff the numbers in the output (-j to test scripts and petscdiff)" 483 -@echo " CUDAMEMCHECK=1 Execute the tests using cuda-memcheck (-U to test scripts)" 484 -@echo " Use PETSC_CUDAMEMCHECK_COMMAND to change the executable to run and" 485 -@echo " PETSC_CUDAMEMCHECK_ARGS to change the arguments (note: both" 486 -@echo " cuda-memcheck and compute-sanitizer are supported)" 487 -@echo " VALGRIND=1 Execute the tests using valgrind (-V to test scripts)" 488 -@echo " DEBUG=1 Launch tests in the debugger (-d to the scripts)" 489 -@echo " NP=<num proc> Set a number of processors to pass to scripts." 490 -@echo " FORCE=1 Force SKIP or TODO tests to run" 491 -@echo " PRINTONLY=1 Print the command, but do not run. For loops print first command" 492 -@echo " TIMEOUT=<time> Test timeout limit in seconds (default in config/petsc_harness.sh)" 493 -@echo " TESTDIR='tests' Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}" 494 -@echo " or $${PREFIX_DIR}/$${TESTDIR}" 495 -@echo " or $${PREFIX_DIR}/share/petsc/examples/$${TESTDIR})" 496 -@echo " TESTBASE='tests' Subdirectory where tests are run ($${PETSC_DIR}/$${PETSC_ARCH}/$${TESTDIR}" 497 -@echo " OPTIONS='<args>' Override options to scripts (-a to test scripts)" 498 -@echo " EXTRA_OPTIONS='<args>' Add options to scripts (-e to test scripts)" 499 -@echo 500 -@echo "Special options for macOS:" 501 -@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" 502 -@echo 503 -@echo "Tests can be generated by searching with multiple methods" 504 -@echo " For general searching (using config/query_test.py):" 505 -@echo " make -f ${makefile} test search='sys*ex2*'" 506 -@echo " or the shortcut using s" 507 -@echo " make -f ${makefile} test s='sys*ex2*'" 508 -@echo " You can also use the full path to a file directory" 509 -@echo " make -f ${makefile} test s='src/sys/tests/'" 510 -@echo 511 -@echo " To search for fields from the original test definitions:" 512 -@echo " make -f ${makefile} test query='requires' queryval='*MPI_PROCESS_SHARED_MEMORY*'" 513 -@echo " or the shortcut using q and qv" 514 -@echo " make -f ${makefile} test q='requires' qv='*MPI_PROCESS_SHARED_MEMORY*'" 515 -@echo " To filter results from other searches, use searchin" 516 -@echo " make -f ${makefile} test s='src/sys/tests/' searchin='*options*'" 517 -@echo 518 -@echo " To re-run the last tests which failed:" 519 -@echo " make -f ${makefile} test test-fail='1'" 520 -@echo 521 -@echo " To see which targets match a given pattern (useful for doing a specific target):" 522 -@echo " make -f ${makefile} print-test search=sys*" 523 -@echo 524 -@echo " To build an executable, give full path to location:" 525 -@echo ' make -f ${makefile} $${PETSC_ARCH}/tests/sys/tests/ex1' 526 -@echo " or make the test with NO_RM=1" 527 -@echo 528 529help-targets: 530 -@echo "All makefile targets and their dependencies:" 531 -@grep ^[a-z] ${makefile} | grep : | grep -v = 532 -@echo 533