Debian Codegraph @

tests/scripts/features/jobserver

raw
1 # -*-perl-*-
2
3 $description = "Test jobserver.";
4
5 $details = "These tests are ones that specifically are different when the
6 jobserver feature is available. Most -j tests are the same whether or not
7 jobserver is available, and those appear in the 'parallelism' test suite.";
8
9 exists $FEATURES{'jobserver'} or return -1;
10
11 if (!$parallel_jobs) {
12 return -1;
13 }
14
15 # Shorthand
16 my $np = '--no-print-directory';
17
18 # Simple test of MAKEFLAGS settings
19 run_make_test(q!
20 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
21 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
22 all:;@echo $@: "/$(SHOW)/"
23 !,
24 "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
25
26 # Setting parallelism with the environment
27 # Command line should take precedence over the environment
28 $extraENV{MAKEFLAGS} = "-j2 $np";
29 run_make_test(q!
30 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
31 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
32 all:;@echo $@: "/$(SHOW)/"
33 !,
34 '', "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
35 delete $extraENV{MAKEFLAGS};
36
37 # Test override of -jN
38 $extraENV{MAKEFLAGS} = "-j9 $np";
39 run_make_test(q!
40 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
41 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j3 -f #MAKEFILE# recurse2
42 recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
43 all:;@echo $@: "/$(SHOW)/"
44 !,
45 "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j3 forced in submake: resetting jobserver mode.\nrecurse2: /-j3 --jobserver-auth=<auth> $np/\nall: /-j3 --jobserver-auth=<auth> $np/\n");
46 delete $extraENV{MAKEFLAGS};
47
48 # Test override of -jN with -j
49 run_make_test(q!
50 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
51 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j -f #MAKEFILE# recurse2
52 recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
53 all:;@echo $@: "/$(SHOW)/"
54 !,
55 "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j0 forced in submake: resetting jobserver mode.\nrecurse2: /-j $np/\nall: /-j $np/\n");
56
57 # Don't put --jobserver-auth into a re-exec'd MAKEFLAGS.
58 # We can't test this directly because there's no way a makefile can
59 # show the value of MAKEFLAGS we were re-exec'd with. We can intuit it
60 # by looking for "disabling jobserver mode" warnings; we should only
61 # get one from the original invocation and none from the re-exec.
62 # See Savannah bug #18124
63
64 unlink('inc.mk');
65
66 run_make_test(q!
67 .RECIPEPREFIX = >
68 -include inc.mk
69 recur:
70 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
71 > @rm -f inc.mk
72 > @$(MAKE) -j2 -f #MAKEFILE# all
73 all:
74 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
75 > @echo $@
76 inc.mk:
77 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
78 > @echo 'FOO = bar' > $@
79 !,
80 "$np -j2", "#MAKE#[1]: warning: -j2 forced in submake: resetting jobserver mode.\nall\n");
81
82 unlink('inc.mk');
83
84 # Test recursion which is hidden from make.
85 # See Savannah bug #39934
86 # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
87 # Windows doesn't use a pipe, and doesn't close access, so this won't happen.
88 if ($port_type ne 'W32') {
89 open(MAKEFILE,"> Makefile2");
90 print MAKEFILE '
91 vpath %.c ../
92 foo:
93 ';
94 close(MAKEFILE);
95
96 run_make_test(q!
97 default: ; @ #MAKEPATH# -f Makefile2
98 !,
99 "-j2 $np",
100 "#MAKE#[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
101 #MAKE#[1]: Nothing to be done for 'foo'.");
102
103 rmfiles('Makefile2');
104 }
105
106 # Ensure enter/leave directory messages appear before jobserver warnings
107
108 run_make_test(q!
109 all: ; @$(MAKE) -C . -f #MAKEFILE# recurse -j1
110 recurse: ; @echo hi
111 !,
112 '-w -j2', "#MAKE#: Entering directory '#PWD#'
113 #MAKE#[1]: Entering directory '#PWD#'
114 #MAKE#[1]: warning: -j1 forced in submake: resetting jobserver mode.
115 hi
116 #MAKE#[1]: Leaving directory '#PWD#'
117 #MAKE#: Leaving directory '#PWD#'\n");
118
119 1;