opt-jobs.mk revision 1.4 1 # $NetBSD: opt-jobs.mk,v 1.4 2023/09/10 11:41:33 rillig 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.
8 ARGS= 0 1 2 8 08 017 0x10 -5 1000
9 EXPECT.0= argument '0' to option '-j' must be a positive number (exit 2)
10 EXPECT.1= 1
11 EXPECT.2= 2
12 EXPECT.8= 8
13 EXPECT.08= argument '08' to option '-j' must be a positive number (exit 2)
14 EXPECT.017= 15
15 EXPECT.0x10= 16
16 EXPECT.-5= argument '-5' to option '-j' must be a positive number (exit 2)
17 EXPECT.1000= 1000
18
19 .for arg in ${ARGS}
20 OUTPUT!= ${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.
29 ARGS= 0.0 0C 0.0C .00001 .00001C 1C 1CPUs 1.2 .5e1C 07.5C 08.5C
30 EXPECT.0.0= argument '0.0' to option '-j' must be a positive number (exit 2)
31 EXPECT.0C= <integer> # rounded up to 1C
32 EXPECT.0.0C= argument '0.0C' to option '-j' must be a positive number (exit 2)
33 EXPECT..00001= argument '.00001' to option '-j' must be a positive number (exit 2)
34 EXPECT..00001C= argument '.00001C' to option '-j' must be a positive number (exit 2)
35 EXPECT.1C= <integer>
36 EXPECT.1CPUs= <integer>
37 EXPECT.1.2= <integer>
38 EXPECT..5e1C= <integer> # unlikely to occur in practice
39 EXPECT.07.5C= <integer>
40 EXPECT.08.5C= argument '08.5C' to option '-j' must be a positive number (exit 2)
41
42 .if ${.MAKE.JOBS.C}
43 . for arg in ${ARGS}
44 OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)"
45 . if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric
46 OUTPUT= <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
54 all: .PHONY
55