bsd.regress.mk revision 1.10
1# $OpenBSD: bsd.regress.mk,v 1.10 2002/09/02 19:56:55 avsm Exp $
2# Documented in bsd.regress.mk(5)
3
4# No man pages for regression tests.
5NOMAN=
6
7# No installation.
8install:
9
10# If REGRESS_TARGETS is defined and PROG is not defined, set NOPROG
11.if defined(REGRESS_TARGETS) && !defined(PROG)
12NOPROG=
13.endif
14
15.include <bsd.prog.mk>
16
17.MAIN: all
18all: regress
19
20# Check for deprecated REGRESS* variables and assign them to the
21# new versions if the new version is not already defined. 
22_REGRESS_DEPRECATED=LOG:LOG SKIPTARGETS:SKIP_TARGETS SKIPSLOW:SKIP_SLOW \
23	SKIP:SKIP TARGETS:TARGETS MAXTIME:MAXTIME ROOTTARGETS:ROOT_TARGETS
24
25.for _I in ${_REGRESS_DEPRECATED}
26_REGRESS_OLD=REGRESS${_I:C/\:.*//}
27_REGRESS_NEW=REGRESS_${_I:C/.*\://}
28.  if defined(${_REGRESS_OLD})
29ERRORS:= ${ERRORS} "Warning: ${_REGRESS_OLD} is deprecated, use ${_REGRESS_NEW} instead."
30.    if !defined(${_REGRESS_NEW})
31${_REGRESS_NEW}:=${${_REGRESS_OLD}}
32.    endif
33.  endif
34.endfor
35
36# XXX - Need full path to REGRESS_LOG, otherwise there will be much pain.
37REGRESS_LOG?=/dev/null
38REGRESS_SKIP_TARGETS?=
39REGRESS_SKIP_SLOW?=no
40
41_REGRESS_NAME=${.CURDIR:S/${BSDSRCDIR}\/regress\///}
42_REGRESS_TMP?=/dev/null
43_REGRESS_OUT= | tee -a ${REGRESS_LOG} ${_REGRESS_TMP} 2>&1 > /dev/null
44
45.if defined(PROG) && !empty(PROG)
46run-regress-${PROG}: ${PROG}
47	./${PROG}
48.endif
49
50.if !defined(REGRESS_TARGETS)
51REGRESS_TARGETS=run-regress-${PROG}
52.  if defined(REGRESS_SKIP)
53REGRESS_SKIP_TARGETS=run-regress-${PROG}
54.  endif
55.endif
56
57.if defined(REGRESS_SLOW_TARGETS) && !empty(REGRESS_SKIP_SLOW)
58REGRESS_SKIP_TARGETS+=${REGRESS_SLOW_TARGETS}
59.endif
60
61.if defined(REGRESS_ROOT_TARGETS)
62_ROOTUSER!=id -g
63SUDO?=
64.  if (${_ROOTUSER} != 0) && empty(SUDO)
65REGRESS_SKIP_TARGETS+=${REGRESS_ROOT_TARGETS}
66.  endif
67.endif
68
69.if defined(ERRORS)
70.BEGIN:
71.  for _m in ${ERRORS}
72	@echo 1>&2 ${_m}
73.  endfor
74.  if !empty(ERRORS:M"Fatal\:*") || !empty(ERRORS:M'Fatal\:*')
75	@exit 1
76.  endif
77.endif 
78
79regress: .SILENT
80.if ! ${REGRESS_LOG:M/*}
81	echo =========================================================
82	echo REGRESS_LOG must contain an absolute path to the log-file.
83	echo It currently points to: ${REGRESS_LOG}
84	echo =========================================================
85	exit 1
86.endif
87.for RT in ${REGRESS_TARGETS} 
88.  if ${REGRESS_SKIP_TARGETS:M${RT}}
89	@echo -n "SKIP " ${_REGRESS_OUT}
90.  else
91# XXX - we need a better method to see if a test fails due to timeout or just
92#       normal failure.
93.   if !defined(REGRESS_MAXTIME)
94	-if cd ${.CURDIR} && ${MAKE} ${RT}; then \
95	    echo -n "SUCCESS " ${_REGRESS_OUT} ; \
96	else \
97	    echo -n "FAIL " ${_REGRESS_OUT} ; \
98	    echo FAILED ; \
99	fi
100.   else
101	-if cd ${.CURDIR} && (ulimit -t ${REGRESS_MAXTIME} ; ${MAKE} ${RT}); then \
102	    echo -n "SUCCESS " ${_REGRESS_OUT} ; \
103	else \
104	    echo -n "FAIL (possible timeout) " ${_REGRESS_OUT} ; \
105	    echo FAILED ; \
106	fi
107.   endif
108.  endif
109	@echo ${_REGRESS_NAME}/${RT:S/^run-regress-//} ${_REGRESS_OUT}
110.endfor
111
112.PHONY: regress
113