-
-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathtests
More file actions
202 lines (160 loc) · 6.98 KB
/
Copy pathtests
File metadata and controls
202 lines (160 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
N_TESTS ?= 100
# override this in make/local. If <= 0, N_TESTS + 1 is interpreted as the number of batches
# to group the probability tests into
##
# Any targets in test/benchmark (.d, .o, executable) needs the Google benchmark flags
##
benchmarks/%$(EXE) : CXXFLAGS += -I $(BENCHMARK)/include $(CXXFLAGS_GTEST) $(BENCHMARK_CXXFLAGS)
benchmarks/%$(EXE) : LDFLAGS += -L $(BENCHMARK)/build/src $(BENCHMARK_LDFLAGS)
benchmarks/%$(EXE) : LDLIBS += -lbenchmark
benchmarks/%$(EXE) : CPPFLAGS += $(CPPFLAGS_GTEST) $(BENCHMARK_CPPFLAGS)
benchmarks/%$(EXE) : INC += $(INC_GTEST)
ifeq ($(OS),Windows_NT)
benchmarks/%$(EXE) : LDLIBS += -lshlwapi
endif
benchmarks/%$(EXE) : benchmarks/%.cpp $(GTEST)/src/gtest-all.o $(MPI_TARGETS) $(TBB_TARGETS)
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)
##
# Any targets in test/ (.d, .o, executable) needs the GTEST flags
##
test/% : CXXFLAGS += $(CXXFLAGS_GTEST)
test/% : CPPFLAGS += $(CPPFLAGS_GTEST)
test/% : INC += $(INC_GTEST)
test/%$(EXE) : test/%.o $(GTEST)/src/gtest_main.cc $(GTEST)/src/gtest-all.o $(MPI_TARGETS) $(TBB_TARGETS)
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)
##
# Include dependency files for tests
# This has the side-effect of making the object files non-intermediates,
# so we need to explicitly tell make we don't want to keep them
##
ifneq ($(filter test/%,$(MAKECMDGOALS)),)
-include $(patsubst %$(EXE),%.d,$(filter test/%,$(MAKECMDGOALS)))
.INTERMEDIATE: $(patsubst test/%_test$(EXE),test/%_test.o,$(filter test/%_test$(EXE),$(MAKECMDGOALS)))
endif
##
# Adding a test for multiple translation units. If this fails,
# a public umbrella header likely exposes a new non-inline external definition.
##
ifneq ($(OS),Windows_NT)
test/unit/multiple_translation_units%.o : CXXFLAGS += -fPIC
endif
test/unit/multiple_translation_units%.o : CXXFLAGS += -pipe
test/unit/libmultiple.so : LDFLAGS += -shared
test/unit/libmultiple.so : test/unit/multiple_translation_units1.o test/unit/multiple_translation_units2.o $(MPI_TARGETS) $(TBB_TARGETS)
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)
test/unit/multiple_translation_units_test$(EXE): test/unit/libmultiple.so
############################################################
#
# Expression tests
##
EXPRESSION_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test/expressions,*_test.cpp))
$(EXPRESSION_TESTS) : $(SUNDIALS_TARGETS)
############################################################
#
# CVODES tests
##
CVODES_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*cvodes*_test.cpp) $(call findfiles,test,*_bdf_*_test.cpp) $(call findfiles,test,*_adams_*_test.cpp) $(call findfiles,test,*_ode_typed_*test.cpp) $(call findfiles,test,*_ode_adjoint_typed_*test.cpp))
$(CVODES_TESTS) : $(SUNDIALS_TARGETS)
############################################################
#
# IDAS tests
##
IDAS_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*idas*_test.cpp) $(call findfiles,test,*_dae*_test.cpp))
$(IDAS_TESTS) : $(SUNDIALS_TARGETS)
############################################################
#
# KINSOL tests
##
ALGEBRA_SOLVER_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,*solve*_test.cpp))
$(ALGEBRA_SOLVER_TESTS) : $(SUNDIALS_TARGETS)
### These can be generated by the jumbo tests and include the above kinds
FUNCTOR_TESTS := $(subst .cpp,$(EXE),$(call findfiles,test,functor_*_test.cpp))
$(FUNCTOR_TESTS) : $(SUNDIALS_TARGETS)
############################################################
#
# Target to verify header files within Stan has
# enough include calls
##
HEADER_TESTS := $(addsuffix -test,$(call findfiles,stan,*.hpp))
ifeq ($(OS),Windows_NT)
DEV_NULL = nul
ifeq ($(IS_UCRT),true)
UCRT_NULL_FLAG = -S
endif
else
DEV_NULL = /dev/null
endif
%.hpp-test : %.hpp test/dummy.cpp
$(COMPILE.cpp) $(CXXFLAGS) -O0 -include $^ $(UCRT_NULL_FLAG) -o $(DEV_NULL) -Wunused-local-typedefs
test/dummy.cpp:
@mkdir -p test
@touch $@
@echo "int main() {return 0;}" >> $@
.PHONY: test-headers
test-headers: $(HEADER_TESTS)
ifdef GENERATE_DISTRIBUTION_TESTS
############################################################
##
# Test generator for distribution tests
##
test/prob/generate_tests$(EXE) : LDLIBS_TBB =
test/prob/generate_tests$(EXE) : test/prob/generate_tests.cpp
@mkdir -p $(dir $@)
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)
## FIXME: think about how to do this generally using test_types
# test_types := v fd fv ffd ffv vv
test_name = $(shell echo $(1) | sed 's,_[0-9]\{5\},_test.hpp,g')
.SECONDEXPANSION:
test/prob/%_generated_v_test.cpp test/prob/%_generated_fd_test.cpp test/prob/%_generated_fv_test.cpp test/prob/%_generated_ffd_test.cpp test/prob/%_generated_ffv_test.cpp test/prob/%_generated_vv_test.cpp: test/prob/$$(call test_name,$$*) test/prob/generate_tests$(EXE)
$(WINE) test/prob/generate_tests$(EXE) $< $(N_TESTS)
LIST_OF_GENERATED_TESTS := $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_v_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_fv_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffd_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_ffv_test.cpp,g') $(shell find test/prob -type f -name '*_test.hpp' | sed 's,_test.hpp,_00000_generated_vv_test.cpp,g')
.PHONY: generate-tests
generate-tests: $(LIST_OF_GENERATED_TESTS)
endif
##
# Building stanc3 binary used for expressions tests
##
STANC_DL_RETRY = 5
STANC_DL_DELAY = 10
ifeq ($(OS),Windows_NT)
OS_TAG := windows
else ifeq ($(OS),Darwin)
OS_TAG := mac
else ifeq ($(OS),Linux)
OS_TAG := linux
endif
ifeq ($(OS),Windows_NT)
TEST_STANC = test/expressions/stanc$(EXE) test\expressions\stanc$(EXE)
else
TEST_STANC = test/expressions/stanc$(EXE)
endif
ifneq ($(STANC3),)
# build stanc3 from local installation
$(TEST_STANC) : $(call findfiles,$(STANC3)/src/,*.ml*) $(STANC#)
@mkdir -p $(dir $@)
cd $(STANC3) && echo "--- Rebuilding stanc ---\n" && dune build @install
cp $(STANC3)/_build/default/src/stanc/stanc.exe $@
else ifneq ($(STANC3_TEST_BIN_URL),)
# download stanc3 build from specific branch
ifeq ($(OS_TAG),windows)
$(TEST_STANC) :
@mkdir -p $(dir $@)
$(shell echo "curl -L $(STANC3_TEST_BIN_URL)/bin/$(OS_TAG)-stanc -o $@ --retry $(STANC_DL_RETRY) --retry-delay $(STANC_DL_DELAY)")
else
$(TEST_STANC) :
@mkdir -p $(dir $@)
curl -L $(STANC3_TEST_BIN_URL)/bin/$(OS_TAG)-stanc -o $@ --retry $(STANC_DL_RETRY) --retry-delay $(STANC_DL_DELAY)
chmod +x $@
endif # end download if/else
else ifeq ($(OS_TAG),windows)
# get latest stanc3 - Windows
$(TEST_STANC) :
@mkdir -p $(dir $@)
$(shell echo "curl -L https://github.com/stan-dev/stanc3/releases/download/nightly/$(OS_TAG)-stanc -o $@ --retry $(STANC_DL_RETRY) --retry-delay $(STANC_DL_DELAY)")
else
# get latest stanc3 - Linux & MacOS
$(TEST_STANC) :
@mkdir -p $(dir $@)
curl -L https://github.com/stan-dev/stanc3/releases/download/nightly/$(OS_TAG)-stanc -o $@ --retry $(STANC_DL_RETRY) --retry-delay $(STANC_DL_DELAY)
chmod +x $@
endif