Add test for non-existant driver.

pull/1090/head
Fredrik Öhrström 2023-11-06 21:04:40 +01:00
rodzic b9306be914
commit 22d6880385
4 zmienionych plików z 33 dodań i 1 usunięć

Wyświetl plik

@ -56,6 +56,8 @@ namespace
vector<uchar> content;
t->extractPayload(&content);
if (content.size() < 4) return;
map<string,pair<int,DVEntry>> vendor_values;
string total;

Wyświetl plik

@ -225,7 +225,12 @@ bool lookupDriverInfo(const string& driver_name, DriverInfo *out_di)
DriverInfo *di = lookupDriver(driver_name);
if (di == NULL)
{
// Ok, not built in, try to load it from file.
if (!endsWith(driver_name, ".xmq") || !checkFileExists(driver_name.c_str()))
{
return false;
}
// Ok, not built in, but it ends with .xmq and the file exists!
string new_name = loadDriver(driver_name);
// Check again if it was registered.

Wyświetl plik

@ -30,6 +30,9 @@ if [ "$?" != "0" ]; then RC="1"; fi
tests/test_s1_meters.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_non_existant_driver.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi
tests/test_mbus.sh $PROG
if [ "$?" != "0" ]; then RC="1"; fi

Wyświetl plik

@ -0,0 +1,22 @@
#!/bin/sh
PROG="$1"
rm -rf testoutput
mkdir -p testoutput
TEST=testoutput
$PROG 434493157856341233038c2075900f002c25b30a000021924d4f2fb66e017a75002007109058475f4bc91df878b80a1b0f98b629024aac727942bfc549233c0140829b93 MyTapWater q40 12345678 NOKEY > $TEST/test_output.txt 2>&1
EXPECT='Not a valid meter driver "q40"'
RES=$(cat $TEST/test_output.txt | grep -o "$EXPECT" | tail -n 1)
if [ "$RES" = "$EXPECT" ]
then
echo OK: Test non-existant driver
else
cat $TEST/test_output.txt
echo ERROR Failed non-existant driver check!
exit 1
fi