diff options
author | Karl Berry <karl@freefriends.org> | 2009-08-17 16:37:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-08-17 16:37:46 +0000 |
commit | cf34595c934021488b1499900cb9182576ceb582 (patch) | |
tree | c0f8dee20a5fe1f9fcef60fb2a88dedc401b8562 /Build/tests/checkpdf.pl | |
parent | 15fb41576282c23c5d6864975a61a9e3436fa7fc (diff) |
move tests to Build
git-svn-id: svn://tug.org/texlive/trunk@14724 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/tests/checkpdf.pl')
-rwxr-xr-x | Build/tests/checkpdf.pl | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Build/tests/checkpdf.pl b/Build/tests/checkpdf.pl new file mode 100755 index 00000000000..6096667dcda --- /dev/null +++ b/Build/tests/checkpdf.pl @@ -0,0 +1,71 @@ +#!/usr/local/bin/perl +# pdfcheck -- PDF autotest helper. +# $Id: //depot/Master/support/tests/checkpdf.pl#2 $ +# +# Public domain. Originaly written 2004, Karl Berry. +# +# (Although it's much simpler and more functional in sh, Perl makes it +# possible to run on Windows, for TeX Live, etc. I hope someone cares +# some day.) + +exit (&main ()); + +sub main +{ + if (@ARGV != 2) { + print <<END_USAGE; +Usage: $0 PPZ_KNOWN_GOOD PDF_TO_CHECK + +Run pdftoppm on PDF_TO_CHECK, and compare against PPZ_KNOWN_GOOD +(after uncompressing). For autotesting. + +PPZ_KNOWN_GOOD should be created with pdftoppm | gzip -1. +See tests/common.mak. +END_USAGE + return 1; + } + + my $good_type = $ARGV[0]; + my $check_pdf = $ARGV[1]; + + die "No PDF file $check_pdf" if ! -s $check_pdf; + die "No good PPZ file $good_type" if ! -s $good_type; + + # get image of the PDF file. We can't compare PDF files directly, + # they can vary from run to run. There is no simple pdftype program, + # and it seems a better test to look at the actual output image than + # just to run pdftotext. + # + # this creates checkpdf-000001.ppm (for a one page file). + my $check = system ("pdftoppm", $check_pdf, "checkpdf"); + die "pdftoppm($check_pdf) failed, status $check" + if $check; + + # compare page images, they should be exactly the same. + my $different = system ("zcat $good_type | cmp -s checkpdf-000001.ppm"); + $different /= 8; + if ($different) { + warn "$0: ${check_pdf} different from $good_type.\n"; + } + + return $different; +} + + +# +# Run PROGRAM on ARGS, running output with clean_dvitype and returning as +# a string. +# +sub snarf_output +{ + my ($program,@args) = @_; + + # use safe (more or less) form of open. + local *PROG; + open (PROG, "-|", $program, @args) ||die "open($program @args |) failed: $!"; + my @lines = <PROG>; +#warn "read lines from $program @args:\n@lines"; + close (PROG) || warn "close($program @args |) failed: $!"; + + return &clean_dvitype (@lines); +} |