kopia lustrzana https://github.com/weetmuts/wmbusmeters
Improved testing.
rodzic
291c0b2452
commit
cae1144283
4
Makefile
4
Makefile
|
@ -166,10 +166,10 @@ clean:
|
|||
rm -rf build/* build_arm/* build_debug/* build_arm_debug/* *~
|
||||
|
||||
test:
|
||||
./test.sh build/wmbusmeters
|
||||
@./test.sh build/wmbusmeters
|
||||
|
||||
testd:
|
||||
./test.sh build_debug/wmbusmeters
|
||||
@./test.sh build_debug/wmbusmeters
|
||||
|
||||
update_manufacturers:
|
||||
iconv -f utf-8 -t ascii//TRANSLIT -c DLMS_Flagids.csv -o tmp.flags
|
||||
|
|
|
@ -43,7 +43,7 @@ struct SerialDeviceSimulator;
|
|||
|
||||
struct SerialCommunicationManagerImp : public SerialCommunicationManager
|
||||
{
|
||||
SerialCommunicationManagerImp(time_t exit_after_seconds, time_t reopen_after_seconds);
|
||||
SerialCommunicationManagerImp(time_t exit_after_seconds, time_t reopen_after_seconds, bool start_event_loop);
|
||||
~SerialCommunicationManagerImp();
|
||||
|
||||
unique_ptr<SerialDevice> createSerialDeviceTTY(string dev, int baud_rate);
|
||||
|
@ -157,7 +157,7 @@ int SerialDeviceImp::receive(vector<uchar> *data)
|
|||
|
||||
if (isDebugEnabled())
|
||||
{
|
||||
if (expecting_ascii_)
|
||||
if (true) // expecting_ascii_)
|
||||
{
|
||||
string msg = safeString(*data);
|
||||
debug("(serial) received ascii %s\n", msg.c_str());
|
||||
|
@ -526,11 +526,17 @@ struct SerialDeviceSimulator : public SerialDeviceImp
|
|||
};
|
||||
|
||||
SerialCommunicationManagerImp::SerialCommunicationManagerImp(time_t exit_after_seconds,
|
||||
time_t reopen_after_seconds)
|
||||
time_t reopen_after_seconds,
|
||||
bool start_event_loop)
|
||||
{
|
||||
running_ = true;
|
||||
max_fd_ = 0;
|
||||
pthread_create(&thread_, NULL, startLoop, this);
|
||||
// Block the event loop until everything is configured.
|
||||
if (start_event_loop)
|
||||
{
|
||||
pthread_mutex_lock(&event_loop_lock_);
|
||||
pthread_create(&thread_, NULL, startLoop, this);
|
||||
}
|
||||
wakeMeUpOnSigChld(thread_);
|
||||
start_time_ = time(NULL);
|
||||
exit_after_seconds_ = exit_after_seconds;
|
||||
|
@ -588,8 +594,8 @@ void SerialCommunicationManagerImp::stop()
|
|||
{
|
||||
if (signalsInstalled())
|
||||
{
|
||||
pthread_kill(main_thread_, SIGUSR2);
|
||||
pthread_kill(thread_, SIGUSR1);
|
||||
if (main_thread_) pthread_kill(main_thread_, SIGUSR2);
|
||||
if (thread_) pthread_kill(thread_, SIGUSR1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -598,19 +604,20 @@ void SerialCommunicationManagerImp::stop()
|
|||
void SerialCommunicationManagerImp::waitForStop()
|
||||
{
|
||||
debug("(serial) waiting for stop\n");
|
||||
// Release the event loop!
|
||||
pthread_mutex_unlock(&event_loop_lock_);
|
||||
|
||||
expect_devices_to_work_ = true;
|
||||
main_thread_ = pthread_self();
|
||||
while (running_) { usleep(1000*1000); }
|
||||
if (signalsInstalled())
|
||||
{
|
||||
pthread_kill(thread_, SIGUSR1);
|
||||
if (thread_) pthread_kill(thread_, SIGUSR1);
|
||||
}
|
||||
pthread_join(thread_, NULL);
|
||||
debug("(serial) closing devices %d\n", devices_.size());
|
||||
for (SerialDevice *d : devices_)
|
||||
{
|
||||
d->close();
|
||||
}
|
||||
|
||||
debug("(serial) closing %d devices\n", devices_.size());
|
||||
closeAll();
|
||||
}
|
||||
|
||||
bool SerialCommunicationManagerImp::isRunning()
|
||||
|
@ -630,7 +637,7 @@ void SerialCommunicationManagerImp::opened(SerialDeviceImp *sd)
|
|||
devices_.push_back(sd);
|
||||
if (signalsInstalled())
|
||||
{
|
||||
pthread_kill(thread_, SIGUSR1);
|
||||
if (thread_) pthread_kill(thread_, SIGUSR1);
|
||||
}
|
||||
pthread_mutex_unlock(&devices_lock_);
|
||||
}
|
||||
|
@ -726,8 +733,9 @@ void *SerialCommunicationManagerImp::eventLoop()
|
|||
break;
|
||||
}
|
||||
|
||||
debug("(serial) select\n");
|
||||
debug("(serial) select num_devies=%d running=%d expect_devices_to_work=%d\n", num_devices, running_, expect_devices_to_work_);
|
||||
int activity = select(max_fd_+1 , &readfds, NULL , NULL, &timeout);
|
||||
debug("(serial) out of select\n");
|
||||
if (!running_) break;
|
||||
if (activity < 0 && errno!=EINTR)
|
||||
{
|
||||
|
@ -788,10 +796,12 @@ void *SerialCommunicationManagerImp::eventLoop()
|
|||
}
|
||||
|
||||
unique_ptr<SerialCommunicationManager> createSerialCommunicationManager(time_t exit_after_seconds,
|
||||
time_t reopen_after_seconds)
|
||||
time_t reopen_after_seconds,
|
||||
bool start_event_loop)
|
||||
{
|
||||
return unique_ptr<SerialCommunicationManager>(new SerialCommunicationManagerImp(exit_after_seconds,
|
||||
reopen_after_seconds));
|
||||
reopen_after_seconds,
|
||||
start_event_loop));
|
||||
}
|
||||
|
||||
static int openSerialTTY(const char *tty, int baud_rate)
|
||||
|
|
|
@ -74,6 +74,7 @@ struct SerialCommunicationManager
|
|||
};
|
||||
|
||||
unique_ptr<SerialCommunicationManager> createSerialCommunicationManager(time_t exit_after_seconds = 0,
|
||||
time_t reopen_after_seconds = 0);
|
||||
time_t reopen_after_seconds = 0,
|
||||
bool start_event_loop = true);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -40,11 +40,11 @@ int main(int argc, char **argv)
|
|||
debugEnabled(true);
|
||||
}
|
||||
onExit([](){});
|
||||
/*
|
||||
|
||||
test_crc();
|
||||
test_dvparser();
|
||||
*/ test_linkmodes();
|
||||
// test_ids();
|
||||
test_linkmodes();
|
||||
test_ids();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -200,22 +200,21 @@ int test_dvparser()
|
|||
int test_linkmodes()
|
||||
{
|
||||
LinkModeCalculationResult lmcr;
|
||||
auto manager = createSerialCommunicationManager(0, 0);
|
||||
auto manager = createSerialCommunicationManager(0, 0, false);
|
||||
|
||||
auto serial1 = manager->createSerialDeviceSimulator();
|
||||
auto serial2 = manager->createSerialDeviceSimulator();
|
||||
auto serial3 = manager->createSerialDeviceSimulator();
|
||||
/*
|
||||
auto serial4 = manager->createSerialDeviceSimulator();*/
|
||||
/*
|
||||
vector<string> no_meter_shells, no_meter_jsons;*/
|
||||
/*
|
||||
auto serial4 = manager->createSerialDeviceSimulator();
|
||||
|
||||
vector<string> no_meter_shells, no_meter_jsons;
|
||||
|
||||
unique_ptr<WMBus> wmbus_im871a = openIM871A("", manager.get(), std::move(serial1));
|
||||
|
||||
unique_ptr<WMBus> wmbus_amb8465 = openAMB8465("", manager.get(), std::move(serial2));
|
||||
unique_ptr<WMBus> wmbus_rtlwmbus = openRTLWMBUS("", manager.get(), [](){}, std::move(serial3));
|
||||
unique_ptr<WMBus> wmbus_rawtty = openRawTTY("", 0, manager.get(), std::move(serial4));
|
||||
*/
|
||||
/*
|
||||
|
||||
Configuration nometers_config;
|
||||
// Check that if no meters are supplied then you must set a link mode.
|
||||
nometers_config.link_mode_configured = false;
|
||||
|
@ -327,7 +326,7 @@ int test_linkmodes()
|
|||
printf("ERROR! Expected dongle cannot listen to! Got instead:\n%s\n", lmcr.msg.c_str());
|
||||
}
|
||||
debug("test7 OK\n\n");
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -350,29 +350,40 @@ void WMBusAmber::processSerialData()
|
|||
int payload_len, payload_offset;
|
||||
uchar rssi;
|
||||
|
||||
FrameStatus status = checkAMB8465Frame(read_buffer_, &frame_length, &msgid, &payload_len, &payload_offset, &rssi);
|
||||
for (;;)
|
||||
{
|
||||
FrameStatus status = checkAMB8465Frame(read_buffer_, &frame_length, &msgid, &payload_len, &payload_offset, &rssi);
|
||||
|
||||
if (status == ErrorInFrame) {
|
||||
verbose("(amb8465) protocol error in message received!\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
debug("(amb8465) protocol error \"%s\"\n", msg.c_str());
|
||||
read_buffer_.clear();
|
||||
} else
|
||||
if (status == FullFrame) {
|
||||
|
||||
vector<uchar> payload;
|
||||
if (payload_len > 0) {
|
||||
uchar l = payload_len;
|
||||
payload.insert(payload.end(), &l, &l+1); // Re-insert the len byte.
|
||||
payload.insert(payload.end(), read_buffer_.begin()+payload_offset, read_buffer_.begin()+payload_offset+payload_len);
|
||||
if (status == PartialFrame)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
|
||||
if (rssi_expected_) {
|
||||
verbose("(amb8465) rssi %d\n", rssi);
|
||||
if (status == ErrorInFrame)
|
||||
{
|
||||
verbose("(amb8465) protocol error in message received!\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
debug("(amb8465) protocol error \"%s\"\n", msg.c_str());
|
||||
read_buffer_.clear();
|
||||
break;
|
||||
}
|
||||
if (status == FullFrame)
|
||||
{
|
||||
vector<uchar> payload;
|
||||
if (payload_len > 0)
|
||||
{
|
||||
uchar l = payload_len;
|
||||
payload.insert(payload.end(), &l, &l+1); // Re-insert the len byte.
|
||||
payload.insert(payload.end(), read_buffer_.begin()+payload_offset, read_buffer_.begin()+payload_offset+payload_len);
|
||||
}
|
||||
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
|
||||
if (rssi_expected_)
|
||||
{
|
||||
verbose("(amb8465) rssi %d\n", rssi);
|
||||
}
|
||||
handleMessage(msgid, payload);
|
||||
}
|
||||
handleMessage(msgid, payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ private:
|
|||
LinkModeSet link_modes_ {};
|
||||
|
||||
void waitForResponse();
|
||||
static FrameStatus checkFrame(vector<uchar> &data,
|
||||
size_t *frame_length, int *endpoint_out, int *msgid_out,
|
||||
int *payload_len_out, int *payload_offset);
|
||||
static FrameStatus checkIM871AFrame(vector<uchar> &data,
|
||||
size_t *frame_length, int *endpoint_out, int *msgid_out,
|
||||
int *payload_len_out, int *payload_offset);
|
||||
friend bool detectIM871A(string device, SerialCommunicationManager *manager);
|
||||
void handleDevMgmt(int msgid, vector<uchar> &payload);
|
||||
void handleRadioLink(int msgid, vector<uchar> &payload);
|
||||
|
@ -394,9 +394,9 @@ void WMBusIM871A::waitForResponse() {
|
|||
}
|
||||
}
|
||||
|
||||
FrameStatus WMBusIM871A::checkFrame(vector<uchar> &data,
|
||||
size_t *frame_length, int *endpoint_out, int *msgid_out,
|
||||
int *payload_len_out, int *payload_offset)
|
||||
FrameStatus WMBusIM871A::checkIM871AFrame(vector<uchar> &data,
|
||||
size_t *frame_length, int *endpoint_out, int *msgid_out,
|
||||
int *payload_len_out, int *payload_offset)
|
||||
{
|
||||
if (data.size() == 0) return PartialFrame;
|
||||
if (data[0] != 0xa5) return ErrorInFrame;
|
||||
|
@ -473,41 +473,48 @@ void WMBusIM871A::processSerialData()
|
|||
int msgid;
|
||||
int payload_len, payload_offset;
|
||||
|
||||
FrameStatus status = checkFrame(read_buffer_, &frame_length, &endpoint, &msgid, &payload_len, &payload_offset);
|
||||
for (;;)
|
||||
{
|
||||
FrameStatus status = checkIM871AFrame(read_buffer_, &frame_length, &endpoint, &msgid, &payload_len, &payload_offset);
|
||||
|
||||
if (status == ErrorInFrame) {
|
||||
verbose("(im871a) protocol error in message received!\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
debug("(im871a) protocol error \"%s\"\n", msg.c_str());
|
||||
read_buffer_.clear();
|
||||
}
|
||||
else
|
||||
if (status == FullFrame) {
|
||||
|
||||
vector<uchar> payload;
|
||||
if (payload_len > 0)
|
||||
if (status == PartialFrame)
|
||||
{
|
||||
if (endpoint == RADIOLINK_ID &&
|
||||
msgid == RADIOLINK_MSG_WMBUSMSG_IND)
|
||||
{
|
||||
uchar l = payload_len;
|
||||
payload.insert(payload.begin(), &l, &l+1); // Re-insert the len byte.
|
||||
}
|
||||
// Insert the payload.
|
||||
payload.insert(payload.end(),
|
||||
read_buffer_.begin()+payload_offset,
|
||||
read_buffer_.begin()+payload_offset+payload_len);
|
||||
break;
|
||||
}
|
||||
if (status == ErrorInFrame)
|
||||
{
|
||||
verbose("(im871a) protocol error in message received!\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
debug("(im871a) protocol error \"%s\"\n", msg.c_str());
|
||||
read_buffer_.clear();
|
||||
break;
|
||||
}
|
||||
if (status == FullFrame)
|
||||
{
|
||||
vector<uchar> payload;
|
||||
if (payload_len > 0)
|
||||
{
|
||||
if (endpoint == RADIOLINK_ID &&
|
||||
msgid == RADIOLINK_MSG_WMBUSMSG_IND)
|
||||
{
|
||||
uchar l = payload_len;
|
||||
payload.insert(payload.begin(), &l, &l+1); // Re-insert the len byte.
|
||||
}
|
||||
// Insert the payload.
|
||||
payload.insert(payload.end(),
|
||||
read_buffer_.begin()+payload_offset,
|
||||
read_buffer_.begin()+payload_offset+payload_len);
|
||||
}
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
|
||||
// We now have a proper message in payload. Let us trigger actions based on it.
|
||||
// It can be wmbus receiver-dongle messages or wmbus remote meter messages received over the radio.
|
||||
switch (endpoint) {
|
||||
case DEVMGMT_ID: handleDevMgmt(msgid, payload); break;
|
||||
case RADIOLINK_ID: handleRadioLink(msgid, payload); break;
|
||||
case RADIOLINKTEST_ID: handleRadioLinkTest(msgid, payload); break;
|
||||
case HWTEST_ID: handleHWTest(msgid, payload); break;
|
||||
// We now have a proper message in payload. Let us trigger actions based on it.
|
||||
// It can be wmbus receiver-dongle messages or wmbus remote meter messages received over the radio.
|
||||
switch (endpoint) {
|
||||
case DEVMGMT_ID: handleDevMgmt(msgid, payload); break;
|
||||
case RADIOLINK_ID: handleRadioLink(msgid, payload); break;
|
||||
case RADIOLINKTEST_ID: handleRadioLinkTest(msgid, payload); break;
|
||||
case HWTEST_ID: handleHWTest(msgid, payload); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -618,9 +625,9 @@ bool detectIM871A(string device, SerialCommunicationManager *manager)
|
|||
|
||||
size_t frame_length;
|
||||
int endpoint, msgid, payload_len, payload_offset;
|
||||
FrameStatus status = WMBusIM871A::checkFrame(data,
|
||||
&frame_length, &endpoint, &msgid,
|
||||
&payload_len, &payload_offset);
|
||||
FrameStatus status = WMBusIM871A::checkIM871AFrame(data,
|
||||
&frame_length, &endpoint, &msgid,
|
||||
&payload_len, &payload_offset);
|
||||
if (status != FullFrame ||
|
||||
endpoint != 1 ||
|
||||
msgid != 2)
|
||||
|
|
|
@ -184,11 +184,11 @@ void WMBusRawTTY::processSerialData()
|
|||
|
||||
read_buffer_.insert(read_buffer_.end(), data.begin(), data.end());
|
||||
|
||||
size_t frame_length;
|
||||
int payload_len, payload_offset;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t frame_length;
|
||||
int payload_len, payload_offset;
|
||||
|
||||
FrameStatus status = checkRawTTYFrame(read_buffer_, &frame_length, &payload_len, &payload_offset);
|
||||
|
||||
if (status == PartialFrame)
|
||||
|
@ -196,7 +196,7 @@ void WMBusRawTTY::processSerialData()
|
|||
// Partial frame, stop eating.
|
||||
break;
|
||||
}
|
||||
else if (status == ErrorInFrame)
|
||||
if (status == ErrorInFrame)
|
||||
{
|
||||
verbose("(rawtty) protocol error in message received!\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
|
@ -204,7 +204,7 @@ void WMBusRawTTY::processSerialData()
|
|||
read_buffer_.clear();
|
||||
break;
|
||||
}
|
||||
else if (status == FullFrame)
|
||||
if (status == FullFrame)
|
||||
{
|
||||
vector<uchar> payload;
|
||||
if (payload_len > 0)
|
||||
|
@ -216,10 +216,6 @@ void WMBusRawTTY::processSerialData()
|
|||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
handleMessage(payload);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,38 +138,54 @@ void WMBusRTLWMBUS::processSerialData()
|
|||
size_t frame_length;
|
||||
int hex_payload_len, hex_payload_offset;
|
||||
|
||||
FrameStatus status = checkRTLWMBUSFrame(read_buffer_, &frame_length, &hex_payload_len, &hex_payload_offset);
|
||||
for (;;)
|
||||
{
|
||||
FrameStatus status = checkRTLWMBUSFrame(read_buffer_, &frame_length, &hex_payload_len, &hex_payload_offset);
|
||||
|
||||
if (status == TextAndNotFrame) {
|
||||
// The buffer has already been printed by serial cmd.
|
||||
read_buffer_.clear();
|
||||
} else
|
||||
if (status == ErrorInFrame) {
|
||||
debug("(rtlwmbus) error in received message.\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
read_buffer_.clear();
|
||||
} else
|
||||
if (status == FullFrame) {
|
||||
vector<uchar> payload;
|
||||
if (hex_payload_len > 0) {
|
||||
vector<uchar> hex;
|
||||
hex.insert(hex.end(), read_buffer_.begin()+hex_payload_offset, read_buffer_.begin()+hex_payload_offset+hex_payload_len);
|
||||
bool ok = hex2bin(hex, &payload);
|
||||
if (!ok) {
|
||||
if (hex.size() % 2 == 1) {
|
||||
payload.clear();
|
||||
warning("(rtlwmbus) warning: the hex string is not an even multiple of two! Dropping last char.\n");
|
||||
hex.pop_back();
|
||||
ok = hex2bin(hex, &payload);
|
||||
}
|
||||
if (!ok) {
|
||||
warning("(rtlwmbus) warning: the hex string contains bad characters! Decode stopped partway.\n");
|
||||
if (status == PartialFrame)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (status == TextAndNotFrame)
|
||||
{
|
||||
// The buffer has already been printed by serial cmd.
|
||||
read_buffer_.clear();
|
||||
break;
|
||||
}
|
||||
if (status == ErrorInFrame)
|
||||
{
|
||||
debug("(rtlwmbus) error in received message.\n");
|
||||
string msg = bin2hex(read_buffer_);
|
||||
read_buffer_.clear();
|
||||
break;
|
||||
}
|
||||
if (status == FullFrame)
|
||||
{
|
||||
vector<uchar> payload;
|
||||
if (hex_payload_len > 0)
|
||||
{
|
||||
vector<uchar> hex;
|
||||
hex.insert(hex.end(), read_buffer_.begin()+hex_payload_offset, read_buffer_.begin()+hex_payload_offset+hex_payload_len);
|
||||
bool ok = hex2bin(hex, &payload);
|
||||
if (!ok)
|
||||
{
|
||||
if (hex.size() % 2 == 1)
|
||||
{
|
||||
payload.clear();
|
||||
warning("(rtlwmbus) warning: the hex string is not an even multiple of two! Dropping last char.\n");
|
||||
hex.pop_back();
|
||||
ok = hex2bin(hex, &payload);
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
warning("(rtlwmbus) warning: the hex string contains bad characters! Decode stopped partway.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
handleMessage(payload);
|
||||
read_buffer_.erase(read_buffer_.begin(), read_buffer_.begin()+frame_length);
|
||||
handleMessage(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
42
test.sh
42
test.sh
|
@ -5,25 +5,65 @@ TESTINTERNAL=$(dirname $PROG)/testinternals
|
|||
|
||||
$TESTINTERNAL
|
||||
if [ "$?" = "0" ]; then
|
||||
echo Internal test OK
|
||||
echo OK: test internals
|
||||
fi
|
||||
RC="0"
|
||||
|
||||
tests/test_c1_meters.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_t1_meters.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_shell.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_shell2.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_meterfiles.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_config1.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_logfile.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_elements.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_listen_to_all.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_multiple_ids.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_conversions.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
#tests/test_oneshot.sh $PROG broken test
|
||||
#if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_wrongkeys.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_config4.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_linkmodes.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_additional_json.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_rtlwmbus.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_stdin_and_file.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
tests/test_serial_bads.sh $PROG
|
||||
if [ "$?" != "0" ]; then RC="1"; fi
|
||||
|
||||
exit $RC
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
loglevel=normal
|
||||
device=simulations/simulation_t1.txt
|
||||
logtelegrams=false
|
||||
logtelegrams=true
|
||||
format=json
|
||||
meterfiles=testoutput/meter_readings2
|
||||
logfile=testoutput/thelog2.txt
|
||||
|
|
|
@ -4,6 +4,9 @@ PROG="$1"
|
|||
TEST=testoutput
|
||||
mkdir -p $TEST
|
||||
|
||||
TESTNAME="Test additional json from cmdline"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_additional_json.txt | grep '^{' > $TEST/test_expected.txt
|
||||
$PROG --format=json --json_floor=5 --json_address="RoodRd 42" simulations/simulation_additional_json.txt \
|
||||
MyTapWater multical21 76348799 "" \
|
||||
|
@ -15,16 +18,16 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Additional json from cmdline OK
|
||||
else
|
||||
echo Failure!
|
||||
exit 1
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
|
||||
TESTNAME="Test additional shell envs from cmdline"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
$PROG --format=json --json_floor=5 --json_house="alfa beta" --shellenvs --listento=c1 simulations/simulation_additional_json.txt \
|
||||
Vatten multical21 76348799 "" | grep METER_ > $TEST/test_output.txt
|
||||
|
@ -53,12 +56,15 @@ EOF
|
|||
diff $TEST/test_expected.txt $TEST/test_output.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Additional json in shell envs OK
|
||||
else
|
||||
echo Failure!
|
||||
exit 1
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test additional json from wmbusmeters.conf and from meter file"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
$PROG --useconfig=tests/config6 > $TEST/test_output.txt
|
||||
|
||||
if [ "$?" == "0" ]
|
||||
|
@ -67,13 +73,9 @@ then
|
|||
EXPECTED=$(echo 'METER =={"media":"warm water","meter":"supercom587","name":"Water","id":"12345678","total_m3":5.548,"timestamp":"1111-11-11T11:11:11Z","floor":"5","address":"RoodRd 42"}== ==RoodRd 42== ==5==')
|
||||
if [ "$INFO" = "$EXPECTED" ]
|
||||
then
|
||||
echo Additional json from config OK
|
||||
else
|
||||
echo $INFO
|
||||
echo $EXPECTED
|
||||
exit 1
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -6,6 +6,9 @@ mkdir -p testoutput
|
|||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test C1 meters"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_c1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
$PROG --format=json simulations/simulation_c1.txt \
|
||||
MyHeater multical302 12345678 "" \
|
||||
|
@ -21,9 +24,13 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo C1 OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -4,6 +4,9 @@ PROG="$1"
|
|||
TEST=testoutput
|
||||
mkdir -p $TEST
|
||||
|
||||
TESTNAME="Test normal config files with C1 meters"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_c1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
|
||||
$PROG --useconfig=tests/config1 > $TEST/test_output.txt
|
||||
|
@ -14,9 +17,9 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Config1 OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -4,6 +4,9 @@ PROG="$1"
|
|||
TEST=testoutput
|
||||
mkdir -p $TEST
|
||||
|
||||
TESTNAME="Test config4 with added conversions"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_conversionsadded.txt | grep '^{' > $TEST/test_expected.txt
|
||||
|
||||
$PROG --useconfig=tests/config4 > $TEST/test_output.txt
|
||||
|
@ -14,9 +17,9 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Config4 with addconversions OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -4,9 +4,11 @@ PROG="$1"
|
|||
|
||||
rm -rf testoutput
|
||||
mkdir -p testoutput
|
||||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test conversions of units"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_conversionsadded.txt | grep '^{' | grep 58234965 > $TEST/test_expected.txt
|
||||
$PROG --addconversions=GJ,L --format=json simulations/simulation_conversionsadded.txt \
|
||||
Hettan vario451 58234965 "" > $TEST/test_output.txt
|
||||
|
@ -17,11 +19,9 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Conversions OK
|
||||
else
|
||||
echo Failure. Conversions failed.
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Conversions failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -4,6 +4,9 @@ PROG="$1"
|
|||
TEST=testoutput
|
||||
mkdir -p $TEST/meter_readings3
|
||||
|
||||
TESTNAME="Test single meter conf file matches any id"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
rm -f $TEST/meter_readings3/*
|
||||
cat simulations/simulation_multiple_qcalorics.txt | grep '^{' > $TEST/test_expected.txt
|
||||
|
||||
|
@ -21,9 +24,13 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Elements OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -7,6 +7,9 @@ mkdir -p testoutput
|
|||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test that listen to t1+c1 works with meters transmitting using t1+c1"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_t1_and_c1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
$PROG --format=json --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
||||
MyTapWater multical21:c1 76348799 "" \
|
||||
|
@ -18,33 +21,45 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Linkmodes t1 and c1 OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
MSG=$($PROG --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
||||
MyTapWater multical21:c1 76348799 "" \
|
||||
Wasser apator162:s1 20202020 "")
|
||||
|
||||
if [ "$MSG" != "(cmdline) cannot set link modes to: s1 because meter apator162 only transmits on: c1,t1" ]
|
||||
then
|
||||
echo Failure. Did not expect: $MSG
|
||||
echo ERROR: $TESTNAME
|
||||
echo Did not expect: $MSG
|
||||
exit 1
|
||||
else
|
||||
echo "OK: $TESTNAME"
|
||||
fi
|
||||
|
||||
TESTNAME="Test that setting multical21 to t1 fails"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
MSG=$($PROG --listento=c1,t1 simulations/simulation_t1_and_c1.txt \
|
||||
MyTapWater multical21:t1 76348799 "" \
|
||||
Wasser apator162:c1 20202020 "")
|
||||
|
||||
if [ "$MSG" != "(cmdline) cannot set link modes to: t1 because meter multical21 only transmits on: c1" ]
|
||||
then
|
||||
echo Failure. Did not expect: $MSG
|
||||
echo ERROR: $TESTNAME
|
||||
echo Did not expect: $MSG
|
||||
exit 1
|
||||
else
|
||||
echo "OK: $TESTNAME"
|
||||
fi
|
||||
|
||||
TESTNAME="Test that the warning for missed telegrams work"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
MSG=$($PROG --s1 simulations/simulation_t1_and_c1.txt \
|
||||
MyTapWater multical21:c1 76348799 "" \
|
||||
Wasser apator162:t1 20202020 "" | tr -d ' \n')
|
||||
|
@ -52,7 +67,10 @@ MSG=$($PROG --s1 simulations/simulation_t1_and_c1.txt \
|
|||
CORRECT="(config)Youhavespecifiedtolistentothelinkmodes:s1butthemetersmighttransmiton:c1,t1(config)Thereforeyoumightmisstelegrams!Pleasespecifytheexpectedtransmitmodeforthemeters,eg:apator162:t1(config)Oruseadonglethatcanlistentoalltherequiredlinkmodesatthesametime."
|
||||
if [ "$MSG" != "$CORRECT" ]
|
||||
then
|
||||
echo Failure. Did not expect:
|
||||
echo ERROR: $TESTNAME
|
||||
echo Did not expect:
|
||||
echo $MSG
|
||||
exit 1
|
||||
else
|
||||
echo "OK: $TESTNAME"
|
||||
fi
|
||||
|
|
|
@ -12,6 +12,9 @@ TEST=testoutput
|
|||
LOGFILE=$TEST/logfile
|
||||
LOGFILE_EXPECTED=$TEST/logfile.expected
|
||||
|
||||
TESTNAME="Test listen and print any meter heard in logfile"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
mkdir -p $TEST
|
||||
rm -f $LOGFILE
|
||||
|
||||
|
@ -65,17 +68,19 @@ RES=$($PROG --logfile=$LOGFILE --t1 simulations/simulation_t1.txt 2>&1)
|
|||
|
||||
if [ ! "$RES" = "" ]
|
||||
then
|
||||
ERRORS=true
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected no output on stdout and stderr
|
||||
echo but got------------------
|
||||
echo $RES
|
||||
echo ---------------------
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GOT=$(cat $LOGFILE)
|
||||
|
||||
if [ ! "$GOT" = "$EXPECTED" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
echo GOT--------------
|
||||
echo $GOT
|
||||
echo EXPECTED---------
|
||||
|
@ -83,14 +88,18 @@ then
|
|||
echo -----------------
|
||||
exit 1
|
||||
else
|
||||
echo OK: listen to all with logfile
|
||||
echo OK: $TESTNAME
|
||||
fi
|
||||
|
||||
|
||||
TESTNAME="Test listen and print any meter heard on stdout"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
GOT=$($PROG --t1 simulations/simulation_t1.txt 2>&1)
|
||||
|
||||
if [ ! "$GOT" = "$EXPECTED" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
echo GOT--------------
|
||||
echo $GOT
|
||||
echo EXPECTED---------
|
||||
|
@ -98,5 +107,5 @@ then
|
|||
echo -----------------
|
||||
exit 1
|
||||
else
|
||||
echo OK: listen to all with stdout
|
||||
echo OK: $TESTNAME
|
||||
fi
|
||||
|
|
|
@ -6,17 +6,19 @@ rm -f $TEST/thelog2.txt
|
|||
rm -rf $TEST/meter_readings2
|
||||
mkdir -p $TEST/meter_readings2
|
||||
|
||||
ERRORS=false
|
||||
TESTNAME="Test logfile"
|
||||
TESTRESULT="ERRORS"
|
||||
|
||||
RES=$($PROG --useconfig=tests/config2 2>&1)
|
||||
|
||||
if [ ! "$RES" = "" ]
|
||||
then
|
||||
ERRORS=true
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected no output on stdout and stderr
|
||||
echo but got------------------
|
||||
echo $RES
|
||||
echo ---------------------
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' | grep 12345699 | tail -n 1 > $TEST/test_expected.txt
|
||||
|
@ -24,7 +26,9 @@ cat $TEST/meter_readings2/MoreWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ ! "$?" = "0" ]
|
||||
then
|
||||
ERRORS=true
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected to find meter MoreWater in readings, but did not.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' | grep 12345678 | tail -n 1 > $TEST/test_expected.txt
|
||||
|
@ -32,7 +36,9 @@ cat $TEST/meter_readings2/MyWarmWater | sed 's/"timestamp":"....-..-..T..:..:..Z
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ ! "$?" = "0" ]
|
||||
then
|
||||
ERRORS=true
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected to find meter MyWarmWater in readings, but did not.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' | grep 11111111 | tail -n 1 > $TEST/test_expected.txt
|
||||
|
@ -40,20 +46,23 @@ cat $TEST/meter_readings2/MyColdWater | sed 's/"timestamp":"....-..-..T..:..:..Z
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ ! "$?" = "0" ]
|
||||
then
|
||||
ERRORS=true
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected to find meter MyColdWater in readings, but did not.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RES=$(cat $TEST/thelog2.txt)
|
||||
RES=$(cat $TEST/thelog2.txt | tr '\n' ' ' | tr -d ' ')
|
||||
|
||||
if [ ! "$RES" = "" ]
|
||||
EXP=$(echo -n '(supercom587) log "telegram=|A244EE4D785634123C067A8F000000|0C1348550000426CE1F14C130000000082046C21298C0413330000008D04931E3A3CFE3300000033000000330000003300000033000000330000003300000033000000330000003300000033000000330000004300000034180000046D0D0B5C2B03FD6C5E150082206C5C290BFD0F0200018C4079678885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0" (supercom587) log "telegram=|A244EE4D111111113C077AAC000000|0C1389490000426CE1F14C130000000082046C21298C0413010000008D04931E3A3CFE0100000001000000010000000100000001000000010000000100000001000000010000000100000001000000010000001600000031130000046D0A0C5C2B03FD6C60150082206C5C290BFD0F0200018C4079629885238310FD3100000082106C01018110FD610002FD66020002FD170000|+0" (iperl) log "telegram=|1E44AE4C9956341268077A36001000|2F2F0413181E0000023B00002F2F2F2F|+0" (iperl) log "telegram=|1844AE4C4455223368077A55000000|041389E20100023B0000|+0"' | tr '\n' ' ' | tr -d ' ')
|
||||
|
||||
if [ "$RES" != "$EXP" ]
|
||||
then
|
||||
ERRORS=true
|
||||
cat $TEST/thelog2.txt
|
||||
echo ERROR: $TESTNAME
|
||||
echo Expected:
|
||||
echo $EXP
|
||||
echo But got:
|
||||
echo $RES
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$ERRORS" = "true" ]
|
||||
then
|
||||
echo Failed config2 tests
|
||||
else
|
||||
echo Config2 with logfile and meterfiles OK
|
||||
fi
|
||||
echo OK: $TESTNAME
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
PROG="$1"
|
||||
|
||||
mkdir -p testoutput
|
||||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test that normal meterfiles are written"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
rm -f /tmp/MyTapWater
|
||||
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
|
||||
$PROG --meterfiles --format=json simulations/simulation_c1.txt MyTapWater multical21 76348799 "" > /dev/null
|
||||
|
@ -13,10 +15,16 @@ cat /tmp/MyTapWater | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp":"111
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Meterfiles OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
rm /tmp/MyTapWater
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test that meterfiles with name-id are written"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
rm -rf /tmp/testmeters
|
||||
mkdir /tmp/testmeters
|
||||
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
|
||||
|
@ -25,10 +33,16 @@ cat /tmp/testmeters/MyTapWater-76348799 | sed 's/"timestamp":"....-..-..T..:..:.
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Meterfiles dir OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
rm -rf /tmp/testmeters
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test that meterfiles with id are written"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
rm -rf /tmp/testmeters
|
||||
mkdir /tmp/testmeters
|
||||
cat simulations/simulation_c1.txt | grep '^{' | grep 76348799 | tail -n 1 > $TEST/test_expected.txt
|
||||
|
@ -37,6 +51,9 @@ cat /tmp/testmeters/76348799 | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timest
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Meterfiles naming OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
rm -rf /tmp/testmeters
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
PROG="$1"
|
||||
|
||||
mkdir -p testoutput
|
||||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test listen to wildcard * id"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
SIM=simulations/simulation_multiple_qcalorics.txt
|
||||
|
||||
cat $SIM | grep '^{' > $TEST/test_expected.txt
|
||||
|
@ -18,13 +21,16 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Wildcard \'\*\' id OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Wildcard \'\*\' id bad
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test listen to wildcard suffix 8856* id"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat $SIM | grep '^{' | grep 8856 > $TEST/test_expected.txt
|
||||
|
||||
$PROG --format=json $SIM \
|
||||
|
@ -38,13 +44,16 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Wildcard \'8856\*\' id OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Wildcard \'8856\*\' id bad
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test listen to two comma separted ids"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat $SIM | grep '^{' | grep -v 88563414 > $TEST/test_expected.txt
|
||||
|
||||
$PROG --format=json $SIM \
|
||||
|
@ -57,13 +66,16 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Multiple ids2 OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Multiple ids2 bad
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test listen to three comma separted ids"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat $SIM | grep '^{' > $TEST/test_expected.txt
|
||||
|
||||
$PROG --format=json $SIM \
|
||||
|
@ -76,13 +88,15 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Multiple ids3 OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Multiple ids3 bad
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
TESTNAME="Test listen with negated ids"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat $SIM | grep '^{' | grep -v 88563414 | grep -v 78563413 > $TEST/test_expected.txt
|
||||
|
||||
|
@ -96,9 +110,9 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Negated ids OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure. Negated ids bad
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -7,6 +7,9 @@ TEST=testoutput
|
|||
rm -rf $TEST
|
||||
mkdir -p $TEST
|
||||
|
||||
TESTNAME="Test rtlwmbus starting background script to produce telegrams"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat tests/rtlwmbus_water.sh | grep '^#{' | tr -d '#' > $TEST/test_expected.txt
|
||||
$PROG --format=json "rtlwmbus:tests/rtlwmbus_water.sh" \
|
||||
ApWater apator162 88888888 00000000000000000000000000000000 \
|
||||
|
@ -17,8 +20,8 @@ cat $TEST/test_output.txt | sed 's/"timestamp":"....-..-..T..:..:..Z"/"timestamp
|
|||
diff $TEST/test_expected.txt $TEST/test_response.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo RTLWMBUS OK
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -6,6 +6,15 @@ mkdir -p testoutput
|
|||
|
||||
TEST=testoutput
|
||||
|
||||
####################################################
|
||||
TESTNAME="Test ok serial rawtty telegram on stdin"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
xxd -r -p simulations/serial_rawtty_ok.hex | \
|
||||
$PROG --format=json --listento=any stdin \
|
||||
Rummet1 lansenth 00010203 "" \
|
||||
|
@ -13,23 +22,27 @@ xxd -r -p simulations/serial_rawtty_ok.hex | \
|
|||
| grep Rummet > $TEST/test_output.txt
|
||||
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
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
|
||||
echo Serial simulation OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
####################################################
|
||||
TESTNAME="Test bad serial rawtty telegram with interspersed noise, on stdin"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
xxd -r -p simulations/serial_rawtty_bad.hex | \
|
||||
$PROG --format=json --listento=any stdin \
|
||||
Rummet1 lansenth 00010203 "" \
|
||||
|
@ -37,18 +50,15 @@ xxd -r -p simulations/serial_rawtty_bad.hex | \
|
|||
| grep Rummet > $TEST/test_output.txt
|
||||
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
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
|
||||
echo Serial simulation with bad prefixes OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
PROG="$1"
|
||||
|
||||
mkdir -p testoutput
|
||||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test shell invocation"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
$PROG --shell='echo "$METER_JSON"' simulations/simulation_shell.txt MWW supercom587 12345678 "" > $TEST/test_output.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
|
@ -14,9 +16,13 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo SHELL OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -4,6 +4,9 @@ PROG="$1"
|
|||
TEST=testoutput
|
||||
mkdir -p $TEST
|
||||
|
||||
TESTNAME="Test shell in config file"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
$PROG --useconfig=tests/config5 > $TEST/test_output.txt
|
||||
|
||||
if [ "$?" == "0" ]
|
||||
|
@ -12,12 +15,13 @@ then
|
|||
EXPECTED=$(echo 'TESTING SHELL {"media":"warm water","meter":"supercom587","name":"Vatten","id":"12345678","total_m3":5.548,"timestamp":"1111-11-11T11:11:11Z"}')
|
||||
if [ "$INFO" = "$EXPECTED" ]
|
||||
then
|
||||
echo meter shell OK
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -7,6 +7,13 @@ mkdir -p testoutput
|
|||
TEST=testoutput
|
||||
|
||||
########################################################
|
||||
TESTNAME="Reading binary telegram from stdin"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
xxd -r -p simulations/serial_rawtty_ok.hex | \
|
||||
$PROG --format=json --listento=any stdin \
|
||||
|
@ -15,47 +22,99 @@ xxd -r -p simulations/serial_rawtty_ok.hex | \
|
|||
| grep Rummet > $TEST/test_output.txt
|
||||
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
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
|
||||
echo Reading binary telegram from stdin OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
########################################################
|
||||
TESTNAME="Reading binary telegram from file"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
xxd -r -p simulations/serial_rawtty_ok.hex > $TEST/test_raw
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
$PROG --format=json --listento=any $TEST/test_raw \
|
||||
Rummet1 lansenth 00010203 "" \
|
||||
Rummet2 rfmamb 11772288 "" \
|
||||
| grep Rummet > $TEST/test_output.txt
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
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
|
||||
echo Reading binary telegram from file OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
########################################################
|
||||
TESTNAME="Reading rtlwmbus formatted telegrams from stdin"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
cat simulations/serial_rtlwmbus_ok.msg | \
|
||||
$PROG --format=json --listento=any stdin:rtlwmbus \
|
||||
Rummet1 lansenth 00010203 "" \
|
||||
Rummet2 rfmamb 11772288 "" \
|
||||
| grep Rummet > $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
|
||||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
||||
########################################################
|
||||
TESTNAME="Reading rtlwmbus formatted telegrams from file"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat > $TEST/test_expected.txt <<EOF
|
||||
{"media":"room sensor","meter":"lansenth","name":"Rummet1","id":"00010203","current_temperature_c":21.8,"current_relative_humidity_rh":43,"average_temperature_1h_c":21.79,"average_relative_humidity_1h_rh":43,"average_temperature_24h_c":21.97,"average_relative_humidity_24h_rh":42.5,"timestamp":"1111-11-11T11:11:11Z"}
|
||||
{"media":"room sensor","meter":"rfmamb","name":"Rummet2","id":"11772288","current_temperature_c":22.08,"average_temperature_1h_c":21.91,"average_temperature_24h_c":22.07,"maximum_temperature_1h_c":22.08,"minimum_temperature_1h_c":21.85,"maximum_temperature_24h_c":23.47,"minimum_temperature_24h_c":21.29,"current_relative_humidity_rh":44.2,"average_relative_humidity_1h_rh":43.2,"average_relative_humidity_24h_rh":44.5,"minimum_relative_humidity_1h_rh":42.2,"maximum_relative_humidity_1h_rh":50.1,"maximum_relative_humidity_24h_rh":0,"minimum_relative_humidity_24h_rh":0,"device_date_time":"2019-10-11 19:59","timestamp":"1111-11-11T11:11:11Z"}
|
||||
EOF
|
||||
|
||||
$PROG --format=json --listento=any simulations/serial_rtlwmbus_ok.msg:rtlwmbus \
|
||||
Rummet1 lansenth 00010203 "" \
|
||||
Rummet2 rfmamb 11772288 "" \
|
||||
| grep Rummet > $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
|
||||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
PROG="$1"
|
||||
|
||||
mkdir -p testoutput
|
||||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test T1 meters"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
$PROG --format=json simulations/simulation_t1.txt \
|
||||
MyWarmWater supercom587 12345678 "" \
|
||||
|
@ -28,9 +30,13 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_responses.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo T1 OK
|
||||
echo OK: $TESTNAME
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]
|
||||
then
|
||||
echo ERROR: $TESTNAME
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -6,6 +6,9 @@ mkdir -p testoutput
|
|||
|
||||
TEST=testoutput
|
||||
|
||||
TESTNAME="Test incorrect decryption keys"
|
||||
TESTRESULT="ERROR"
|
||||
|
||||
cat simulations/simulation_t1.txt | grep '^{' > $TEST/test_expected.txt
|
||||
$PROG --format=json simulations/simulation_t1.txt \
|
||||
MyWarmWater supercom587 12345678 11111111111111111111111111111111 \
|
||||
|
@ -30,9 +33,9 @@ then
|
|||
diff $TEST/test_expected.txt $TEST/test_output.txt
|
||||
if [ "$?" == "0" ]
|
||||
then
|
||||
echo Random keys OK
|
||||
echo "OK: $TESTNAME"
|
||||
TESTRESULT="OK"
|
||||
fi
|
||||
else
|
||||
echo Failure.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$TESTRESULT" = "ERROR" ]; then echo ERROR: $TESTNAME; exit 1; fi
|
||||
|
|
Ładowanie…
Reference in New Issue