wmbusmeters/tests/test_elements.sh

37 wiersze
921 B
Bash
Czysty Zwykły widok Historia

#!/bin/sh
2019-04-04 06:36:22 +00:00
PROG="$1"
TEST=testoutput
mkdir -p $TEST/meter_readings3
2019-11-03 21:00:18 +00:00
TESTNAME="Test single meter conf file matches any id"
TESTRESULT="ERROR"
2019-06-20 12:28:52 +00:00
rm -f $TEST/meter_readings3/*
2019-04-04 06:36:22 +00:00
cat simulations/simulation_multiple_qcalorics.txt | grep '^{' > $TEST/test_expected.txt
$PROG --useconfig=tests/config3 > $TEST/test_output.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-04-04 06:36:22 +00:00
then
2019-06-20 12:28:52 +00:00
FILES=$(ls $TEST/meter_readings3/ | tr '\n' ' ')
if [ ! "$FILES" = "78563412 78563413 88563414 " ]
then
echo Failure, not the expected files in meter readings directory.
exit 1
fi
cat $TEST/meter_readings3/* | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt
2019-04-04 06:36:22 +00:00
diff $TEST/test_expected.txt $TEST/test_responses.txt
2020-04-22 06:07:19 +00:00
if [ "$?" = "0" ]
2019-04-04 06:36:22 +00:00
then
2019-11-03 21:00:18 +00:00
echo OK: $TESTNAME
TESTRESULT="OK"
2019-04-04 06:36:22 +00:00
fi
2019-11-03 21:00:18 +00:00
fi
if [ "$TESTRESULT" = "ERROR" ]
then
echo ERROR: $TESTNAME
2019-04-04 06:36:22 +00:00
exit 1
fi