Debian Codegraph @

tests/scripts/targets/POSIX

raw
1 # -*-perl-*-
2
3 $description = "Test the behaviour of the .POSIX target.";
4
5 $details = "";
6
7
8 # Ensure turning on .POSIX enables the -e flag for the shell
9 # We can't assume the exit value of "false" because on different systems it's
10 # different.
11
12 my $script = 'false; true';
13 my $flags = '-ec';
14 my $out = `$sh_name $flags '$script' 2>&1`;
15 my $err = $? >> 8;
16 setup_for_test();
17 open(MAKEFILE,"> $makefile");
18 print MAKEFILE qq{
19 .SHELLFLAGS = $flags
20 .POSIX:
21 all: ; \@$script
22 };
23
24 $out = `/bin/sh $flags '$script' 2>&1`;
25 my $answer = qq{#MAKEFILE#:4: *** [all] error $err
26
27 #0 all at #MAKEFILE#:4
28 };
29
30 $logfile = &get_logfile;
31 run_make_with_options($makefile, '', $logfile, 512);
32 my $slurp = &read_file_into_string ($logfile);
33 $slurp =~ s:^#0 all at .*work/targets/:#0 all at work/targets/:gm;
34 &compare_output_string($answer, $slurp, $logfile);
35
36 # Test the default value of various POSIX-specific variables
37 my %POSIX = (AR => 'ar', ARFLAGS => 'rvU',
38 YACC => 'yacc', YFLAGS => '',
39 LEX => 'lex', LFLAGS => '',
40 LDFLAGS => '',
41 CC => 'c99', CFLAGS => '-O1',
42 FC => 'fort77', FFLAGS => '-O1',
43 SCCSFLAGS => '', SCCSGETFLAGS => '-s');
44 my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
45 my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
46 run_make_test(qq!
47 .POSIX:
48 all:
49 $make
50 !,
51 '', $r);
52
53 # Make sure that local settings take precedence
54 %extraENV = map { $_ => "xx-$_" } keys %POSIX;
55 $r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
56 run_make_test(undef, '', $r);
57
58 # This tells the test driver that the perl test script executed properly.
59 1;