2021-08-01 16:24:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
PROG="$1"
|
|
|
|
|
|
|
|
mkdir -p testoutput
|
|
|
|
TEST=testoutput
|
|
|
|
|
|
|
|
TESTNAME="Test unix timestamp in fields"
|
|
|
|
TESTRESULT="ERROR"
|
|
|
|
|
|
|
|
METERS="Votten aventieswm 61070071 A004EB23329A477F1DD2D7820B56EB3D"
|
|
|
|
|
|
|
|
cat simulations/simulation_unix_timestamp.txt | grep '^{' > $TEST/test_expected.txt
|
|
|
|
|
2021-08-27 09:22:08 +00:00
|
|
|
# Wait for the second to switch before starting the run. This will avoid spurious errors
|
|
|
|
# where the second barrier switches inside the test.
|
|
|
|
PREV=$(date +%s)
|
|
|
|
NOW=$PREV
|
|
|
|
while [ "$NOW" = "$PREV" ] ; do NOW=$(date "+%s") ; done
|
|
|
|
|
2021-08-01 16:24:19 +00:00
|
|
|
cat simulations/simulation_unix_timestamp.txt | grep '^|' | sed 's/^|//' | sed "s/UT/${NOW}/" > $TEST/test_expected.txt
|
2021-08-08 14:50:25 +00:00
|
|
|
$PROG --format=fields --separator='*' --field_extra=extra_info --selectfields=total_m3,timestamp_ut,timestamp_utc,timestamp_lt,name,id,extra simulations/simulation_t1.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt
|
2021-08-27 09:22:08 +00:00
|
|
|
|
2021-08-01 16:24:19 +00:00
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
2021-08-08 14:50:25 +00:00
|
|
|
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/g' | \
|
|
|
|
sed 's/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9].[0-9][0-9]Z/1111-11-11T11:11.11Z/g' \
|
|
|
|
> $TEST/test_responses.txt
|
2021-08-01 16:24:19 +00:00
|
|
|
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
echo OK fields: $TESTNAME
|
|
|
|
TESTRESULT="OK"
|
|
|
|
else
|
2021-08-27 09:22:08 +00:00
|
|
|
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
2021-08-01 16:24:19 +00:00
|
|
|
TESTRESULT="ERROR"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "wmbusmeters returned error code: $?"
|
|
|
|
cat $TEST/test_output.txt
|
|
|
|
cat $TEST/test_stderr.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$TESTRESULT" = "ERROR" ]
|
|
|
|
then
|
|
|
|
echo ERROR: $TESTNAME
|
|
|
|
exit 1
|
|
|
|
fi
|