Debian Codegraph @

texk/dvipsk/quotecmd-test.pl

raw
1 #!/usr/bin/env perl
2 # $Id: quotecmd-test.pl 21216 2011-01-29 00:32:02Z karl $
3 # Public domain. Originally written 2010, Karl Berry.
4 # Check that dvips quotes external command arguments.
5
6 BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `dirname $0`); }
7 require "$srcdir/../tests/common-test.pl";
8
9 exit (&main ());
10
11 sub main
12 {
13 # create the weirdly-named file which dvips executes with popen.
14 # quotecmd.tex also creates it, but we don't want to run TeX in
15 # this test, nor do we want such a weirdly-named file in our
16 # repository, so create it here. The names here and in quotecmd.tex
17 # must match exactly or the test won't be testing what it should.
18 #
19 # Leave the file in place, so we can conveniently run dvips under the
20 # debugger if we need to.
21 my $weirdf = ' 2>&1 | echo badnews >pwned.txt #.gz';
22 unlink ($weirdf); # ensure no leftover
23 open (WEIRDF, ">", $weirdf);
24 close (WEIRDF) || die "open(weird file name) failed: $!";
25
26 $badfile = "pwned.txt"; # will be created if program is broken
27 unlink ($badfile); # ensure no leftover from previous test
28
29 my @args = ("$srcdir/testdata/quotecmd.dvi", qw(-o /dev/null));
30 my $ret = &test_run ("./dvips", @args);
31
32 my $bad = -f $badfile; # file should not have been created
33 return $bad;
34 }