From e0023883c6d2e6745a19e4b48e186ed156c1fca8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:19:27 +0200 Subject: Adding upstream version 2.11.2. Signed-off-by: Daniel Baumann --- src/tests/mandb-purge-updates-timestamp | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 src/tests/mandb-purge-updates-timestamp (limited to 'src/tests/mandb-purge-updates-timestamp') diff --git a/src/tests/mandb-purge-updates-timestamp b/src/tests/mandb-purge-updates-timestamp new file mode 100755 index 0000000..48666d8 --- /dev/null +++ b/src/tests/mandb-purge-updates-timestamp @@ -0,0 +1,70 @@ +#! /bin/sh + +# If mandb purges missing pages, it updates the database's timestamp, +# without confusing itself into not scanning for newer pages. + +: "${srcdir=.}" +# shellcheck source-path=SCRIPTDIR +. "$srcdir/testlib.sh" + +: "${MANDB=mandb}" +: "${ACCESSDB=accessdb}" + +init +fake_config /usr/share/man +MANPATH="$tmpdir/usr/share/man" +export MANPATH +db_ext="$(db_ext)" +case $DBTYPE in + ndbm) full_db_ext=.pag ;; + *) full_db_ext="$db_ext" ;; +esac + +write_page test1 1 "$tmpdir/usr/share/man/man1/test1.1.gz" \ + UTF-8 gz t 'test1 \- test1(1)' +write_page test2 1 "$tmpdir/usr/share/man/man1/test2.1.gz" \ + UTF-8 gz t 'test2 \- test2(1)' +write_page test3 1 "$tmpdir/usr/share/man/man1/test3.1.gz" \ + UTF-8 gz t 'test3 \- test3(1)' +run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man" +cat >"$tmpdir/1.exp" < "- 1 1 MTIME A - - gz test1(1)" +test2 -> "- 1 1 MTIME A - - gz test2(1)" +test3 -> "- 1 1 MTIME A - - gz test3(1)" +EOF +accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/1.out" +expect_files_equal 'setup' "$tmpdir/1.exp" "$tmpdir/1.out" +mtime1="$(./get-mtime "$tmpdir/usr/share/man/index$full_db_ext")" + +./fspause +rm -f "$tmpdir/usr/share/man/man1/test3.1.gz" +# Fool mandb into believing that this directory was not modified. It will +# still run its purge step. +touch -r "$tmpdir/usr/share/man/index$db_ext" "$tmpdir/usr/share/man/man1" +run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man" +cat >"$tmpdir/2.exp" < "- 1 1 MTIME A - - gz test1(1)" +test2 -> "- 1 1 MTIME A - - gz test2(1)" +EOF +accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/2.out" +expect_files_equal 'remove test3' "$tmpdir/2.exp" "$tmpdir/2.out" +mtime2="$(./get-mtime "$tmpdir/usr/share/man/index$full_db_ext")" +test "$mtime1" != "$mtime2" +report 'mtime changed (1)' "$?" + +./fspause +rm -f "$tmpdir/usr/share/man/man1/test2.1.gz" +write_page test4 1 "$tmpdir/usr/share/man/man1/test4.1.gz" \ + UTF-8 gz t 'test4 \- test4(1)' +run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man" +cat >"$tmpdir/3.exp" < "- 1 1 MTIME A - - gz test1(1)" +test4 -> "- 1 1 MTIME A - - gz test4(1)" +EOF +accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/3.out" +expect_files_equal 'remove test2, add test4' "$tmpdir/3.exp" "$tmpdir/3.out" +mtime3="$(./get-mtime "$tmpdir/usr/share/man/index$full_db_ext")" +test "$mtime2" != "$mtime3" +report 'mtime changed (2)' "$?" + +finish -- cgit v1.2.3