test-variants.mk revision 1.5 1 1.5 rillig # $NetBSD: test-variants.mk,v 1.5 2023/01/19 19:55:27 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.5 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 # NetBSD 8.0 x86_64
78 1.1 rillig # In file included from arch.c:135:0:
79 1.1 rillig # /usr/include/sys/param.h:357:0: error: "MAXPATHLEN" redefined [-Werror]
80 1.1 rillig TESTS+= maxpathlen
81 1.1 rillig CPPFLAGS.maxpathlen= -DMAXPATHLEN=20
82 1.1 rillig SKIP.maxpathlen= yes
83 1.1 rillig
84 1.1 rillig # In this variant, the unit tests using the modifier ':C' fail, as expected.
85 1.1 rillig #
86 1.1 rillig TESTS+= no-regex
87 1.1 rillig CPPFLAGS.no-regex= -DNO_REGEX
88 1.1 rillig SKIP_TESTS.no-regex= archive cond-short deptgt-makeflags dollar export-all
89 1.1 rillig SKIP_TESTS.no-regex+= moderrs modmatch modmisc var-eval-short
90 1.1 rillig SKIP_TESTS.no-regex+= varmod-select-words varmod-subst varmod-subst-regex
91 1.1 rillig SKIP_TESTS.no-regex+= varname-dot-make-pid varname-dot-make-ppid
92 1.1 rillig
93 1.1 rillig # NetBSD 8.0 x86_64 says:
94 1.1 rillig # In file included from /usr/include/sys/param.h:115:0,
95 1.1 rillig # from arch.c:135:
96 1.1 rillig # /usr/include/sys/syslimits.h:60:0: error: "PATH_MAX" redefined [-Werror]
97 1.1 rillig TESTS+= path_max
98 1.1 rillig CPPFLAGS.path_max= -DPATH_MAX=20
99 1.1 rillig SKIP.path_max= yes
100 1.1 rillig
101 1.1 rillig # This higher optimization level may trigger additional "may be used
102 1.1 rillig # uninitialized" errors. Could be combined with other compilers as well.
103 1.1 rillig #
104 1.1 rillig TESTS+= opt-3
105 1.1 rillig CFLAGS.opt-3= -O3
106 1.1 rillig
107 1.1 rillig # When optimizing for small code size, GCC gets confused by the initialization
108 1.1 rillig # status of local variables in some cases.
109 1.1 rillig TESTS+= opt-size
110 1.1 rillig CFLAGS.opt-size= -Os
111 1.1 rillig
112 1.1 rillig TESTS+= opt-none
113 1.1 rillig CFLAGS.opt-none= -O0 -ggdb
114 1.1 rillig
115 1.1 rillig # Ensure that every inline function is declared as MAKE_ATTR_UNUSED.
116 1.1 rillig TESTS+= no-inline
117 1.1 rillig CPPFLAGS.no-inline= -Dinline=
118 1.1 rillig
119 1.1 rillig # Is expected to fail with "<stdbool.h> is included in pre-C99 mode" since
120 1.1 rillig # main.c includes <sys/sysctl.h>, which includes <stdbool.h> even in pre-C99
121 1.1 rillig # mode. This would lead to inconsistent definitions of bool and thus
122 1.1 rillig # differently sized struct CmdOpts and others.
123 1.1 rillig TESTS+= c90-plain
124 1.1 rillig ENV.c90-plain= USE_FILEMON=no # filemon uses designated initializers
125 1.1 rillig CFLAGS.c90-plain= -std=c90 -ansi -pedantic -Wno-system-headers
126 1.1 rillig SKIP.c90-plain= yes
127 1.1 rillig
128 1.1 rillig # The make source code is _intended_ to be compatible with C90, it uses some
129 1.1 rillig # C99 features though (snprintf). The workaround with USE_C99_BOOLEAN is
130 1.1 rillig # necessary on NetBSD 9.99 since main.c includes <sys/sysctl.h>, which
131 1.1 rillig # includes <stdbool.h> even in pre-C99 mode.
132 1.1 rillig TESTS+= c90-stdbool
133 1.1 rillig ENV.c90-stdbool= USE_FILEMON=no # filemon uses designated initializers
134 1.1 rillig CFLAGS.c90-stdbool= -std=c90 -ansi -pedantic -Wno-system-headers
135 1.1 rillig CPPFLAGS.c90-stdbool= -DUSE_C99_BOOLEAN
136 1.1 rillig
137 1.1 rillig # Ensure that there are only side-effect-free conditions in the assert
138 1.1 rillig # macro, or at least none that affect the outcome of the tests.
139 1.1 rillig #
140 1.1 rillig TESTS+= no-assert
141 1.1 rillig CPPFLAGS.no-assert= -DNDEBUG
142 1.1 rillig
143 1.1 rillig # Only in native mode, make dares to use a shortcut in Compat_RunCommand
144 1.1 rillig # that circumvents the shell and instead calls execvp directly.
145 1.1 rillig # Another effect is that the shell is run with -q, which prevents the
146 1.1 rillig # -x and -v flags from echoing the commands from profile files.
147 1.1 rillig TESTS+= non-native
148 1.1 rillig CPPFLAGS.non-native= -UMAKE_NATIVE
149 1.1 rillig CPPFLAGS.non-native+= -DHAVE_STRERROR -DHAVE_SETENV -DHAVE_VSNPRINTF
150 1.1 rillig
151 1.1 rillig # Running the code coverage using gcov took a long time on NetBSD < 10, due to
152 1.1 rillig # https://gnats.netbsd.org/55808.
153 1.1 rillig #
154 1.1 rillig # Combining USE_COVERAGE with HAVE_LLVM does not work since ld fails to link
155 1.1 rillig # with the coverage library.
156 1.1 rillig #
157 1.1 rillig # Turning the optimization off is required because gcov does not work on the
158 1.1 rillig # source code level but on the intermediate code after optimization:
159 1.1 rillig # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96622
160 1.1 rillig #
161 1.1 rillig TESTS+= coverage
162 1.1 rillig ENV.coverage= USE_COVERAGE="yes"
163 1.1 rillig CFLAGS.coverage= -O0 -ggdb
164 1.1 rillig
165 1.1 rillig TESTS+= fort
166 1.1 rillig ENV.fort= USE_FORT="yes"
167 1.1 rillig
168 1.1 rillig # Ensure that the tests can be specified either as relative filenames or
169 1.1 rillig # as absolute filenames.
170 1.1 rillig TESTS+= abs
171 1.1 rillig ENV.abs= USE_ABSOLUTE_TESTNAMES="yes"
172 1.1 rillig
173 1.3 rillig # This test is the result of reading through the GCC 10 "Warning Options"
174 1.1 rillig # documentation, noting down everything that sounded interesting.
175 1.1 rillig #
176 1.3 rillig TESTS+= gcc-warn
177 1.3 rillig CFLAGS.gcc-warn= -Wmisleading-indentation
178 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-attributes
179 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-braces
180 1.3 rillig CFLAGS.gcc-warn+= -Wextra
181 1.3 rillig CFLAGS.gcc-warn+= -Wnonnull
182 1.3 rillig CFLAGS.gcc-warn+= -Wnonnull-compare
183 1.3 rillig CFLAGS.gcc-warn+= -Wnull-dereference
184 1.3 rillig CFLAGS.gcc-warn+= -Wimplicit
185 1.3 rillig CFLAGS.gcc-warn+= -Wimplicit-fallthrough=4
186 1.3 rillig CFLAGS.gcc-warn+= -Wignored-qualifiers
187 1.3 rillig CFLAGS.gcc-warn+= -Wunused
188 1.3 rillig CFLAGS.gcc-warn+= -Wunused-but-set-variable
189 1.3 rillig CFLAGS.gcc-warn+= -Wunused-parameter
190 1.3 rillig CFLAGS.gcc-warn+= -Wduplicated-branches
191 1.3 rillig CFLAGS.gcc-warn+= -Wduplicated-cond
192 1.3 rillig CFLAGS.gcc-warn+= -Wunused-macros
193 1.3 rillig CFLAGS.gcc-warn+= -Wcast-function-type
194 1.3 rillig CFLAGS.gcc-warn+= -Wconversion
195 1.3 rillig CFLAGS.gcc-warn+= -Wenum-compare
196 1.3 rillig CFLAGS.gcc-warn+= -Wmissing-field-initializers
197 1.3 rillig CFLAGS.gcc-warn+= -Wredundant-decls
198 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=conversion
199 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=sign-conversion
200 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=unused-macros
201 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=unused-parameter
202 1.3 rillig CFLAGS.gcc-warn+= -Wno-error=duplicated-branches
203 1.1 rillig
204 1.1 rillig .for shell in /usr/pkg/bin/bash /usr/pkg/bin/dash
205 1.1 rillig . if exists(${shell})
206 1.1 rillig TESTS+= ${shell:T}
207 1.1 rillig CPPFLAGS.${shell:T}= -DDEFSHELL_CUSTOM="\"${shell}\""
208 1.1 rillig . endif
209 1.1 rillig .endfor
210 1.1 rillig
211 1.1 rillig
212 1.1 rillig .MAKEFLAGS: -k
213 1.1 rillig .MAKE.DEPENDFILE= nonexistent
214 1.1 rillig
215 1.1 rillig .PHONY: usage list all ${TESTS}
216 1.1 rillig
217 1.1 rillig all: ${TESTS:${TESTS:@t@${SKIP.$t:Myes:%=N$t}@:ts:}}
218 1.1 rillig
219 1.1 rillig SLOW_TESTS= dotwait sh-flags
220 1.1 rillig
221 1.1 rillig .for test in ${TESTS}
222 1.1 rillig _ENV.${test}= PATH="$$PATH"
223 1.1 rillig _ENV.${test}+= USETOOLS="no"
224 1.1 rillig _ENV.${test}+= MALLOC_OPTIONS="JA" # for jemalloc 1.0.0
225 1.1 rillig _ENV.${test}+= MALLOC_CONF="junk:true" # for jemalloc 5.1.0
226 1.1 rillig _ENV.${test}+= _MKMSG_COMPILE=":"
227 1.1 rillig _ENV.${test}+= _MKMSG_CREATE=":"
228 1.1 rillig _ENV.${test}+= _MKMSG_FORMAT=":"
229 1.1 rillig _ENV.${test}+= _MKMSG_TEST=":"
230 1.1 rillig _ENV.${test}+= ${ENV.${test}}
231 1.1 rillig _ENV.${test}+= USER_CPPFLAGS=${CPPFLAGS.${.TARGET}:Q}
232 1.1 rillig _ENV.${test}+= USER_CFLAGS=${CFLAGS.${.TARGET}:Q}
233 1.1 rillig _ENV.${test}+= BROKEN_TESTS=${${SLOW_TESTS} ${SKIP_TESTS.${.TARGET}}:L:Q}
234 1.1 rillig .endfor
235 1.1 rillig
236 1.1 rillig ${TESTS}: run-test
237 1.1 rillig run-test: .USE
238 1.1 rillig @echo "===> Running ${.TARGET}"
239 1.1 rillig @echo "env: "${ENV.${.TARGET}:U"(none)"}
240 1.1 rillig @echo "cflags: "${CFLAGS.${.TARGET}:U(none):Q}
241 1.1 rillig @echo "cppflags: "${CPPFLAGS.${.TARGET}:U(none):Q}
242 1.1 rillig
243 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -s cleandir"
244 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -ks -j6 dependall"
245 1.1 rillig @size *.o make
246 1.1 rillig @env -i ${_ENV.${.TARGET}} sh -ce "ma""ke -s test"
247 1.1 rillig
248 1.1 rillig list:
249 1.1 rillig @printf '%s%s\n' ${TESTS:O:@t@$t '${SKIP.$t:Myes:%= (skipped)}'@}
250