6 $PERL -e 1 > /dev/null 2>&1 || {
7 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
8 "so can't run this test"
12 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
16 (my $ME = $0) =~ s|.*/||;
19 # Turn off localisation of executable's ouput.
20 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
24 # test-name, [option, option, ...] {OUT=>"expected-output"}
26 ['nl', q!--printf='\n' .!, {OUT=>"\n"}],
27 ['no-nl', "--printf=%n .", {OUT=>"."}],
28 ['pct-and-esc', q!--printf='\0%n\0' .!, {OUT=>"\0.\0"}],
29 ['backslash', q!--printf='\\\\' .!, {OUT=>"\\"}],
30 ['nul', q!--printf='\0' .!, {OUT=>"\0"}],
31 # Don't bother testing \v, since Perl doesn't handle it.
32 ['bel-etc', q!--printf='\a\b\f\n\r\t' .!, {OUT=>"\a\b\f\n\r\t"}],
33 ['octal-1', q!--printf='\012\377' .!, {OUT=>"\012\377"}],
34 ['octal-2', q!--printf='.\012a\377b' .!, {OUT=>".\012a\377b"}],
35 ['hex-1', q!--printf='\x34\xf' .!, {OUT=>"\x34\xf"}],
36 ['hex-2', q!--printf='.\x18p\xfq' .!, {OUT=>".\x18p\x0fq"}],
37 ['hex-3', q!--printf='\x' .!, {OUT=>'x'},
38 {ERR=>"$prog: warning: unrecognized escape `\\x'\n"}],
40 # With --format, there *is* a trailing newline.
41 ['f-nl', "--format=%n .", {OUT=>".\n"}],
42 ['f-nl2', "--format=%n . .", {OUT=>".\n.\n"}],
44 ['end-pct', "--printf=% .", {OUT=>"%"}],
45 ['pct-pct', "--printf=%% .", {OUT=>"%"}],
46 ['end-bs', "--printf='\\' .", {OUT=>'\\'},
47 {ERR=>"$prog: warning: backslash at end of format\n"}],
49 ['err-1', "--printf=%9% .", {EXIT => 1},
50 {ERR=>"$prog: %9%: invalid directive\n"}],
51 ['err-2', "--printf=%9 .", {EXIT => 1},
52 {ERR=>"$prog: %9: invalid directive\n"}],
55 my $save_temps = $ENV{DEBUG};
56 my $verbose = $ENV{VERBOSE};
58 my $fail = run_tests ($ME, $prog, \@Tests, $save_temps, $verbose);