summaryrefslogtreecommitdiffstats
path: root/src/tests/man-suffixed-extension
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/man-suffixed-extension
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/man-suffixed-extension')
-rwxr-xr-xsrc/tests/man-suffixed-extension52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tests/man-suffixed-extension b/src/tests/man-suffixed-extension
new file mode 100755
index 0000000..1921e9b
--- /dev/null
+++ b/src/tests/man-suffixed-extension
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Test for:
+# man chmod.2 => man 2 chmod
+# man 'chmod(2)' => man 2 chmod
+# man chmod.2p => man 2p chmod
+# man 'chmod(2p)' => man 2p chmod
+
+: "${srcdir=.}"
+# shellcheck source-path=SCRIPTDIR
+. "$srcdir/testlib.sh"
+
+: "${MAN=man}"
+
+init
+fake_config /usr/share/man
+MANPATH="$tmpdir/usr/share/man"
+export MANPATH
+
+page_name="chmod"
+
+write_page "$page_name" 1 "$tmpdir/usr/share/man/man1/${page_name}.1.gz" \
+ UTF-8 gz '' "$page_name \- coreutils $page_name manual page"
+write_page "$page_name" 2 "$tmpdir/usr/share/man/man2/${page_name}.2.gz" \
+ UTF-8 gz '' "$page_name \- $page_name() syscall manual page"
+
+cat >"$tmpdir/2.exp" <<EOF
+$abstmpdir/usr/share/man/man2/${page_name}.2.gz
+EOF
+
+run $MAN -C "$tmpdir/manpath.config" -aw "$page_name".2 >"$tmpdir/2.out"
+expect_files_equal '"man name.2" is the same as "man 2 name"' \
+ "$tmpdir/2.exp" "$tmpdir/2.out"
+run $MAN -C "$tmpdir/manpath.config" -aw "$page_name(2)" >"$tmpdir/2.out"
+expect_files_equal '"man '\''name(2)'\''" is the same as "man 2 name"' \
+ "$tmpdir/2.exp" "$tmpdir/2.out"
+
+mv "$tmpdir/usr/share/man/man2/$page_name.2.gz" \
+ "$tmpdir/usr/share/man/man2/$page_name.2p.gz"
+
+cat >"$tmpdir/2p.exp" <<EOF
+$abstmpdir/usr/share/man/man2/${page_name}.2p.gz
+EOF
+
+run $MAN -C "$tmpdir/manpath.config" -aw "$page_name".2p >"$tmpdir/2p.out"
+expect_files_equal '"man name.2p" is the same as "man 2p name"' \
+ "$tmpdir/2p.exp" "$tmpdir/2p.out"
+run $MAN -C "$tmpdir/manpath.config" -aw "$page_name(2p)" >"$tmpdir/2p.out"
+expect_files_equal '"man '\''name(2p)'\''" is the same as "man 2p name"' \
+ "$tmpdir/2p.exp" "$tmpdir/2p.out"
+
+finish