d303a8f2f47604026df9bd72f587369e19522d62
[mmh] / test / format / test-myhost
1 #!/bin/sh
2 #
3 # Test that the %(myhost) function returns the local hostname and
4 # the localname entry out of the mts configuration file.
5 #
6
7 if [ -z "${MH_TEST_COMMON}" ]; then
8         echo "MH_TEST_COMMON not set; try running via 'make check'"
9 fi
10
11 . ${MH_TEST_COMMON}
12
13 setup_test
14
15 runtest()
16 {
17         testoutput=$(${MH_LIB_DIR}/ap -format "%(myhost)" ignore)
18
19         if [ x"$1" != x"${testoutput}" ]; then
20                 echo "For $2, expected $1 but got ${testoutput}"
21                 exit 1
22         fi
23 }
24
25 runtest "$(hostname)" "local hostname test"
26
27 cp ${MHMTSCONF} ${MH_TEST_DIR}/Mail/mts.conf || exit 1
28 export MHMTSCONF="${MH_TEST_DIR}/Mail/mts.conf"
29
30 echo "localname: some.random.name" >> ${MHMTSCONF}
31
32 runtest "some.random.name" "mts.conf localname test"
33
34 exit 0