summaryrefslogtreecommitdiffstats
path: root/src/tests/man-suffixed-extension
blob: 100efff27aa3953d3195c83472cf525df5d9c12b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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=.}
. "$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_pass '"man name.2" is the same as "man 2 name"' \
        'diff -u "$tmpdir/2.exp" "$tmpdir/2.out"'
run $MAN -C "$tmpdir/manpath.config" -aw "$page_name(2)" >"$tmpdir/2.out"
expect_pass '"man '\''name(2)'\''" is the same as "man 2 name"' \
        'diff -u "$tmpdir/2.exp" "$tmpdir/2.out"'

(
        cd "$tmpdir/usr/share/man/man2/"
        mv "${page_name}.2.gz" "${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_pass '"man name.2p" is the same as "man 2p name"' \
        'diff -u "$tmpdir/2p.exp" "$tmpdir/2p.out"'
run $MAN -C "$tmpdir/manpath.config" -aw "$page_name(2p)" >"$tmpdir/2p.out"
expect_pass '"man '\''name(2p)'\''" is the same as "man 2p name"' \
        'diff -u "$tmpdir/2p.exp" "$tmpdir/2p.out"'

finish