#!/bin/sh
#
# Test that the %(myhost) function returns the local hostname and
# the localname entry out of the mts configuration file.
#

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

set +e
host=`${MH_OBJ_DIR}/test/getcanon`
set -e
run_test "${MH_LIBEXEC_DIR}/ap -format %(myhost) ignore" "$host" \
         "local hostname test"

cp ${MHMTSCONF} ${MH_TEST_DIR}/Mail/mts.conf || exit 1
MHMTSCONF="${MH_TEST_DIR}/Mail/mts.conf"

echo "localname: some.random.name" >> ${MHMTSCONF}

run_test "${MH_LIBEXEC_DIR}/ap -format %(myhost) ignore" "some.random.name" \
         "mts.conf localname test"

exit $failed
