wmbusmeters/tests/test_t1_meters.sh

70 wiersze
2.2 KiB
Bash
Czysty Zwykły widok Historia

#!/bin/sh
2019-02-23 17:30:16 +00:00
PROG="$1"
mkdir -p testoutput
TEST=testoutput
2019-11-03 21:00:18 +00:00
TESTNAME="Test T1 meters"
TESTRESULT="ERROR"
2020-02-06 17:20:47 +00:00
METERS="MyWarmWater supercom587 12345678 NOKEY
MyColdWater supercom587 11111111 NOKEY
MoreWater iperl 12345699 NOKEY
WaterWater iperl 33225544 NOKEY
MyElectricity1 amiplus 10101010 NOKEY
Duschen mkradio3 34333231 NOKEY
HeatMeter vario451 58234965 NOKEY
2020-02-12 06:52:29 +00:00
Room fhkvdataiii 11776622 NOKEY
2020-02-06 17:20:47 +00:00
HeatMeter eurisii 88018801 NOKEY
Smokeo lansensm 00010204 NOKEY
2020-02-06 17:20:47 +00:00
Tempoo lansenth 00010203 NOKEY
Rummet rfmamb 11772288 NOKEY
IzarWater izar 21242472 NOKEY
IzarWater2 izar 66290778 NOKEY
HydrusWater hydrus 64646464 NOKEY
HydrodigitWater hydrodigit 86868686 NOKEY
Q400Water q400 72727272 AAA896100FED12DD614DD5D46369ACDD
Elen1 ebzwmbe 22992299 NOKEY
Elen2 esyswm 77997799 NOKEY
2020-02-23 17:41:21 +00:00
Elen3 ehzp 55995599 NOKEY
Vatten apator08 004444dd NOKEY
Wasser rfmtx1 74737271 NOKEY"
2020-02-06 17:20:47 +00:00
2019-02-23 17:30:16 +00:00
cat simulations/simulation_t1.txt | grep '^{' > $TEST/test_expected.txt
2020-02-06 17:20:47 +00:00
$PROG --format=json simulations/simulation_t1.txt $METERS > $TEST/test_output.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-02-23 17:30:16 +00:00
then
cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
2019-02-23 17:30:16 +00:00
diff $TEST/test_expected.txt $TEST/test_responses.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-02-23 17:30:16 +00:00
then
2020-02-06 17:20:47 +00:00
echo OK json: $TESTNAME
2019-11-03 21:00:18 +00:00
TESTRESULT="OK"
2020-04-26 13:08:24 +00:00
else
TESTRESULT="ERROR"
2019-02-23 17:30:16 +00:00
fi
2019-11-03 21:00:18 +00:00
fi
2020-02-06 17:20:47 +00:00
cat simulations/simulation_t1.txt | grep '^|' | sed 's/^|//' > $TEST/test_expected.txt
$PROG --format=fields simulations/simulation_t1.txt $METERS > $TEST/test_output.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2020-02-06 17:20:47 +00:00
then
cat $TEST/test_output.txt | sed 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9].[0-9][0-9]$/1111-11-11 11:11.11/' > $TEST/test_responses.txt
diff $TEST/test_expected.txt $TEST/test_responses.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2020-02-06 17:20:47 +00:00
then
2020-02-06 18:06:53 +00:00
echo OK fields: $TESTNAME
2020-02-06 17:20:47 +00:00
TESTRESULT="OK"
2020-04-26 13:08:24 +00:00
else
TESTRESULT="ERROR"
2020-02-06 17:20:47 +00:00
fi
fi
2019-11-03 21:00:18 +00:00
if [ "$TESTRESULT" = "ERROR" ]
then
echo ERROR: $TESTNAME
exit 1
2019-02-23 17:30:16 +00:00
fi