Skip to content

Commit 8b7b2b5

Browse files
rlubosdkalowsk
authored andcommitted
tests: net: mqtt: client: Add test case for connect with iface binding
Add test case for verifying that MQTT client works fine if bound to an interface. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent 35af68b commit 8b7b2b5

File tree

1 file changed

+17
-0
lines changed
  • tests/net/lib/mqtt/v3_1_1/mqtt_client/src

1 file changed

+17
-0
lines changed

tests/net/lib/mqtt/v3_1_1/mqtt_client/src/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,23 @@ ZTEST(mqtt_client, test_mqtt_connect)
710710
zassert_false(test_ctx.connected, "MQTT client should be disconnected");
711711
}
712712

713+
ZTEST(mqtt_client, test_mqtt_connect_with_binding)
714+
{
715+
char name_buf[IFNAMSIZ] = { 0 };
716+
int ret = net_if_get_name(net_if_get_first_by_type(&NET_L2_GET_NAME(DUMMY)),
717+
name_buf, sizeof(name_buf));
718+
719+
720+
zassert_true(ret > 0, "Failed to get loopback interface name");
721+
722+
client_ctx.transport.if_name = name_buf;
723+
724+
test_connect();
725+
zassert_true(test_ctx.connected, "MQTT client should be connected");
726+
test_disconnect();
727+
zassert_false(test_ctx.connected, "MQTT client should be disconnected");
728+
}
729+
713730
ZTEST(mqtt_client, test_mqtt_ping)
714731
{
715732
test_connect();

0 commit comments

Comments
 (0)