3 $description = "Test jobserver.";
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.";
9 exists $FEATURES{'jobserver'} or return -1;
11 if (!$parallel_jobs) {
16 my $np = '--no-print-directory';
18 # Simple test of MAKEFLAGS settings
20 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
21 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
22 all:;@echo $@: "/$(SHOW)/"
24 "-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
26 # Setting parallelism with the environment
27 # Command line should take precedence over the environment
28 $ENV{MAKEFLAGS} = "-j2 $np";
30 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
31 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
32 all:;@echo $@: "/$(SHOW)/"
34 '', "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
36 # Test override of -jN
37 $ENV{MAKEFLAGS} = "-j9 $np";
39 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
40 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j3 -f #MAKEFILE# recurse2
41 recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
42 all:;@echo $@: "/$(SHOW)/"
44 "-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 # Test override of -jN with -j
48 SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
49 recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j -f #MAKEFILE# recurse2
50 recurse2: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
51 all:;@echo $@: "/$(SHOW)/"
53 "-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");
55 # Don't put --jobserver-auth into a re-exec'd MAKEFLAGS.
56 # We can't test this directly because there's no way a makefile can
57 # show the value of MAKEFLAGS we were re-exec'd with. We can intuit it
58 # by looking for "disabling jobserver mode" warnings; we should only
59 # get one from the original invocation and none from the re-exec.
60 # See Savannah bug #18124
68 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
70 > @$(MAKE) -j2 -f #MAKEFILE# all
72 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
75 #> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
76 > @echo 'FOO = bar' > $@
78 "$np -j2", "#MAKE#[1]: warning: -j2 forced in submake: resetting jobserver mode.\nall\n");
82 # Test recursion which is hidden from make.
83 # See Savannah bug #39934
84 # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
85 # Environments that don't use a pipe won't close access, so this won't happen.
86 if ($port_type ne 'W32') {
87 create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
90 default: ; @ #MAKEPATH# -f Makefile2
92 "--jobserver-style=pipe -j2 $np",
93 "#MAKE#[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
94 #MAKE#[1]: Nothing to be done for 'foo'.");
99 # For Windows and named pipes, we don't need to worry about recursion
100 if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) {
101 create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
104 default: ; @ #MAKEPATH# -f Makefile2
107 "#MAKE#[1]: Nothing to be done for 'foo'.");
109 rmfiles('Makefile2');
112 # Ensure enter/leave directory messages appear before jobserver warnings
115 all: ; @$(MAKE) -C . -f #MAKEFILE# recurse -j1
118 '-w -j2', "#MAKE#: Entering directory '#PWD#'
119 #MAKE#[1]: Entering directory '#PWD#'
120 #MAKE#[1]: warning: -j1 forced in submake: resetting jobserver mode.
122 #MAKE#[1]: Leaving directory '#PWD#'
123 #MAKE#: Leaving directory '#PWD#'\n");
125 # Check for invalid jobserver-style options
131 '--jobserver-style=foo -j8',
132 "#MAKE#: *** Unknown jobserver auth style 'foo'. Stop.", 512);
135 # Test that when mkfifo fails, make switches to pipe and succeeds.
136 # Force mkfifo to fail by attempting to create a fifo in a non existent
138 # run_make_test does not allow matching a multiline pattern, therefore run the
140 # First time look for /$ERR_no_such_file/ to ensure mkfifo failed.
141 # Second time look for /Nothing to be done/ to ensure make succeeded.
142 if (exists $FEATURES{'jobserver-fifo'}) {
143 $ENV{TMPDIR} = "nosuchdir";
144 run_make_test("all:\n", '-j2', "/$ERR_no_such_file/");
146 $ENV{TMPDIR} = "nosuchdir";
147 run_make_test(undef, '-j2', "/Nothing to be done/");
149 # Verify that MAKE_TMPDIR is preferred if provided
150 $ENV{MAKE_TMPDIR} = '.';
151 $ENV{TMPDIR} = 'nosuchdir';
154 recurse: ; @$(MAKE) -f #MAKEFILE# all
155 all:;@echo "$$MAKEFLAGS"
157 "-j2 --no-print-directory", "/--jobserver-auth=fifo:\\./");