gbranden pushed a commit to branch master
in repository groff.

commit 360c8ea288edffc9878f2ea23b356b1278809817
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 10 05:16:53 2026 -0500

    [refer]: Regression-test Savannah #68679.
    
    * src/preproc/refer/tests/check-index-file-validity.sh: Do it.
    * src/preproc/refer/refer.am (refer_TESTS): Run test.
    
    Test fails at this commit.
---
 ChangeLog                                          |  7 ++
 src/preproc/refer/refer.am                         |  1 +
 .../refer/tests/check-index-file-validity.sh       | 91 ++++++++++++++++++++++
 3 files changed, 99 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 248f8c9e3..bea24debb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-09-10  G. Branden Robinson <[email protected]>
+
+       [refer]: Regression-test Savannah #68679.
+
+       * src/preproc/refer/tests/check-index-file-validity.sh: Do it.
+       * src/preproc/refer/refer.am (refer_TESTS): Run test.
+
 2026-09-10  G. Branden Robinson <[email protected]>
 
        * src/libs/libbib/index.cpp (index_search_item::load): Improve
diff --git a/src/preproc/refer/refer.am b/src/preproc/refer/refer.am
index 86e5c0af6..43c999667 100644
--- a/src/preproc/refer/refer.am
+++ b/src/preproc/refer/refer.am
@@ -69,6 +69,7 @@ maintainer-clean-refer:
        fi
 
 refer_TESTS = \
+  src/preproc/refer/tests/check-index-file-validity.sh \
   src/preproc/refer/tests/report-correct-line-numbers.sh \
   src/preproc/refer/tests/smoke-test.sh
 TESTS += $(refer_TESTS)
diff --git a/src/preproc/refer/tests/check-index-file-validity.sh 
b/src/preproc/refer/tests/check-index-file-validity.sh
new file mode 100755
index 000000000..449dcb41f
--- /dev/null
+++ b/src/preproc/refer/tests/check-index-file-validity.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# Copyright 2026 Free Software Foundation, Inc.
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# 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/>.
+
+indxbib="${abs_top_builddir:-.}/indxbib"
+lkbib="${abs_top_builddir:-.}/lkbib"
+
+# Regression-test Savannah #68679.
+
+# Index files are in host-dependent data format.  Skip this test if
+# we're not on the most common (and worst) host environment.
+if [ "$(uname -m)" != "x86_64" ]
+then
+    echo "cannot be sure of index file data format; skipping" >&2
+    exit 77 # skip
+fi
+
+# Locate directory containing our test artifacts.
+artifact_dir=
+
+for buildroot in . .. ../..
+do
+    d=$buildroot/src/preproc/refer/tests/artifacts
+    if [ -d "$d" ]
+    then
+        artifact_dir=$d
+        break
+    fi
+done
+
+# If we can't find it, we can't test.
+if [ -z "$artifact_dir" ]
+then
+    echo "cannot find test artifact directory; skipping" >&2
+    exit 77 # skip
+fi
+
+common_words_file="$buildroot/src/utils/indxbib/eign"
+
+sandbox_dir=$(mktemp -d)
+if [ $? -ne 0 ]
+then
+    echo "cannot create temporary directory; skipping" >&2
+    exit 77 # skip
+fi
+
+if ! cp "$artifact_dir/little-schemer.bib" "$sandbox_dir"
+then
+    echo "cannot populate temporary directory; skipping" >&2
+    exit 77 # skip
+fi
+
+REFER="$sandbox_dir"/little-schemer.bib
+export REFER
+
+if ! "$indxbib" -c "$common_words_file" "$REFER"
+then
+    echo "cannot generate index for bibliography file; skipping" >&2
+    exit 77 # skip
+fi
+
+# Corrupt the index file.  Thanks to Pavol Sloboda.
+#
+# dash's built-in printf doesn't support \x or \u escapes, so likely
+# other shells don't either, and expecting one that does to be in the
+# $PATH seems optimistic.
+printf '\377\377\377\377' | dd of="$REFER".i bs=1 seek=24 conv=notrunc
+status=1
+"$lkbib" Schemer 2>&1 > /dev/null | grep -q 'error.*corrupt' && status=0
+
+# We need `-f` because "little-schemer.bib" gets mode 444 in a "make
+# distcheck" build.
+rm -rf "$sandbox_dir"
+exit $status
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to