#!/bin/sh
# Exercise both installed entry points without touching the network.
set -e

for cmd in dhcpig dhcpig-web; do
	"$cmd" --help > "$AUTOPKGTEST_TMP/$cmd.help"
	if ! [ -s "$AUTOPKGTEST_TMP/$cmd.help" ]; then
		echo "ERROR: $cmd --help produced no output" >&2
		exit 1
	fi
done

# The 2.x CLI is subcommand-driven; check the documented set is present.
for sub in exhaust scan active-scan release release-previous restore ifaces report; do
	if ! grep -q -- "$sub" "$AUTOPKGTEST_TMP/dhcpig.help"; then
		echo "ERROR: subcommand '$sub' missing from dhcpig --help" >&2
		cat "$AUTOPKGTEST_TMP/dhcpig.help" >&2
		exit 1
	fi
done

# A bare interface argument was the 1.x invocation and must now fail cleanly
# rather than doing something unexpected.
if dhcpig lo > "$AUTOPKGTEST_TMP/legacy" 2>&1; then
	echo "ERROR: legacy 'dhcpig <iface>' invocation unexpectedly succeeded" >&2
	exit 1
fi
