summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/tests
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-01-13 01:18:02 +0000
committerKarl Berry <karl@freefriends.org>2010-01-13 01:18:02 +0000
commit2c3f4ac000585f4d975117d6000cbfd574070fef (patch)
tree4472d9ffb35f46e81df4b31ff5a367e1816dc042 /Build/source/texk/web2c/tests
parent8a0ac1c324c5add345d500a13d24dcdb5785d9cb (diff)
start at testing restricted \write18 and quotes, plus factoring out common test functions
git-svn-id: svn://tug.org/texlive/trunk@16695 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/tests')
-rwxr-xr-xBuild/source/texk/web2c/tests/bibtex-openout-test.pl25
-rw-r--r--Build/source/texk/web2c/tests/common-test.pl24
-rwxr-xr-xBuild/source/texk/web2c/tests/write18-quote-test.pl22
-rw-r--r--Build/source/texk/web2c/tests/write18-quote.tex16
-rw-r--r--Build/source/texk/web2c/tests/write18.tex2
5 files changed, 67 insertions, 22 deletions
diff --git a/Build/source/texk/web2c/tests/bibtex-openout-test.pl b/Build/source/texk/web2c/tests/bibtex-openout-test.pl
index 9d45effefa2..fc8dabfc846 100755
--- a/Build/source/texk/web2c/tests/bibtex-openout-test.pl
+++ b/Build/source/texk/web2c/tests/bibtex-openout-test.pl
@@ -1,35 +1,20 @@
#!/usr/bin/env perl
# $Id$
-# Copyright 2009 Karl Berry <tex-live@tug.org>.
+# Copyright 2009, 2010 Karl Berry <tex-live@tug.org>.
# You may freely use, modify and/or distribute this file.
# Check that bibtex respects openout_any.
-BEGIN {
- chomp ($mydir = `dirname $0`);
- unshift (@INC, "$mydir");
-}
+BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `pwd`); }
+require "$srcdir/tests/common-test.pl";
exit (&main ());
sub main
{
- # attempt at making it possible to run this when srcdir=builddir.
- $ENV{"srcdir"} = $mydir if ! exists $ENV{"srcdir"};
- my $srcdir = $ENV{"srcdir"};
-
- $ENV{"TEXMFCNF"} = "$srcdir/../kpathsea";
- $ENV{"BIBINPUTS"} = "$srcdir/tests";
- $ENV{"BSTINPUTS"} = "$srcdir/tests";
-
$ENV{"openout_any"} = "p"; # should already be in texmf.cnf, but ...
- my $prog = "./bibtex";
- die "$0: no program $prog in " . `pwd` if ! -x $prog;
-
- my @args = ("$srcdir/exampl.aux"); # blg open of abs path should fail
-
- $ret = system ($prog, @args);
- #warn ("ret=$ret in " . `pwd`);
+ # .blg open of abs path should fail
+ my $ret = &test_run ("./bibtex", "$srcdir/exampl.aux");
# The test fails if the program succeeded. Ideally we'd grep the output.
my $bad = ($ret == 0);
diff --git a/Build/source/texk/web2c/tests/common-test.pl b/Build/source/texk/web2c/tests/common-test.pl
new file mode 100644
index 00000000000..725ba55b624
--- /dev/null
+++ b/Build/source/texk/web2c/tests/common-test.pl
@@ -0,0 +1,24 @@
+# $Id$
+# Copyright 2010 Karl Berry <tex-live@tug.org>.
+# You may freely use, modify and/or distribute this file.
+# Common definitions for Perl tests in TeX Live.
+
+$ENV{"TEXMFCNF"} = "$srcdir/../kpathsea";
+$ENV{"BIBINPUTS"} = "$srcdir/tests";
+$ENV{"BSTINPUTS"} = "$srcdir/tests";
+$ENV{"TEXINPUTS"} = "$srcdir/tests";
+
+# Run PROG with ARGS. Return the exit status.
+# Die if PROG is not executable.
+#
+sub test_run
+{
+ my ($prog, @args) = @_;
+
+ # Possibly we should check that $prog starts with ./, since we always
+ # want to run out of the build dir. I think.
+ die "$0: no program $prog in " . `pwd` if ! -x $prog;
+
+ my $ret = system ($prog, @args);
+ return $ret;
+}
diff --git a/Build/source/texk/web2c/tests/write18-quote-test.pl b/Build/source/texk/web2c/tests/write18-quote-test.pl
new file mode 100755
index 00000000000..74256516b73
--- /dev/null
+++ b/Build/source/texk/web2c/tests/write18-quote-test.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+# $Id$
+# Copyright 2010 Karl Berry <tex-live@tug.org>.
+# You may freely use, modify and/or distribute this file.
+# Check that restricted shell invocation doesn't misquote.
+
+BEGIN { chomp ($srcdir = $ENV{"srcdir"} || `pwd`); }
+require "$srcdir/tests/common-test.pl";
+
+exit (&main ());
+
+sub main
+{
+ $badfile = "write18-quote-newfile.tex";
+ unlink ($badfile); # ensure no leftover from previous test
+
+ my @args = qw(-ini -shell-restricted $srcdir/tests/write18-quote.tex);
+ my $ret = &test_run ("./tex", @args);
+
+ my $bad = -f $badfile; # file should not have been created
+ return $bad;
+}
diff --git a/Build/source/texk/web2c/tests/write18-quote.tex b/Build/source/texk/web2c/tests/write18-quote.tex
new file mode 100644
index 00000000000..d766ac4f808
--- /dev/null
+++ b/Build/source/texk/web2c/tests/write18-quote.tex
@@ -0,0 +1,16 @@
+% $Id$
+% Copyright 2010 Karl Berry <tex-live@tug.org>.
+% You may freely use, modify and/or distribute this file.
+
+\catcode`\{=1 \catcode`\}=2 % allow for running with initex.
+
+% This filename is used in the test code.
+\def\newfile{write18-quote-newfile.tex} % tex expansion happens first.
+
+\immediate\write18{false "`touch \newfile`"}
+\immediate\write18{false "story.tex'; touch '\newfile"}
+
+% xxtodo: something about pipes.
+%\message{\input |printf /etc/issue}
+
+\end
diff --git a/Build/source/texk/web2c/tests/write18.tex b/Build/source/texk/web2c/tests/write18.tex
deleted file mode 100644
index 4a2b0ee00f9..00000000000
--- a/Build/source/texk/web2c/tests/write18.tex
+++ /dev/null
@@ -1,2 +0,0 @@
-\immediate\write18{echo this is write18 output from echo}
-\bye