summaryrefslogtreecommitdiffstats
path: root/contrib/mom/examples/test-mom.sh.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:44:05 +0000
commitd318611dd6f23fcfedd50e9b9e24620b102ba96a (patch)
tree8b9eef82ca40fdd5a8deeabf07572074c236095d /contrib/mom/examples/test-mom.sh.in
parentInitial commit. (diff)
downloadgroff-f22bf21391d2b916c7303c565592ae6e99efbb58.tar.xz
groff-f22bf21391d2b916c7303c565592ae6e99efbb58.zip
Adding upstream version 1.23.0.upstream/1.23.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/mom/examples/test-mom.sh.in')
-rw-r--r--contrib/mom/examples/test-mom.sh.in92
1 files changed, 92 insertions, 0 deletions
diff --git a/contrib/mom/examples/test-mom.sh.in b/contrib/mom/examples/test-mom.sh.in
new file mode 100644
index 0000000..ebaba20
--- /dev/null
+++ b/contrib/mom/examples/test-mom.sh.in
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# Copyright (C) 2018-2020 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+builddir="@abs_top_builddir@"
+have_urw_fonts="@groff_have_urw_fonts@"
+examplesdir="$builddir/contrib/mom/examples"
+ret=0
+list="
+ letter.pdf
+ mom-pdf.pdf
+ mon_premier_doc.pdf
+ sample_docs.pdf
+ slide-demo.pdf
+ typesetting.pdf
+ copyright-chapter.pdf
+ copyright-default.pdf
+ "
+
+if test "$have_urw_fonts" != "yes"; then
+ echo "No URW fonts, mom examples cannot be correctly generated"
+ exit 77
+fi
+
+for cmd in pdfinfo pdfimages
+do
+ if ! command -v $cmd >/dev/null
+ then
+ echo "cannot locate '$cmd' command; skipping" >&2
+ exit 77 # skip
+ fi
+done
+
+# $1: pdf file
+# $2: expected number of pages
+check_number_pages()
+{
+ echo "Checking number of pages of $1"
+ n_pages=`pdfinfo $1 | grep Pages | awk '{ print $2}'`
+ if test "$n_pages" != "$2"; then
+ echo " Error: expected $2 pages, found $n_pages pages"
+ ret=255
+ fi
+}
+
+# $1 pdf file
+check_has_images()
+{
+ echo "Checking if $1 has images"
+ n_lines=`pdfimages -list $1 | wc -l `
+ if test $n_lines -le 2; then
+ echo " no images found"
+ ret=255
+ fi
+}
+
+for k in $list; do
+ if ! test -f $examplesdir/$k; then
+ echo "File $k not found"
+ exit 255
+ fi
+done
+
+check_number_pages "$examplesdir/letter.pdf" 1
+check_number_pages "$examplesdir/mom-pdf.pdf" 8
+check_number_pages "$examplesdir/mon_premier_doc.pdf" 5
+check_number_pages "$examplesdir/sample_docs.pdf" 12
+check_number_pages "$examplesdir/slide-demo.pdf" 33
+check_number_pages "$examplesdir/typesetting.pdf" 3
+check_number_pages "$examplesdir/copyright-chapter.pdf" 5
+check_number_pages "$examplesdir/copyright-default.pdf" 5
+
+check_has_images "$examplesdir/typesetting.pdf"
+check_has_images "$examplesdir/slide-demo.pdf"
+
+exit $ret