summaryrefslogtreecommitdiff
path: root/test/integration/test-00-commands-have-help
blob: 699cdef150aa714b47f6a8b0f9bec5306c938e59 (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
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configarchitecture 'amd64'

# this test does double duty: The obvious is checking for --help and co,
# but it also checks if the binary can find all methods in the library.
# The later is quite handy for manual testing of non-abibreaking changes
export LD_BIND_NOW=1
# german variant of klingon used for testing usage of non-existent l10n
export LC_ALL=tlh_DE.UTF-8

checkversionmessage() {
	testsuccess grep '^apt .* (' ${1}-help.output
}

checkhelpmessage() {
	checkversionmessage "$1"
	testsuccess grep '^Usage:' ${1}-help.output
}

checkoptions() {
	testsuccess $1 --help
	cp -f rootdir/tmp/testsuccess.output ${1}-help.output
	checkhelpmessage "$1"

	testsuccess $1 --version
	cp -f rootdir/tmp/testsuccess.output ${1}-help.output
	checkversionmessage "$1"
}

for CMD in 'apt-cache' 'apt-cdrom' 'apt-config' \
	'apt-extracttemplates' 'apt-get' 'apt-helper' \
	'apt-mark' 'apt-sortpkgs' 'apt' 'apt-ftparchive'; do
	cmd="$(echo "$CMD" | tr -d '-')"
	msgtest 'Test for failure with no parameters calling' "$CMD"
	if $cmd > ${cmd}-help.output 2>&1; then
		echo
		cat ${cmd}-help.output
		msgfail 'zero exit'
	else
		msgpass
	fi
	checkhelpmessage "$cmd"
	checkoptions "$cmd"
done

for CMD in 'apt-dump-solver'  'apt-internal-solver' 'apt-internal-planner'; do
	checkoptions "$(echo "$CMD" | tr -d '-')"
done

# in times of need, we all look for super cow to save the day
testsuccess aptget moo
testsuccess aptget moo -q=2
testsuccess aptget moo moo
testsuccess aptget moo moo -q=2
testsuccess aptget moo moo --color
testsuccess aptget moo moo moo
testsuccess aptget moo moo moo -q=2
testsuccess aptget moo moo moo moo
testsuccess aptget moo moo moo moo -q=2