Skip to content

Commit eda0bef

Browse files
Xiao Songcarlescufi
authored andcommitted
tests: net: hostname: move to new ztest API
Move tests/net/hostname/ to use new ztest API. Signed-off-by: Xiao Song <[email protected]>
1 parent 89421bf commit eda0bef

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

tests/net/hostname/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=6
2020
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=2
2121
CONFIG_NET_IPV6_ND=n
2222
CONFIG_ZTEST=y
23+
CONFIG_ZTEST_NEW_API=y
2324
CONFIG_NET_IF_MAX_IPV4_COUNT=4
2425
CONFIG_NET_IF_MAX_IPV6_COUNT=4
2526
CONFIG_NET_HOSTNAME_ENABLE=y

tests/net/hostname/src/main.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void iface_cb(struct net_if *iface, void *user_data)
216216
}
217217
}
218218

219-
static void test_iface_setup(void)
219+
static void *test_iface_setup(void)
220220
{
221221
struct net_if_mcast_addr *maddr;
222222
struct net_if_addr *ifaddr;
@@ -277,6 +277,8 @@ static void test_iface_setup(void)
277277
net_if_up(iface1);
278278

279279
test_started = true;
280+
281+
return NULL;
280282
}
281283

282284
static int bytes_from_hostname_unique(uint8_t *buf, int buf_len, const char *src)
@@ -313,7 +315,7 @@ static int bytes_from_hostname_unique(uint8_t *buf, int buf_len, const char *src
313315
return 0;
314316
}
315317

316-
static void test_hostname_get(void)
318+
ZTEST(net_hostname, test_hostname_get)
317319
{
318320
const char *hostname;
319321
const char *config_hostname = CONFIG_NET_HOSTNAME;
@@ -336,7 +338,7 @@ static void test_hostname_get(void)
336338
}
337339
}
338340

339-
static void test_hostname_set(void)
341+
ZTEST(net_hostname, test_hostname_set)
340342
{
341343
if (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE)) {
342344
int ret;
@@ -347,13 +349,4 @@ static void test_hostname_set(void)
347349
}
348350
}
349351

350-
void test_main(void)
351-
{
352-
ztest_test_suite(net_hostname_test,
353-
ztest_unit_test(test_iface_setup),
354-
ztest_unit_test(test_hostname_get),
355-
ztest_unit_test(test_hostname_set)
356-
);
357-
358-
ztest_run_test_suite(net_hostname_test);
359-
}
352+
ZTEST_SUITE(net_hostname, NULL, test_iface_setup, NULL, NULL, NULL);

0 commit comments

Comments
 (0)