summaryrefslogtreecommitdiff
path: root/Build/source/texk
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
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')
-rw-r--r--Build/source/texk/web2c/ChangeLog6
-rw-r--r--Build/source/texk/web2c/Makefile.in13
-rw-r--r--Build/source/texk/web2c/am/texmf.am14
-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
8 files changed, 86 insertions, 36 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 54a7641daac..79f73f97a57 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-04 Karl Berry <karl@tug.org>
+
+ * am/texmf.am (tex_tests): add tests/write18-quote-test.pl.
+ * tests/write18-quote-test.pl,
+ * tests/write18-quote.tex: new files to do a bit of \write18 testing.
+
2010-01-02 Karl Berry <karl@tug.org>
* tex.ch (\write18): say "executed safely" instead of just
diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in
index c2d48b23193..b695eed9d82 100644
--- a/Build/source/texk/web2c/Makefile.in
+++ b/Build/source/texk/web2c/Makefile.in
@@ -1120,9 +1120,10 @@ EXTRA_DIST = PROJECTS cftests config.h cpascal.h help.h tangle.web \
tests/rptmr.tfm tests/story.dvi tests/testex.err \
tests/testex.mp tests/testex.tex tests/translate tests/uno.dos \
tests/write18.tex tests/xampl.bib ctiedir tiedir \
- lib/mfmpi386.asm lib/mfmpw32.c lib/texmfmp.c texmfmem.h \
- texmfmp-help.h texmfmp.h $(tex_ch_srcs) lib/texmfmp.c \
- tmf-pool.h $(tex_tests) mf.web mf-binpool.ch mf.ch mftalk.h \
+ lib/mfmpi386.asm lib/mfmpw32.c tests/common-test.pl \
+ lib/texmfmp.c texmfmem.h texmfmp-help.h texmfmp.h \
+ $(tex_ch_srcs) lib/texmfmp.c tmf-pool.h $(tex_tests) \
+ tests/write18-quote.tex mf.web mf-binpool.ch mf.ch mftalk.h \
lib/texmfmp.c tmf-pool.h $(mf_tests) triptrap/README \
triptrap/mftrap.diffs triptrap/mftrap.fot triptrap/mftrap.log \
triptrap/mftrap.pl triptrap/mftrap1.in triptrap/mftrap2.in \
@@ -1468,9 +1469,9 @@ tex_ch_srcs = \
tex-binpool.ch
-# TeX Tests
+# TeX tests
#
-tex_tests = trip.test
+tex_tests = trip.test tests/write18-quote-test.pl
nodist_mf_SOURCES = mfextra.c
mf_CPPFLAGS = $(X_CFLAGS)
mf_CFLAGS = $(WARNING_CFLAGS)
@@ -1495,7 +1496,7 @@ nodist_libmf_a_SOURCES = $(mf_c_h) mf-pool.c
libmf_a_CPPFLAGS = -DMETA_FONT
libmf_a_CFLAGS = $(WARNING_CFLAGS)
-# Metafont Tests
+# Metafont tests
#
mf_tests = trap.test
mpost_CPPFLAGS = -I$(srcdir)/mplibdir
diff --git a/Build/source/texk/web2c/am/texmf.am b/Build/source/texk/web2c/am/texmf.am
index a5c9b791525..3da2e5ac292 100644
--- a/Build/source/texk/web2c/am/texmf.am
+++ b/Build/source/texk/web2c/am/texmf.am
@@ -1,12 +1,13 @@
## texk/web2c/am/texmf.am: Makefile fragment for TeX and MF.
##
-## Copyright (C) 2009 Peter Breitenlohner <tex-live@tug.org>
+## Copyright (C) 2009, 2010 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
## Common for MF and TeX
EXTRA_DIST += \
lib/mfmpi386.asm \
lib/mfmpw32.c \
+ tests/common-test.pl \
lib/texmfmp.c \
texmfmem.h \
texmfmp-help.h \
@@ -64,12 +65,11 @@ EXTRA_DIST += $(tex_ch_srcs) lib/texmfmp.c tmf-pool.h
DISTCLEANFILES += $(nodist_tex_SOURCES) tex-final.ch tex-web2c \
tex.p tex.pool tex-tangle
-# TeX Tests
+# TeX tests
#
-tex_tests = trip.test
-
+tex_tests = trip.test tests/write18-quote-test.pl
EXTRA_DIST += $(tex_tests)
-
+EXTRA_DIST += tests/write18-quote.tex
if TEX
TESTS += $(tex_tests)
check_PROGRAMS += dvitype pltotf tftopl
@@ -154,12 +154,10 @@ EXTRA_DIST += mf.web mf-binpool.ch mf.ch mftalk.h lib/texmfmp.c tmf-pool.h
DISTCLEANFILES += $(nodist_libmf_a_SOURCES) mfextra.c mf-final.ch mf-web2c \
mf.p mf.pool mf-tangle
-# Metafont Tests
+# Metafont tests
#
mf_tests = trap.test
-
EXTRA_DIST += $(mf_tests)
-
if MF
TESTS += $(mf_tests)
check_PROGRAMS += gftype tftopl
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