test-variants.mk revision 1.3 1 1.3 rillig # $NetBSD: test-variants.mk,v 1.3 2022/05/03 19:05:34 rillig Exp $
2 1.1 rillig #
3 1.1 rillig # Build several variants of make and run the tests on them.
4 1.1 rillig #
5 1.1 rillig # The output of this test suite must be inspected manually to see the
6 1.1 rillig # interesting details. The main purpose is to list the available build
7 1.1 rillig # options.
8 1.1 rillig
9 1.1 rillig .MAIN: usage
10 1.1 rillig usage:
11 1.1 rillig @echo 'usage: ${MAKE} -f ${MAKEFILE} list'
12 1.1 rillig @echo ' ${MAKE} -f ${MAKEFILE} all'
13 1.1 rillig @echo ' ${MAKE} -f ${MAKEFILE} test...'
14 1.1 rillig
15 1.1 rillig
16 1.1 rillig TESTS+= default
17 1.1 rillig #ENV.default= VAR=value...
18 1.1 rillig #CPPFLAGS.default= -DMACRO -I...
19 1.1 rillig #CFLAGS.default= -O1
20 1.1 rillig #SKIP.default= yes
21 1.1 rillig #SKIP_TESTS.default= varmod-subst
22 1.1 rillig
23 1.1 rillig # Try a different compiler, with slightly different warnings and error
24 1.1 rillig # messages. Clang has a few stricter checks than GCC, concerning enums
25 1.1 rillig # and non-literal format strings.
26 1.1 rillig #
27 1.1 rillig TESTS+= llvm
28 1.1 rillig ENV.llvm= HAVE_LLVM="yes"
29 1.1 rillig
30 1.1 rillig # Use emalloc for memory allocation.
31 1.1 rillig TESTS+= emalloc
32 1.1 rillig ENV.emalloc= TOOLDIR=""
33 1.1 rillig
34 1.1 rillig # NetBSD 10 fails with:
35 1.1 rillig # filemon_dev.c:93:19: error: 'FILEMON_SET_FD' undeclared
36 1.1 rillig TESTS+= filemon-dev
37 1.1 rillig ENV.filemon-dev= USE_FILEMON="dev"
38 1.1 rillig SKIP.filemon-dev= yes
39 1.1 rillig
40 1.1 rillig TESTS+= filemon-ktrace
41 1.1 rillig ENV.filemon-ktrace= USE_FILEMON="ktrace"
42 1.1 rillig
43 1.2 rillig TESTS+= filemon-none
44 1.2 rillig ENV.filemon-none= USE_FILEMON="no"
45 1.2 rillig # The following tests only fail due to the extra variable in the debug log.
46 1.2 rillig SKIP_TESTS.filemon-none= \
47 1.2 rillig opt-debug-graph1 \
48 1.2 rillig opt-debug-graph2 \
49 1.2 rillig opt-debug-graph3 \
50 1.2 rillig suff-main-several \
51 1.2 rillig suff-transform-debug
52 1.2 rillig
53 1.1 rillig TESTS+= no-meta
54 1.1 rillig ENV.no-meta= USE_META="no"
55 1.1 rillig SKIP_TESTS.no-meta= depsrc-meta meta-cmd-cmp
56 1.1 rillig
57 1.1 rillig TESTS+= cleanup
58 1.1 rillig CPPFLAGS.cleanup= -DCLEANUP
59 1.1 rillig
60 1.1 rillig TESTS+= debug-refcnt
61 1.1 rillig CPPFLAGS.debug-refcnt= -DDEBUG_REFCNT
62 1.1 rillig
63 1.1 rillig TESTS+= debug-hash
64 1.1 rillig CPPFLAGS.debug-hash= -DDEBUG_HASH_LOOKUP
65 1.1 rillig SKIP_TESTS.debug-hash= opt-debug-hash # mixes regular and debug output
66 1.1 rillig
67 1.1 rillig TESTS+= debug-meta
68 1.1 rillig CPPFLAGS.debug-meta= -DDEBUG_META_MODE
69 1.1 rillig SKIP_TESTS.debug-meta= depsrc-meta meta-cmd-cmp # generate extra debug output
70 1.1 rillig
71 1.1 rillig # Produces lots of debugging output.
72 1.1 rillig #
73 1.1 rillig TESTS+= debug-src
74 1.1 rillig CPPFLAGS.debug-src= -DDEBUG_SRC
75 1.1 rillig SKIP.debug-src= yes
76 1.1 rillig
77 1.1 rillig # In this variant, the tests for 'export VAR=value' fail, as expected.
78 1.1 rillig #
79 1.1 rillig TESTS+= no-gmake-export
80 1.1 rillig CPPFLAGS.no-gmake-export= -UGMAKEEXPORT
81 1.1 rillig SKIP.no-gmake-export= yes
82 1.1 rillig
83 1.1 rillig # NetBSD 8.0 x86_64
84 1.1 rillig # In file included from arch.c:135:0:
85 1.1 rillig # /usr/include/sys/param.h:357:0: error: "MAXPATHLEN" redefined [-Werror]
86 1.1 rillig TESTS+= maxpathlen
87 1.1 rillig CPPFLAGS.maxpathlen= -DMAXPATHLEN=20
88 1.1 rillig SKIP.maxpathlen= yes
89 1.1 rillig
90 1.1 rillig # In this variant, the unit tests using the modifier ':C' fail, as expected.
91 1.1 rillig #
92 1.1 rillig TESTS+= no-regex
93 1.1 rillig CPPFLAGS.no-regex= -DNO_REGEX
94 1.1 rillig SKIP_TESTS.no-regex= archive cond-short deptgt-makeflags dollar export-all
95 1.1 rillig SKIP_TESTS.no-regex+= moderrs modmatch modmisc var-eval-short
96 1.1 rillig SKIP_TESTS.no-regex+= varmod-select-words varmod-subst varmod-subst-regex
97 1.1 rillig SKIP_TESTS.no-regex+= varname-dot-make-pid varname-dot-make-ppid
98 1.1 rillig
99 1.1 rillig # NetBSD 8.0 x86_64 says:
100 1.1 rillig # In file included from /usr/include/sys/param.h:115:0,
101 1.1 rillig # from arch.c:135:
102 1.1 rillig # /usr/include/sys/syslimits.h:60:0: error: "PATH_MAX" redefined [-Werror]
103 1.1 rillig TESTS+= path_max
104 1.1 rillig CPPFLAGS.path_max= -DPATH_MAX=20
105 1.1 rillig SKIP.path_max= yes
106 1.1 rillig
107 1.1 rillig # This higher optimization level may trigger additional "may be used
108 1.1 rillig # uninitialized" errors. Could be combined with other compilers as well.
109 1.1 rillig #
110 1.1 rillig TESTS+= opt-3
111 1.1 rillig CFLAGS.opt-3= -O3
112 1.1 rillig
113 1.1 rillig # When optimizing for small code size, GCC gets confused by the initialization
114 1.1 rillig # status of local variables in some cases.
115 1.1 rillig TESTS+= opt-size
116 1.1 rillig CFLAGS.opt-size= -Os
117 1.1 rillig
118 1.1 rillig TESTS+= opt-none
119 1.1 rillig CFLAGS.opt-none= -O0 -ggdb
120 1.1 rillig
121 1.1 rillig # Ensure that every inline function is declared as MAKE_ATTR_UNUSED.
122 1.1 rillig TESTS+= no-inline
123 1.1 rillig CPPFLAGS.no-inline= -Dinline=
124 1.1 rillig
125 1.1 rillig # Is expected to fail with "<stdbool.h> is included in pre-C99 mode" since
126 1.1 rillig # main.c includes <sys/sysctl.h>, which includes <stdbool.h> even in pre-C99
127 1.1 rillig # mode. This would lead to inconsistent definitions of bool and thus
128 1.1 rillig # differently sized struct CmdOpts and others.
129 1.1 rillig TESTS+= c90-plain
130 1.1 rillig ENV.c90-plain= USE_FILEMON=no # filemon uses designated initializers
131 1.1 rillig CFLAGS.c90-plain= -std=c90 -ansi -pedantic -Wno-system-headers
132 1.1 rillig SKIP.c90-plain= yes
133 1.1 rillig
134 1.1 rillig # The make source code is _intended_ to be compatible with C90, it uses some
135 1.1 rillig # C99 features though (snprintf). The workaround with USE_C99_BOOLEAN is
136 1.1 rillig # necessary on NetBSD 9.99 since main.c includes <sys/sysctl.h>, which
137 1.1 rillig # includes <stdbool.h> even in pre-C99 mode.
138 1.1 rillig TESTS+= c90-stdbool
139 1.1 rillig ENV.c90-stdbool= USE_FILEMON=no # filemon uses designated initializers
140 1.1 rillig CFLAGS.c90-stdbool= -std=c90 -ansi -pedantic -Wno-system-headers
141 1.1 rillig CPPFLAGS.c90-stdbool= -DUSE_C99_BOOLEAN
142 1.1 rillig
143 1.1 rillig # Ensure that there are only side-effect-free conditions in the assert
144 1.1 rillig # macro, or at least none that affect the outcome of the tests.
145 1.1 rillig #
146 1.1 rillig TESTS+= no-assert
147 1.1 rillig CPPFLAGS.no-assert= -DNDEBUG
148 1.1 rillig
149 1.1 rillig # Only in native mode, make dares to use a shortcut in Compat_RunCommand
150 1.1 rillig # that circumvents the shell and instead calls execvp directly.
151 1.1 rillig # Another effect is that the shell is run with -q, which prevents the
152 1.1 rillig # -x and -v flags from echoing the commands from profile files.
153 1.1 rillig TESTS+= non-native
154 1.1 rillig CPPFLAGS.non-native= -UMAKE_NATIVE
155 1.1 rillig CPPFLAGS.non-native+= -DHAVE_STRERROR -DHAVE_SETENV -DHAVE_VSNPRINTF
156 1.1 rillig
157 1.1 rillig # Running the code coverage using gcov took a long time on NetBSD < 10, due to
158 1.1 rillig # https://gnats.netbsd.org/55808.
159 1.1 rillig #
160 1.1 rillig # Combining USE_COVERAGE with HAVE_LLVM does not work since ld fails to link
161 1.1 rillig # with the coverage library.
162 1.1 rillig #
163 1.1 rillig # Turning the optimization off is required because gcov does not work on the
164 1.1 rillig # source code level but on the intermediate code after optimization:
165 1.1 rillig # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96622
166 1.1 rillig #
167 1.1 rillig TESTS+= coverage
168 1.1 rillig ENV.coverage= USE_COVERAGE="yes"
169 1.1 rillig CFLAGS.coverage= -O0 -ggdb
170 1.1 rillig
171 1.1 rillig TESTS+= fort
172 1.1 rillig ENV.fort= USE_FORT="yes"
173 1.1 rillig
174 1.1 rillig # Ensure that the tests can be specified either as relative filenames or
175 1.1 rillig # as absolute filenames.
176 1.1 rillig TESTS+= abs
177 1.1 rillig ENV.abs= USE_ABSOLUTE_TESTNAMES="yes"
178 1.1 rillig
179 1.3 rillig # This test is the result of reading through the GCC 10 "Warning Options"
180 1.1 rillig # documentation, noting down everything that sounded interesting.
181 1.1 rillig #
182 1.3 rillig TESTS+= gcc-warn
183 1.3 rillig CFLAGS.gcc-warn= -Wmisleading-indentation
184 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-attributes
185 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-braces
186 1.3 rillig CFLAGS.gcc-warn+= -Wextra
187 1.3 rillig CFLAGS.gcc-warn+= -Wnonnull
188 1.3 rillig CFLAGS.gcc-warn+= -Wnonnull-compare
189 1.3 rillig CFLAGS.gcc-warn+= -Wnull-dereference
190 1.3 rillig CFLAGS.gcc-warn+= -Wimplicit
191 1.3 rillig CFLAGS.gcc-warn+= -Wimplicit-fallthrough=4
192 1.3 rillig CFLAGS.gcc-warn+= -Wignored-qualifiers
193 1.3 rillig CFLAGS.gcc-warn+= -Wunused
194 1.3 rillig CFLAGS.gcc-warn+= -Wunused-but-set-variable
195 1.3 rillig CFLAGS.gcc-warn+= -Wunused-parameter
196 1.3 rillig CFLAGS.gcc-warn+= -Wduplicated-branches
197 1.3 rillig CFLAGS.gcc-warn+= -Wduplicated-cond
198 1.3 rillig CFLAGS.gcc-warn+= -Wunused-macros
199 1.3 rillig CFLAGS.gcc-warn+= -Wcast-function-type
200 1.3 rillig CFLAGS.gcc-warn+= -Wconversion
201 1.3 rillig CFLAGS.gcc-warn+= -Wenum-compare
202 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-field-initializers
203 1.3 rillig CFLAGS.gcc-warn+= -Wredundant-decls
204 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=conversion
205 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=sign-conversion
206 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=unused-macros
207 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=unused-parameter
208 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=duplicated-branches
209 1.1 rillig
210 1.1 rillig .for shell in /usr/pkg/bin/bash /usr/pkg/bin/dash
211 1.1 rillig . if exists(${shell})
212 1.1 rillig TESTS+= ${shell:T}
213 1.1 rillig CPPFLAGS.${shell:T}= -DDEFSHELL_CUSTOM="\"${shell}\""
214 1.1 rillig . endif
215 1.1 rillig .endfor
216 1.1 rillig
217 1.1 rillig
218 1.1 rillig .MAKEFLAGS: -k
219 1.1 rillig .MAKE.DEPENDFILE= nonexistent
220 1.1 rillig
221 1.1 rillig .PHONY: usage list all ${TESTS}
222 1.1 rillig
223 1.1 rillig all: ${TESTS:${TESTS:@t@${SKIP.$t:Myes:%=N$t}@:ts:}}
224 1.1 rillig
225 1.1 rillig SLOW_TESTS= dotwait sh-flags
226 1.1 rillig
227 1.1 rillig .for test in ${TESTS}
228 1.1 rillig _ENV.${test}= PATH="$$PATH"
229 1.1 rillig _ENV.${test}+= USETOOLS="no"
230 1.1 rillig _ENV.${test}+= MALLOC_OPTIONS="JA" # for jemalloc 1.0.0
231 1.1 rillig _ENV.${test}+= MALLOC_CONF="junk:true" # for jemalloc 5.1.0
232 1.1 rillig _ENV.${test}+= _MKMSG_COMPILE=":"
233 1.1 rillig _ENV.${test}+= _MKMSG_CREATE=":"
234 1.1 rillig _ENV.${test}+= _MKMSG_FORMAT=":"
235 1.1 rillig _ENV.${test}+= _MKMSG_TEST=":"
236 1.1 rillig _ENV.${test}+= ${ENV.${test}}
237 1.1 rillig _ENV.${test}+= USER_CPPFLAGS=${CPPFLAGS.${.TARGET}:Q}
238 1.1 rillig _ENV.${test}+= USER_CFLAGS=${CFLAGS.${.TARGET}:Q}
239 1.1 rillig _ENV.${test}+= BROKEN_TESTS=${${SLOW_TESTS} ${SKIP_TESTS.${.TARGET}}:L:Q}
240 1.1 rillig .endfor
241 1.1 rillig
242 1.1 rillig ${TESTS}: run-test
243 1.1 rillig run-test: .USE
244 1.1 rillig @echo "===> Running ${.TARGET}"
245 1.1 rillig @echo "env: "${ENV.${.TARGET}:U"(none)"}
246 1.1 rillig @echo "cflags: "${CFLAGS.${.TARGET}:U(none):Q}
247 1.1 rillig @echo "cppflags: "${CPPFLAGS.${.TARGET}:U(none):Q}
248 1.1 rillig
249 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -s cleandir"
250 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -ks -j6 dependall"
251 1.1 rillig @size *.o make
252 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -s test"
253 1.1 rillig
254 1.1 rillig list:
255 1.1 rillig @printf '%s%s\n' ${TESTS:O:@t@$t '${SKIP.$t:Myes:%= (skipped)}'@}
256