#!/bin/sh

set -e

. ./helpers

ME=$(basename $0)

setup_sandbox

# The switch template is built with root auto-login on both the VGA
# console (reachable over VNC) and the serial one (reachable over the
# IPMI SOL, with the kernel console on ttyS0 as well): the consoles
# are only reachable from the ikvswitch host, and typing the root
# password on each of them is tedious.
rm ${SANDBOX}/var/lib/ikvswitch/templates/ikvswitch-template.raw
export IKV_MOCK_BODI_LOG=${SANDBOX}/bodi-args.log
run_setup start
assert_eq "ikvswitch-setup start rc" "${SETUP_RC}" "0"
assert_file_contains "bodi tty autologin" "${IKV_MOCK_BODI_LOG}" "--tty-autologin yes"
assert_file_contains "bodi serial getty" "${IKV_MOCK_BODI_LOG}" "--add-serial-getty ttyS0"
if [ ! -r ${SANDBOX}/var/lib/ikvswitch/templates/ikvswitch-template.raw ] ; then
	echo "test_tty_autologin: the template build did not produce the template"
	exit 1
fi

exit 0
