2020-04-21 10:40:25 +00:00
|
|
|
#!/bin/sh
|
2019-02-24 14:20:55 +00:00
|
|
|
|
|
|
|
PROG="$1"
|
|
|
|
TEST=testoutput
|
2019-02-24 16:31:32 +00:00
|
|
|
rm -f $TEST/thelog2.txt
|
|
|
|
rm -rf $TEST/meter_readings2
|
2019-02-24 14:20:55 +00:00
|
|
|
mkdir -p $TEST/meter_readings2
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
TESTNAME="Test logfile"
|
|
|
|
TESTRESULT="ERRORS"
|
2019-02-24 16:31:32 +00:00
|
|
|
|
2019-02-27 18:42:21 +00:00
|
|
|
RES=$($PROG --useconfig=tests/config2 2>&1)
|
|
|
|
|
|
|
|
if [ ! "$RES" = "" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
2019-02-27 18:42:21 +00:00
|
|
|
echo Expected no output on stdout and stderr
|
|
|
|
echo but got------------------
|
|
|
|
echo $RES
|
|
|
|
echo ---------------------
|
2019-11-03 21:00:18 +00:00
|
|
|
exit 1
|
2019-02-27 18:42:21 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-24 16:31:32 +00:00
|
|
|
cat simulations/simulation_t1.txt | grep '^{' | grep 12345699 | tail -n 1 > $TEST/test_expected.txt
|
|
|
|
cat $TEST/meter_readings2/MoreWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
|
|
|
|
diff $TEST/test_expected.txt $TEST/test_response.txt
|
|
|
|
if [ ! "$?" = "0" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Expected to find meter MoreWater in readings, but did not.
|
|
|
|
exit 1
|
2019-02-24 16:31:32 +00:00
|
|
|
fi
|
|
|
|
|
2020-02-06 14:41:48 +00:00
|
|
|
cat simulations/simulation_t1.txt | grep '^{' | grep supercom | grep 12345678 | tail -n 1 > $TEST/test_expected.txt
|
2019-02-24 16:31:32 +00:00
|
|
|
cat $TEST/meter_readings2/MyWarmWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
|
|
|
|
diff $TEST/test_expected.txt $TEST/test_response.txt
|
|
|
|
if [ ! "$?" = "0" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Expected to find meter MyWarmWater in readings, but did not.
|
|
|
|
exit 1
|
2019-02-24 16:31:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat simulations/simulation_t1.txt | grep '^{' | grep 11111111 | tail -n 1 > $TEST/test_expected.txt
|
|
|
|
cat $TEST/meter_readings2/MyColdWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt
|
|
|
|
diff $TEST/test_expected.txt $TEST/test_response.txt
|
|
|
|
if [ ! "$?" = "0" ]
|
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Expected to find meter MyColdWater in readings, but did not.
|
|
|
|
exit 1
|
2019-02-24 16:31:32 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
RES=$(cat $TEST/thelog2.txt | tr '\n' ' ' | tr -d ' ')
|
2019-02-24 16:31:32 +00:00
|
|
|
|
2020-10-31 14:16:14 +00:00
|
|
|
EXP=$(printf 'telegram=|A244EE4D785634123C067A8F000000|0C1348550000426CE1F14C130000000082046C21298C0413330000008D04931E3A3CFE3300000033000000330000003300000033000000330000003300000033000000330000003300000033000000330000004300000034180000046D0D0B5C2B03FD6C5E150082206C5C290BFD0F0200018C4079678885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|A244EE4D111111113C077AAC000000|0C1389490000426CE1F14C130000000082046C21298C0413010000008D04931E3A3CFE0100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000001600000031130000046D0A0C5C2B03FD6C60150082206C5C290BFD0F0200018C4079629885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0 telegram=|1E44AE4C9956341268077A36001000|2F2F0413181E0000023B00002F2F2F2F|+0 telegram=|1844AE4C4455223368077A55000000|041389E20100023B0000|+0' | tr '\n' ' ' | tr -d ' ')
|
2019-02-24 16:31:32 +00:00
|
|
|
|
2019-11-03 21:00:18 +00:00
|
|
|
if [ "$RES" != "$EXP" ]
|
2019-02-24 16:31:32 +00:00
|
|
|
then
|
2019-11-03 21:00:18 +00:00
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
echo Expected:
|
|
|
|
echo $EXP
|
|
|
|
echo But got:
|
|
|
|
echo $RES
|
|
|
|
exit 1
|
2019-02-24 16:31:32 +00:00
|
|
|
fi
|
2019-11-03 21:00:18 +00:00
|
|
|
|
|
|
|
echo OK: $TESTNAME
|