tests: net: hostname: move to new ztest API

Move tests/net/hostname/ to use new ztest API.

Signed-off-by: Xiao Song <songx.xiao@intel.com>
This commit is contained in:
Xiao Song 2022-07-11 15:34:40 +08:00 committed by Carles Cufí
commit eda0bef213
2 changed files with 7 additions and 13 deletions

View file

@ -20,6 +20,7 @@ CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=6
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=2
CONFIG_NET_IPV6_ND=n
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_NET_IF_MAX_IPV4_COUNT=4
CONFIG_NET_IF_MAX_IPV6_COUNT=4
CONFIG_NET_HOSTNAME_ENABLE=y

View file

@ -216,7 +216,7 @@ static void iface_cb(struct net_if *iface, void *user_data)
}
}
static void test_iface_setup(void)
static void *test_iface_setup(void)
{
struct net_if_mcast_addr *maddr;
struct net_if_addr *ifaddr;
@ -277,6 +277,8 @@ static void test_iface_setup(void)
net_if_up(iface1);
test_started = true;
return NULL;
}
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
return 0;
}
static void test_hostname_get(void)
ZTEST(net_hostname, test_hostname_get)
{
const char *hostname;
const char *config_hostname = CONFIG_NET_HOSTNAME;
@ -336,7 +338,7 @@ static void test_hostname_get(void)
}
}
static void test_hostname_set(void)
ZTEST(net_hostname, test_hostname_set)
{
if (IS_ENABLED(CONFIG_NET_HOSTNAME_UNIQUE)) {
int ret;
@ -347,13 +349,4 @@ static void test_hostname_set(void)
}
}
void test_main(void)
{
ztest_test_suite(net_hostname_test,
ztest_unit_test(test_iface_setup),
ztest_unit_test(test_hostname_get),
ztest_unit_test(test_hostname_set)
);
ztest_run_test_suite(net_hostname_test);
}
ZTEST_SUITE(net_hostname, NULL, test_iface_setup, NULL, NULL, NULL);