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: -jN forced in submake: disabling 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: -jN forced in submake: disabling 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 | -include inc.mk
|
---|
68 | recur:
|
---|
69 | # @echo 'MAKEFLAGS = $(MAKEFLAGS)'
|
---|
70 | @rm -f inc.mk
|
---|
71 | @$(MAKE) -j2 -f #MAKEFILE# all
|
---|
72 | all:
|
---|
73 | # @echo 'MAKEFLAGS = $(MAKEFLAGS)'
|
---|
74 | @echo $@
|
---|
75 | inc.mk:
|
---|
76 | # @echo 'MAKEFLAGS = $(MAKEFLAGS)'
|
---|
77 | @echo 'FOO = bar' > $@
|
---|
78 | !,
|
---|
79 | "$np -j2", "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
|
---|
80 |
|
---|
81 | unlink('inc.mk');
|
---|
82 |
|
---|
83 | # Test recursion when make doesn't think it exists.
|
---|
84 | # See Savannah bug #39934
|
---|
85 | # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
|
---|
86 |
|
---|
87 | open(MAKEFILE,"> Makefile2");
|
---|
88 | print MAKEFILE '
|
---|
89 | vpath %.c ../
|
---|
90 | foo:
|
---|
91 | ';
|
---|
92 | close(MAKEFILE);
|
---|
93 |
|
---|
94 | run_make_test(q!
|
---|
95 | default: ; @ #MAKEPATH# -f Makefile2
|
---|
96 | !,
|
---|
97 | "-j2 $np",
|
---|
98 | "#MAKE#[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
|
---|
99 | #MAKE#[1]: Nothing to be done for 'foo'.");
|
---|
100 |
|
---|
101 | rmfiles('Makefile2');
|
---|
102 |
|
---|
103 | 1;
|
---|
104 |
|
---|
105 | ### Local Variables:
|
---|
106 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
|
---|
107 | ### End:
|
---|