Fix unit tests

This commit is contained in:
hsaturn
2023-01-14 14:26:30 +01:00
parent a0435b2cfb
commit 3b2460572b
3 changed files with 13 additions and 10 deletions

View File

@@ -1,27 +1,28 @@
tests: tests:
set -e; \ @set -e; \
for i in *-tests/Makefile; do \ for i in *-tests/Makefile; do \
$(MAKE) -C $$(dirname $$i) -j clean; \
echo '==== Making:' $$(dirname $$i); \ echo '==== Making:' $$(dirname $$i); \
$(MAKE) -C $$(dirname $$i) -j; \ $(MAKE) -C $$(dirname $$i) -j; \
done done
debugtest: debugtest:
set -e; \ @set -e; \
$(MAKE) clean; \ $(MAKE) clean; \
$(MAKE) -C debug-mode -j; \ $(MAKE) -C debug-mode -j; \
debug-mode/debug-tests.out debug-mode/debug-tests.out
runtests: debugtest runtests: debugtest
$(MAKE) clean @$(MAKE) clean
$(MAKE) tests @$(MAKE) tests
set -e; \ @set -e; \
for i in *-tests/Makefile; do \ for i in *-tests/Makefile; do \
echo '==== Running:' $$(dirname $$i); \ echo '==== Running:' $$(dirname $$i); \
$$(dirname $$i)/$$(dirname $$i).out; \ $$(dirname $$i)/$$(dirname $$i).out; \
done done
clean: clean:
set -e; \ @set -e; \
for i in *-tests/Makefile; do \ for i in *-tests/Makefile; do \
echo '==== Cleaning:' $$(dirname $$i); \ echo '==== Cleaning:' $$(dirname $$i); \
$(MAKE) -C $$(dirname $$i) clean; \ $(MAKE) -C $$(dirname $$i) clean; \

View File

@@ -19,7 +19,8 @@ class TestReceiver : public MqttClassBinder<TestReceiver>
void onPublish(const MqttClient* /* source */, const Topic& topic, const char* payload, size_t /* length */) void onPublish(const MqttClient* /* source */, const Topic& topic, const char* payload, size_t /* length */)
{ {
Serial << "--> routed message received by " << name_ << ':' << topic.c_str() << " = " << payload << endl; (void) topic;
// Serial << "--> routed message received by " << name_ << ':' << topic.c_str() << " = " << payload << endl;
messages[name_]++; messages[name_]++;
} }
@@ -35,7 +36,8 @@ std::map<std::string, int> TestReceiver::messages;
static int unrouted = 0; static int unrouted = 0;
void onUnrouted(const MqttClient*, const Topic& topic, const char*, size_t) void onUnrouted(const MqttClient*, const Topic& topic, const char*, size_t)
{ {
Serial << "--> unrouted: " << topic.c_str() << endl; (void) topic;
// Serial << "--> unrouted: " << topic.c_str() << endl;
unrouted++; unrouted++;
} }

View File

@@ -42,7 +42,7 @@ test(local_client_should_unregister_when_destroyed)
test(local_client_do_not_disconnect_after_publishing) test(local_client_do_not_disconnect_after_publishing)
{ {
set_millis(0); EpoxyTest::set_millis(0);
MqttBroker broker(1883); MqttBroker broker(1883);
MqttClient client(&broker, "client"); MqttClient client(&broker, "client");
MqttClient sender(&broker, "sender"); MqttClient sender(&broker, "sender");
@@ -56,7 +56,7 @@ test(local_client_do_not_disconnect_after_publishing)
sender.publish("test", "value"); sender.publish("test", "value");
broker.loop(); broker.loop();
add_seconds(60); EpoxyTest::add_seconds(60);
client.loop(); client.loop();
sender.loop(); sender.loop();
broker.loop(); broker.loop();