Imported Upstream version 4.0
[platform/upstream/make.git] / tests / scripts / features / jobserver
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 # Don't put --jobserver-fds into a re-exec'd MAKEFLAGS.
16 # We can't test this directly because there's no way a makefile can
17 # show the value of MAKEFLAGS we were re-exec'd with.  We can intuit it
18 # by looking for "disabling jobserver mode" warnings; we should only
19 # get one from the original invocation and none from the re-exec.
20 # See Savannah bug #18124
21
22 unlink('inc.mk');
23
24 run_make_test(q!
25 -include inc.mk
26 recur:
27 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
28         @rm -f inc.mk
29         @$(MAKE) -j2 -f #MAKEFILE# all
30 all:
31 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
32         @echo $@
33 inc.mk:
34 #       @echo 'MAKEFLAGS = $(MAKEFLAGS)'
35         @echo 'FOO = bar' > $@
36 !,
37               '--no-print-directory -j2', "#MAKE#[1]: warning: -jN forced in submake: disabling jobserver mode.\nall\n");
38
39 unlink('inc.mk');
40
41 # Test recursion when make doesn't think it exists.
42 # See Savannah bug #39934
43 # Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
44
45 open(MAKEFILE,"> Makefile2");
46 print MAKEFILE '
47 vpath %.c ../
48 foo:
49 ';
50 close(MAKEFILE);
51
52 run_make_test(q!
53 default: ; @ #MAKEPATH# -f Makefile2
54 !,
55               '-j2 --no-print-directory',
56 "#MAKE#[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
57 #MAKE#[1]: Nothing to be done for 'foo'.");
58
59 rmfiles('Makefile2');
60
61 1;