libfmd_agent: make fmd_agent_cpu_* visible even on 64-bit
[unleashed.git] / bin / make / unit-tests / Makefile
blobbc4545b92325caa89e73c6e7935b179b09c3625f
1 # $Id: Makefile.in,v 1.48 2015/12/07 04:06:29 sjg Exp $
3 # $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
5 # Unit tests for make(1)
6 # The main targets are:
7 #
8 # all: run all the tests
9 # test: run 'all', and compare to expected results
10 # accept: move generated output to expected results
12 # Adding a test case.
13 # Each feature should get its own set of tests in its own suitably
14 # named makefile (*.mk), with its own set of expected results (*.exp),
15 # and it should be added to the TESTNAMES list.
18 .MAIN: all
20 UNIT_TESTS:= ${.CURDIR}
21 .PATH: ${UNIT_TESTS}
23 # Each test is in a sub-makefile.
24 # Keep the list sorted.
25 TESTNAMES= \
26 comment \
27 cond1 \
28 cond2 \
29 error \
30 export \
31 export-all \
32 export-env \
33 doterror \
34 dotwait \
35 forloop \
36 forsubst \
37 hash \
38 misc \
39 moderrs \
40 modmatch \
41 modmisc \
42 modorder \
43 modts \
44 modword \
45 order \
46 posix \
47 qequals \
48 sunshcmd \
49 sysv \
50 ternary \
51 unexport \
52 unexport-env \
53 varcmd \
54 varmisc \
55 varshell
57 # these tests were broken by referting POSIX chanegs
58 STRICT_POSIX_TESTS = \
59 escape \
60 impsrc \
61 phony-end \
62 posix1 \
63 suffixes
65 # Override make flags for certain tests
66 flags.doterror=
67 flags.order=-j1
69 OUTFILES= ${TESTNAMES:S/$/.out/}
71 all: ${OUTFILES}
73 CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
74 CLEANFILES += obj*.[och] lib*.a # posix1.mk
75 CLEANFILES += issue* .[ab]* # suffixes.mk
76 CLEANRECURSIVE += dir dummy # posix1.mk
78 clean:
79 rm -f ${CLEANFILES}
80 .if !empty(CLEANRECURSIVE)
81 rm -rf ${CLEANRECURSIVE}
82 .endif
84 TEST_MAKE?= ${.MAKE}
85 TOOL_SED?= sed
86 TOOL_TR?= tr
87 TOOL_DIFF?= diff
88 DIFF_FLAGS?= -u
90 .if defined(.PARSEDIR)
91 # ensure consistent results from sort(1)
92 LC_ALL= C
93 LANG= C
94 .export LANG LC_ALL
95 .endif
97 # some tests need extra post-processing
98 SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
99 -e '/command/s,No such.*,not found,'
101 # the tests are actually done with sub-makes.
102 .SUFFIXES: .mk .rawout .out
103 .mk.rawout:
104 @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
105 -@cd ${.OBJDIR} && \
106 { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
107 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
108 @mv ${.TARGET}.tmp ${.TARGET}
110 # We always pretend .MAKE was called 'make'
111 # and strip ${.CURDIR}/ from the output
112 # and replace anything after 'stopped in' with unit-tests
113 # so the results can be compared.
114 .rawout.out:
115 @echo postprocess ${.TARGET}
116 @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
117 -e 's,${TEST_MAKE:C/\./\\\./g},make,' \
118 -e '/stopped/s, /.*, unit-tests,' \
119 -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
120 -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
121 < ${.IMPSRC} > ${.TARGET}.tmp
122 @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
123 @mv ${.TARGET}.tmp ${.TARGET}
125 # Compare all output files
126 test: ${OUTFILES} .PHONY
127 @failed= ; \
128 for test in ${TESTNAMES}; do \
129 ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
130 || failed="$${failed}$${failed:+ }$${test}" ; \
131 done ; \
132 if [ -n "$${failed}" ]; then \
133 echo "Failed tests: $${failed}" ; false ; \
134 else \
135 echo "All tests passed" ; \
138 accept:
139 @for test in ${TESTNAMES}; do \
140 cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
141 || { echo "Replacing $${test}.exp" ; \
142 cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
143 done
145 .if exists(${TEST_MAKE})
146 ${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
147 .endif
149 .sinclude <bsd.obj.mk>