wmbusmeters/tests/test_listen_to_all.sh

85 wiersze
1.9 KiB
Bash
Czysty Zwykły widok Historia

2019-02-28 16:30:29 +00:00
#!/bin/bash
PROG="$1"
if [ "$PROG" = "" ]
then
echo Please supply the binary to be tested as the first argument.
exit 1
fi
TEST=testoutput
LOGFILE=$TEST/logfile
LOGFILE_EXPECTED=$TEST/logfile.expected
2019-02-28 16:30:29 +00:00
mkdir -p $TEST
rm -f $LOGFILE
cat > $LOGFILE_EXPECTED <<EOF
2019-02-28 16:30:29 +00:00
No meters configured. Printing id:s of all telegrams heard!
Received telegram from: 12345678
manufacturer: (SON) Sontex, Switzerland
2019-02-28 16:30:29 +00:00
device type: Warm Water (30°C-90°C) meter
Received telegram from: 11111111
manufacturer: (SON) Sontex, Switzerland
2019-02-28 16:30:29 +00:00
device type: Water meter
Received telegram from: 12345699
manufacturer: (SEN) Sensus Metering Systems, Germany
2019-02-28 16:30:29 +00:00
device type: Water meter
2019-03-11 16:31:34 +00:00
Received telegram from: 33225544
manufacturer: (SEN) Sensus Metering Systems, Germany
2019-03-11 16:31:34 +00:00
device type: Water meter
Received telegram from: 20202020
manufacturer: (APA) Apator, Poland
device type: Water meter
Received telegram from: 10101010
manufacturer: (APA) Apator, Poland
device type: Electricity meter
Received telegram from: 34333231
manufacturer: (TCH) Techem Service
device type: Warm water
2019-02-28 16:30:29 +00:00
EOF
EXPECTED=$(cat $LOGFILE_EXPECTED)
2019-02-28 16:30:29 +00:00
RES=$($PROG --logfile=$LOGFILE --t1 simulations/simulation_t1.txt 2>&1)
if [ ! "$RES" = "" ]
then
ERRORS=true
echo Expected no output on stdout and stderr
echo but got------------------
echo $RES
echo ---------------------
fi
GOT=$(cat $LOGFILE)
if [ ! "$GOT" = "$EXPECTED" ]
then
echo GOT--------------
echo $GOT
echo EXPECTED---------
echo $EXPECTED
echo -----------------
exit 1
else
echo OK: listen to all with logfile
fi
GOT=$($PROG --t1 simulations/simulation_t1.txt 2>&1)
if [ ! "$GOT" = "$EXPECTED" ]
then
echo GOT--------------
echo $GOT
echo EXPECTED---------
echo $EXPECTED
echo -----------------
exit 1
else
echo OK: listen to all with stdout
fi