2019-02-24 14:20:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
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-02-24 16:31:32 +00:00
|
|
|
ERRORS=false
|
|
|
|
|
2019-02-27 18:42:21 +00:00
|
|
|
RES=$($PROG --useconfig=tests/config2 2>&1)
|
|
|
|
|
|
|
|
if [ ! "$RES" = "" ]
|
|
|
|
then
|
|
|
|
ERRORS=true
|
|
|
|
echo Expected no output on stdout and stderr
|
|
|
|
echo but got------------------
|
|
|
|
echo $RES
|
|
|
|
echo ---------------------
|
|
|
|
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
|
|
|
|
ERRORS=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat simulations/simulation_t1.txt | grep '^{' | grep 12345678 | tail -n 1 > $TEST/test_expected.txt
|
|
|
|
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
|
|
|
|
ERRORS=true
|
|
|
|
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
|
|
|
|
ERRORS=true
|
|
|
|
fi
|
|
|
|
|
2019-02-27 18:42:21 +00:00
|
|
|
RES=$(cat $TEST/thelog2.txt)
|
2019-02-24 16:31:32 +00:00
|
|
|
|
|
|
|
if [ ! "$RES" = "" ]
|
|
|
|
then
|
|
|
|
ERRORS=true
|
|
|
|
cat $TEST/thelog2.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ERRORS" = "true" ]
|
|
|
|
then
|
|
|
|
echo Failed config2 tests
|
|
|
|
else
|
2019-02-26 21:19:16 +00:00
|
|
|
echo Config2 with logfile and meterfiles OK
|
2019-02-24 16:31:32 +00:00
|
|
|
fi
|