diff --git a/tests/config5/etc/wmbusmeters.d/Vatten b/tests/config5/etc/wmbusmeters.d/Vatten index 6ea39b3..be41515 100644 --- a/tests/config5/etc/wmbusmeters.d/Vatten +++ b/tests/config5/etc/wmbusmeters.d/Vatten @@ -2,4 +2,4 @@ name=Vatten type=supercom587 id=12345678 key= -shell=echo "TESTING SHELL $METER_JSON" > /tmp/wmbusmeters_meter_shell_test \ No newline at end of file +shell=echo "TESTING SHELL $(echo $METER_JSON | jq -c --sort-keys .)" > /tmp/wmbusmeters_meter_shell_test \ No newline at end of file diff --git a/tests/test_aes.sh b/tests/test_aes.sh index 934ef82..cb9808c 100755 --- a/tests/test_aes.sh +++ b/tests/test_aes.sh @@ -10,14 +10,14 @@ mkdir -p $TEST TESTNAME="Test aes encrypted telegrams" TESTRESULT="ERROR" -cat simulations/serial_aes.msg | grep '^{' | tr -d '#' > $TEST/test_expected.txt +cat simulations/serial_aes.msg | grep '^{' | tr -d '#' | jq --sort-keys . > $TEST/test_expected.txt cat simulations/serial_aes.msg | grep '^[CT]' | tr -d '#' > $TEST/test_input.txt cat $TEST/test_input.txt | $PROG --format=json "stdin:rtlwmbus" \ ApWater apator162 88888888 00000000000000000000000000000000 \ Vatten multical21 76348799 28F64A24988064A079AA2C807D6102AE \ - Wasser supercom587 77777777 5065747220486F6C79737A6577736B69 > $TEST/test_output.txt 2> $TEST/test_stderr.txt + Wasser supercom587 77777777 5065747220486F6C79737A6577736B69 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt -cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_response.txt +cat $TEST/test_output.txt | 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 diff --git a/tests/test_apas.sh b/tests/test_apas.sh index 0497332..7e1263f 100755 --- a/tests/test_apas.sh +++ b/tests/test_apas.sh @@ -18,11 +18,11 @@ METERS="Wasser apator162 20202020 NOKEY MyTapWatere apator162 27202020 NOKEY MyTapWaterf apator162 03410514 NOKEY" -cat simulations/simulation_apas.txt | grep '^{' > $TEST/test_expected.txt -$PROG --format=json simulations/simulation_apas.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt +cat simulations/simulation_apas.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt +$PROG --format=json simulations/simulation_apas.txt $METERS 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt if [ "$?" = "0" ] then - cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt + cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt diff $TEST/test_expected.txt $TEST/test_responses.txt if [ "$?" = "0" ] then diff --git a/tests/test_izars.sh b/tests/test_izars.sh index 2137740..5ed1460 100755 --- a/tests/test_izars.sh +++ b/tests/test_izars.sh @@ -20,11 +20,11 @@ METERS="IzarWater izar 21242472 NOKEY IzarWater5 izar 20e4ffde NOKEY IzarWater6 auto 48500375 NOKEY" -cat simulations/simulation_izars.txt | grep '^{' > $TEST/test_expected.txt -$PROG --format=json simulations/simulation_izars.txt $METERS > $TEST/test_output.txt 2> $TEST/test_stderr.txt +cat simulations/simulation_izars.txt | grep '^{' | jq --sort-keys . > $TEST/test_expected.txt +$PROG --format=json simulations/simulation_izars.txt $METERS 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt if [ "$?" = "0" ] then - cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt + cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt diff $TEST/test_expected.txt $TEST/test_responses.txt if [ "$?" = "0" ] then diff --git a/tests/test_key_warnings.sh b/tests/test_key_warnings.sh index b40a8a9..98636a8 100755 --- a/tests/test_key_warnings.sh +++ b/tests/test_key_warnings.sh @@ -8,7 +8,8 @@ TEST=testoutput TESTNAME="Test that failed decryption warning only prints once." TESTRESULT="OK" -$PROG --format=json simulations/simulation_bad_keys.txt room fhkvdataiv 03065716 NOKEY > $TEST/test_output.txt 2> $TEST/test_stderr.txt +$PROG --format=json simulations/simulation_bad_keys.txt room fhkvdataiv 03065716 NOKEY \ + 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt cat > $TEST/expected_err.txt < $TEST/test_output.txt 2> $TEST/test_stderr.txt +$PROG --format=json simulations/simulation_bad_keys.txt room fhkvdataiv 03065716 00112233445566778899AABBCCDDEEFF \ + 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt cat > $TEST/expected_err.txt < $TEST/test_output.txt 2> $TEST/test_stderr.txt +$PROG --shell='echo "$METER_JSON"' simulations/simulation_shell.txt MWW supercom587 12345678 "" \ + 2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt if [ "$?" = "0" ] then - cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt - echo '{"media":"warm water","meter":"supercom587","name":"MWW","id":"12345678","total_m3":5.548,"timestamp":"1111-11-11T11:11:11Z"}' > $TEST/test_expected.txt + cat $TEST/test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST/test_responses.txt + echo '{"media":"warm water","meter":"supercom587","name":"MWW","id":"12345678","total_m3":5.548,"timestamp":"1111-11-11T11:11:11Z"}' \ + | jq --sort-keys . > $TEST/test_expected.txt diff $TEST/test_expected.txt $TEST/test_responses.txt if [ "$?" = "0" ] then diff --git a/tests/test_shell2.sh b/tests/test_shell2.sh index 43ccbfb..a3101da 100755 --- a/tests/test_shell2.sh +++ b/tests/test_shell2.sh @@ -7,16 +7,19 @@ mkdir -p $TEST TESTNAME="Test shell in config file" TESTRESULT="ERROR" -$PROG --useconfig=tests/config5 > $TEST/test_output.txt 2> $TEST/test_stderr.txt +$PROG --useconfig=tests/config5 2> $TEST/test_stderr.txt > $TEST/test_output.txt if [ "$?" = "0" ] then INFO=$(cat /tmp/wmbusmeters_meter_shell_test | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"1111-11-11T11:11:11Z"/') - EXPECTED=$(echo 'TESTING SHELL {"media":"warm water","meter":"supercom587","name":"Vatten","id":"12345678","total_m3":5.548,"timestamp":"1111-11-11T11:11:11Z"}') + EXPECTED='TESTING SHELL {"id":"12345678","media":"warm water","meter":"supercom587","name":"Vatten","timestamp":"1111-11-11T11:11:11Z","total_m3":5.548}' if [ "$INFO" = "$EXPECTED" ] then echo OK: $TESTNAME TESTRESULT="OK" + else + echo "Expected: $EXPECTED" + echo "Got : $INFO" fi fi