2020-04-21 10:40:25 +00:00
|
|
|
#!/bin/sh
|
2019-06-06 15:28:20 +00:00
|
|
|
|
|
|
|
PROG="$1"
|
|
|
|
|
|
|
|
rm -rf testoutput
|
|
|
|
mkdir -p testoutput
|
|
|
|
|
|
|
|
TEST=testoutput
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
TESTNAME="Test that listen to t1+c1 works with meters transmitting using t1+c1"
|
|
|
|
TESTRESULT="ERROR"
|
|
|
|
|
2019-06-06 15:28:20 +00:00
|
|
|
cat simulations/simulation_t1_and_c1.txt | grep '^{' > $TEST/test_expected.txt
|
|
|
|
$PROG --format=json --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
|
|
|
MyTapWater multical21:c1 76348799 "" \
|
|
|
|
Wasser apator162:t1 20202020 "" \
|
|
|
|
> $TEST/test_output.txt
|
2020-04-22 06:07:19 +00:00
|
|
|
if [ "$?" = "0" ]
|
2019-06-06 15:28:20 +00:00
|
|
|
then
|
|
|
|
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
|
|
|
|
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
2020-04-22 06:07:19 +00:00
|
|
|
if [ "$?" = "0" ]
|
2019-06-06 15:28:20 +00:00
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo "OK: $TESTNAME"
|
|
|
|
TESTRESULT="OK"
|
2019-06-06 15:28:20 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
|
|
|
|
2019-06-06 15:28:20 +00:00
|
|
|
MSG=$($PROG --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
|
|
|
MyTapWater multical21:c1 76348799 "" \
|
|
|
|
Wasser apator162:s1 20202020 "")
|
|
|
|
|
|
|
|
if [ "$MSG" != "(cmdline) cannot set link modes to: s1 because meter apator162 only transmits on: c1,t1" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Did not expect: $MSG
|
2019-06-06 15:28:20 +00:00
|
|
|
exit 1
|
2019-11-03 21:00:18 +00:00
|
|
|
else
|
|
|
|
echo "OK: $TESTNAME"
|
2019-06-06 15:28:20 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
TESTNAME="Test that setting multical21 to t1 fails"
|
|
|
|
TESTRESULT="ERROR"
|
|
|
|
|
2019-06-06 15:28:20 +00:00
|
|
|
MSG=$($PROG --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
|
|
|
MyTapWater multical21:t1 76348799 "" \
|
|
|
|
Wasser apator162:c1 20202020 "")
|
|
|
|
|
|
|
|
if [ "$MSG" != "(cmdline) cannot set link modes to: t1 because meter multical21 only transmits on: c1" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Did not expect: $MSG
|
2019-06-06 15:28:20 +00:00
|
|
|
exit 1
|
2019-11-03 21:00:18 +00:00
|
|
|
else
|
|
|
|
echo "OK: $TESTNAME"
|
2019-06-06 15:28:20 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
TESTNAME="Test that the warning for missed telegrams work"
|
|
|
|
TESTRESULT="ERROR"
|
|
|
|
|
2019-06-06 15:28:20 +00:00
|
|
|
MSG=$($PROG --s1 simulations/simulation_t1_and_c1.txt \
|
|
|
|
MyTapWater multical21:c1 76348799 "" \
|
|
|
|
Wasser apator162:t1 20202020 "" | tr -d ' \n')
|
|
|
|
|
|
|
|
CORRECT="(config)Youhavespecifiedtolistentothelinkmodes:s1butthemetersmighttransmiton:c1,t1(config)Thereforeyoumightmisstelegrams!Pleasespecifytheexpectedtransmitmodeforthemeters,eg:apator162:t1(config)Oruseadonglethatcanlistentoalltherequiredlinkmodesatthesametime."
|
|
|
|
if [ "$MSG" != "$CORRECT" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Did not expect:
|
2019-06-06 15:28:20 +00:00
|
|
|
echo $MSG
|
|
|
|
exit 1
|
2019-11-03 21:00:18 +00:00
|
|
|
else
|
|
|
|
echo "OK: $TESTNAME"
|
2019-06-06 15:28:20 +00:00
|
|
|
fi
|