File: test_manpage.sh

package info (click to toggle)
libsmdev 20190315-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,320 kB
  • sloc: ansic: 103,279; sh: 5,995; makefile: 822; python: 395; sed: 16
file content (101 lines) | stat: -rwxr-xr-x 1,645 bytes parent folder | download | duplicates (20)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
# Tests man pages.
#
# Version: 20190302

EXIT_SUCCESS=0;
EXIT_FAILURE=1;
EXIT_IGNORE=77;

run_test()
{
	local INPUT_FILE=$1;
	local RESULT=0

	TEST_NAME=`basename ${INPUT_FILE}`;
	echo -n "Testing man with input: ${TEST_NAME}";

	LC_ALL=en_US.UTF-8 MANROFFSEQ='' MANWIDTH=80 man --warnings -E UTF-8 -l -Tutf8 -Z ${INPUT_FILE} > /dev/null 2> ${TMPDIR}/${TEST_NAME}.warnings;
	RESULT=$?;

	# For now line break warnings are ignored.
	if test -f ${TMPDIR}/${TEST_NAME}.warnings;
	then
		sed "/can't break line/ d" -i ${TMPDIR}/${TEST_NAME}.warnings;
	fi
	if test -s ${TMPDIR}/${TEST_NAME}.warnings;
	then
		RESULT=${EXIT_FAILURE};
	fi
	if test ${RESULT} -ne ${EXIT_SUCCESS};
	then
		echo " (FAIL)";
	else
		echo " (PASS)";
	fi
	if test -s ${TMPDIR}/${TEST_NAME}.warnings;
	then
		cat ${TMPDIR}/${TEST_NAME}.warnings;
	fi
	return ${RESULT};
}

if test "${OSTYPE}" = "msys";
then
	exit ${EXIT_IGNORE};
fi

TEST_RUNNER="tests/test_runner.sh";

if ! test -f "${TEST_RUNNER}";
then
	TEST_RUNNER="./test_runner.sh";
fi

if ! test -f "${TEST_RUNNER}";
then
	echo "Missing test runner: ${TEST_RUNNER}";

	exit ${EXIT_FAILURE};
fi

source ${TEST_RUNNER};

assert_availability_binary man;

RESULT=${EXIT_IGNORE};

TMPDIR="tmp$$";

rm -rf ${TMPDIR};
mkdir ${TMPDIR};

MANUALS_PATH="../manuals";

if ! test -d ${MANUALS_PATH};
then
	MANUALS_PATH="manuals";
fi

if ! test -d ${MANUALS_PATH};
then
	echo "Manuals directory not found.";

	exit ${EXIT_IGNORE};
fi

for INPUT_FILE in ${MANUALS_PATH}/*.[13];
do
	run_test "${INPUT_FILE}";
	RESULT=$?;

	if test ${RESULT} -ne ${EXIT_SUCCESS};
	then
		break;
	fi
done

rm -rf ${TMPDIR};

exit ${RESULT};