summaryrefslogtreecommitdiffstats
path: root/iptables/tests/shell/testcases/iptables/0009-unknown-arg_0
blob: ac6e743966196561b699638fcc3c8ec8203250b5 (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
#!/bin/bash

rc=0

check() {
	local cmd="$1"
	local msg="$2"

	$XT_MULTI $cmd 2>&1 | grep -q "$msg" || {
		echo "cmd: $XT_MULTI $1"
		echo "exp: $msg"
		echo "res: $($XT_MULTI $cmd 2>&1)"
		rc=1
	}
}

cmds="iptables ip6tables"
[[ $XT_MULTI == *xtables-nft-multi ]] && {
	cmds+=" ebtables"
	cmds+=" iptables-translate"
	cmds+=" ip6tables-translate"
	cmds+=" ebtables-translate"
}

for cmd in $cmds; do
	check "${cmd} --foo" 'unknown option "--foo"'
	check "${cmd} -A" 'option "-A" requires an argument'
	check "${cmd} -aL" 'unknown option "-a"'
done

exit $rc