xref: /freebsd/contrib/bmake/unit-tests/opt-jobs.mk (revision 67be1e195acfaec99ce4fffeb17111ce085755f7)
1# $NetBSD: opt-jobs.mk,v 1.5 2023/09/10 16:25:32 sjg Exp $
2#
3# Tests for the -j command line option, which creates the targets in parallel.
4
5
6# The option '-j <integer>' specifies the number of targets that can be made
7# in parallel.
8ARGS=		0 1 2 8 08 017 0x10 -5 1000
9EXPECT.0=	argument '0' to option '-j' must be a positive number (exit 2)
10EXPECT.1=	1
11EXPECT.2=	2
12EXPECT.8=	8
13EXPECT.08=	argument '08' to option '-j' must be a positive number (exit 2)
14EXPECT.017=	15
15EXPECT.0x10=	16
16EXPECT.-5=	argument '-5' to option '-j' must be a positive number (exit 2)
17EXPECT.1000=	1000
18
19.for arg in ${ARGS}
20OUTPUT!=	${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)"
21.  if ${OUTPUT:[2..-1]} != ${EXPECT.${arg}}
22.      warning ${arg}:${.newline}    have: ${OUTPUT:[2..-1]}${.newline}    want: ${EXPECT.${arg}}
23.  endif
24.endfor
25
26
27# The options '-j <float>' and '-j <integer>C' multiply the given number with
28# the number of available CPUs.
29ARGS=		0.0 0C 0.0C .00001 .00001C 1C 1CPUs 1.2 .5e1C 07.5C 08.5C
30EXPECT.0.0=	argument '0.0' to option '-j' must be a positive number (exit 2)
31EXPECT.0C=	<integer>		# rounded up to 1C
32EXPECT.0.0C=	argument '0.0C' to option '-j' must be a positive number (exit 2)
33EXPECT..00001=	argument '.00001' to option '-j' must be a positive number (exit 2)
34EXPECT..00001C=	argument '.00001C' to option '-j' must be a positive number (exit 2)
35EXPECT.1C=	<integer>
36EXPECT.1CPUs=	<integer>
37EXPECT.1.2=	<integer>
38EXPECT..5e1C=	<integer>		# unlikely to occur in practice
39EXPECT.07.5C=	<integer>
40EXPECT.08.5C=	argument '08.5C' to option '-j' must be a positive number (exit 2)
41
42.if ${.MAKE.JOBS.C} == "yes"
43.  for arg in ${ARGS}
44OUTPUT!=	${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)"
45.    if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric
46OUTPUT=		<integer>
47.    endif
48.    if ${OUTPUT:[2..-1]} != ${EXPECT.${arg}}
49.      warning ${arg}:${.newline}    have: ${OUTPUT:[2..-1]}${.newline}    want: ${EXPECT.${arg}}
50.    endif
51.  endfor
52.endif
53
54all: .PHONY
55