summaryrefslogtreecommitdiffstats
path: root/src/tests/mandb-regular-file-symlink-changes
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:37:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:37:10 +0000
commitc9addba5cc770d2d231b34f6739f32c6be8690f1 (patch)
treec643da154a95a1d163137135050bb47858a1654e /src/tests/mandb-regular-file-symlink-changes
parentInitial commit. (diff)
downloadman-db-c9addba5cc770d2d231b34f6739f32c6be8690f1.tar.xz
man-db-c9addba5cc770d2d231b34f6739f32c6be8690f1.zip
Adding upstream version 2.12.0.upstream/2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tests/mandb-regular-file-symlink-changes')
-rwxr-xr-xsrc/tests/mandb-regular-file-symlink-changes68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/tests/mandb-regular-file-symlink-changes b/src/tests/mandb-regular-file-symlink-changes
new file mode 100755
index 0000000..900d6b6
--- /dev/null
+++ b/src/tests/mandb-regular-file-symlink-changes
@@ -0,0 +1,68 @@
+#! /bin/sh
+
+# What happens when a manual page changes from a regular file to a symbolic
+# link and back?
+# https://bugs.debian.org/490582
+
+: "${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)"
+
+write_page fs 5 "$tmpdir/usr/share/man/man5/fs.5.gz" \
+ UTF-8 gz t 'fs \- fs(5)'
+run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man"
+cat >"$tmpdir/1.exp" <<EOF
+fs -> "- 5 5 MTIME A - - gz fs(5)"
+EOF
+accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/1.out"
+expect_files_equal 'fs(5) setup' "$tmpdir/1.exp" "$tmpdir/1.out"
+
+./fspause
+write_page filesystems 5 "$tmpdir/usr/share/man/man5/filesystems.5.gz" \
+ UTF-8 gz t 'filesystems \- filesystems(5)'
+ln -sf filesystems.5.gz "$tmpdir/usr/share/man/man5/fs.5.gz"
+run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man"
+cat >"$tmpdir/2.exp" <<EOF
+filesystems -> "- 5 5 MTIME A - - gz filesystems(5)"
+fs -> "- 5 5 MTIME B - - gz filesystems(5)"
+EOF
+accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/2.out"
+expect_files_equal 'mandb notices regular file -> symlink' \
+ "$tmpdir/2.exp" "$tmpdir/2.out"
+
+./fspause
+ln -sf fs.5.gz "$tmpdir/usr/share/man/man5/fs2.5.gz"
+run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man"
+cat >"$tmpdir/3.exp" <<EOF
+filesystems -> "- 5 5 MTIME A - - gz filesystems(5)"
+fs -> "- 5 5 MTIME B - - gz filesystems(5)"
+fs2 -> "- 5 5 MTIME B - - gz filesystems(5)"
+EOF
+accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/3.out"
+expect_files_equal 'mandb notices two-level symlink' \
+ "$tmpdir/3.exp" "$tmpdir/3.out"
+
+./fspause
+rm -f "$tmpdir/usr/share/man/man5/fs.5.gz"
+write_page fs 5 "$tmpdir/usr/share/man/man5/fs.5.gz" \
+ UTF-8 gz t 'fs \- new fs(5)'
+run $MANDB -C "$tmpdir/manpath.config" -u -q "$tmpdir/usr/share/man"
+cat >"$tmpdir/4.exp" <<EOF
+filesystems -> "- 5 5 MTIME A - - gz filesystems(5)"
+fs -> "- 5 5 MTIME A - - gz new fs(5)"
+fs2 -> "- 5 5 MTIME B - - gz filesystems(5)"
+EOF
+accessdb_filter "$tmpdir/usr/share/man/index$db_ext" >"$tmpdir/4.out"
+expect_files_equal 'mandb notices symlink -> regular file' \
+ "$tmpdir/4.exp" "$tmpdir/4.out"
+
+finish