]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/atf.test.mk
Import device-tree files from Linux 6.0
[FreeBSD/FreeBSD.git] / share / mk / atf.test.mk
1 # $FreeBSD$
2 #
3 # You must include bsd.test.mk instead of this file from your Makefile.
4 #
5 # Logic to build and install ATF test programs; i.e. test programs linked
6 # against the ATF libraries.
7
8 .if !target(__<bsd.test.mk>__)
9 .error atf.test.mk cannot be included directly.
10 .endif
11
12 # List of C, C++ and shell test programs to build.
13 #
14 # Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS,
15 # respectively, from bsd.prog.mk.  However, the build rules are tweaked to
16 # require the ATF libraries.
17 #
18 # Test programs registered in this manner are set to be installed into TESTSDIR
19 # (which should be overridden by the Makefile) and are not required to provide a
20 # manpage.
21 ATF_TESTS_C?=
22 ATF_TESTS_CXX?=
23 ATF_TESTS_SH?=
24 ATF_TESTS_KSH93?=
25 ATF_TESTS_PYTEST?=
26
27 .if !empty(ATF_TESTS_C)
28 PROGS+= ${ATF_TESTS_C}
29 _TESTS+= ${ATF_TESTS_C}
30 .for _T in ${ATF_TESTS_C}
31 BINDIR.${_T}= ${TESTSDIR}
32 MAN.${_T}?= # empty
33 SRCS.${_T}?= ${_T}.c
34 DPADD.${_T}+= ${LIBATF_C}
35 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
36 LDADD.${_T}+= ${LDADD_atf_c}
37 .else
38 LDADD.${_T}+= ${LIBATF_C}
39 .endif
40 TEST_INTERFACE.${_T}= atf
41 .endfor
42 .endif
43
44 .if !empty(ATF_TESTS_CXX)
45 PROGS_CXX+= ${ATF_TESTS_CXX}
46 _TESTS+= ${ATF_TESTS_CXX}
47 .for _T in ${ATF_TESTS_CXX}
48 BINDIR.${_T}= ${TESTSDIR}
49 MAN.${_T}?= # empty
50 SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
51 DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
52 .if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
53 LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
54 .else
55 LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
56 .endif
57 TEST_INTERFACE.${_T}= atf
58 .endfor
59 # Silence warnings about usage of deprecated std::auto_ptr
60 CXXWARNFLAGS+=  -Wno-deprecated-declarations
61 .endif
62
63 .if !empty(ATF_TESTS_SH)
64 SCRIPTS+= ${ATF_TESTS_SH}
65 _TESTS+= ${ATF_TESTS_SH}
66 .for _T in ${ATF_TESTS_SH}
67 SCRIPTSDIR_${_T}= ${TESTSDIR}
68 TEST_INTERFACE.${_T}= atf
69 CLEANFILES+= ${_T} ${_T}.tmp
70 # TODO(jmmv): It seems to me that this SED and SRC functionality should
71 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
72 # this proves to be useful within the tests.
73 ATF_TESTS_SH_SED_${_T}?= # empty
74 ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh
75 ${_T}: ${ATF_TESTS_SH_SRC_${_T}}
76         echo '#! /usr/libexec/atf-sh' > ${.TARGET}.tmp
77 .if empty(ATF_TESTS_SH_SED_${_T})
78         cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
79 .else
80         cat ${.ALLSRC:N*Makefile*} \
81             | sed ${ATF_TESTS_SH_SED_${_T}} >>${.TARGET}.tmp
82 .endif
83         chmod +x ${.TARGET}.tmp
84         mv ${.TARGET}.tmp ${.TARGET}
85 .endfor
86 .endif
87
88 .if !empty(ATF_TESTS_KSH93)
89 SCRIPTS+= ${ATF_TESTS_KSH93}
90 _TESTS+= ${ATF_TESTS_KSH93}
91 .for _T in ${ATF_TESTS_KSH93}
92 SCRIPTSDIR_${_T}= ${TESTSDIR}
93 TEST_INTERFACE.${_T}= atf
94 TEST_METADATA.${_T}+= required_programs="ksh93"
95 CLEANFILES+= ${_T} ${_T}.tmp
96 # TODO(jmmv): It seems to me that this SED and SRC functionality should
97 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
98 # this proves to be useful within the tests.
99 ATF_TESTS_KSH93_SED_${_T}?= # empty
100 ATF_TESTS_KSH93_SRC_${_T}?= ${_T}.sh
101 ${_T}: ${ATF_TESTS_KSH93_SRC_${_T}}
102         echo '#! /usr/libexec/atf-sh -s/usr/local/bin/ksh93' > ${.TARGET}.tmp
103 .if empty(ATF_TESTS_KSH93_SED_${_T})
104         cat ${.ALLSRC:N*Makefile*} >>${.TARGET}.tmp
105 .else
106         cat ${.ALLSRC:N*Makefile*} \
107             | sed ${ATF_TESTS_KSH93_SED_${_T}} >>${.TARGET}.tmp
108 .endif
109         chmod +x ${.TARGET}.tmp
110         mv ${.TARGET}.tmp ${.TARGET}
111 .endfor
112 .endif
113
114 .if !empty(ATF_TESTS_PYTEST)
115 # bsd.prog.mk SCRIPTS interface removes file extension unless
116 # SCRIPTSNAME is set, which is not possible to do here.
117 # Workaround this by appending another extension (.xtmp) to the
118 # file name. Use separate loop to avoid dealing with explicitly
119 # stating expansion for each and every variable.
120 #
121 # ATF_TESTS_PYTEST -> contains list of files as is (test_something.py ..)
122 # _ATF_TESTS_PYTEST -> (test_something.py.xtmp ..)
123 #
124 # Former array is iterated to construct Kyuafile, where original file
125 #  names need to be written.
126 # Latter array is iterated to enable bsd.prog.mk scripts framework -
127 #  namely, installing scripts without .xtmp prefix. Note: this allows to
128 #  not bother about the fact that make target needs to be different from
129 #  the source file.
130 _TESTS+= ${ATF_TESTS_PYTEST}
131 _ATF_TESTS_PYTEST=
132 .for _T in ${ATF_TESTS_PYTEST}
133 _ATF_TESTS_PYTEST += ${_T}.xtmp
134 TEST_INTERFACE.${_T}= atf
135 TEST_METADATA.${_T}+= required_programs="pytest"
136 .endfor
137
138 SCRIPTS+= ${_ATF_TESTS_PYTEST}
139 .for _T in ${_ATF_TESTS_PYTEST}
140 SCRIPTSDIR_${_T}= ${TESTSDIR}
141 CLEANFILES+= ${_T} ${_T}.tmp
142 # TODO(jmmv): It seems to me that this SED and SRC functionality should
143 # exist in bsd.prog.mk along the support for SCRIPTS.  Move it there if
144 # this proves to be useful within the tests.
145 ATF_TESTS_PYTEST_SED_${_T}?= # empty
146 ATF_TESTS_PYTEST_SRC_${_T}?= ${.CURDIR}/${_T:S,.xtmp$,,}
147 ${_T}:
148         echo "#! /usr/libexec/atf_pytest_wrapper -P ${TESTSBASE}" > ${.TARGET}.tmp
149 .if empty(ATF_TESTS_PYTEST_SED_${_T})
150         cat ${ATF_TESTS_PYTEST_SRC_${_T}}  >>${.TARGET}.tmp
151 .else
152         cat ${ATF_TESTS_PYTEST_SRC_${_T}} \
153             | sed ${ATF_TESTS_PYTEST_SED_${_T}} >>${.TARGET}.tmp
154 .endif
155         chmod +x ${.TARGET}.tmp
156         mv ${.TARGET}.tmp ${.TARGET}
157 .endfor
158 .endif