Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/twister.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
env:
TWISTER_COMMON: ' --force-color --inline-logs -v -N -M --retry-failed 3 '
DAILY_OPTIONS: ' -M --build-only --show-footprint'
VENDOR_FILTER: ' --vendor nordic --vendor zephyr '
VENDOR_FILTER: ' --vendor nordic --vendor zephyr --vendor embeint '
EXTRA_BOARDS: ' --platform qemu_cortex_m3 --platform qemu_cortex_m0 '
UNIT_TESTING: ' --platform unit_testing '
PR_OPTIONS: ' --clobber-output --integration'
Expand Down
15 changes: 15 additions & 0 deletions tests/net/auto_sntp/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build as SDK application on real hardware
configdefault INFUSE_SDK
default y if SOC_FAMILY_NORDIC_NRF

config WIFI_SSID
string "WiFi SSID"
depends on WIFI
default "test_ssid"

config WIFI_PSK
string "WiFi PSK"
depends on WIFI
default "test_psk"

source "Kconfig.zephyr"
3 changes: 3 additions & 0 deletions tests/net/auto_sntp/prj.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_ZTEST=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
Expand All @@ -7,6 +8,8 @@ CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_INFUSE_EPOCH_TIME=y
CONFIG_DNS_RESOLVER=y
CONFIG_INFUSE_DNS=y
CONFIG_SNTP=y
CONFIG_SNTP_AUTO=y
CONFIG_SNTP_AUTO_RESYNC_AGE=3
28 changes: 24 additions & 4 deletions tests/net/auto_sntp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
#include <zephyr/ztest.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/conn_mgr_monitor.h>
#include <zephyr/net/conn_mgr_connectivity.h>

#include <infuse/time/epoch.h>
#include <infuse/fs/kv_store.h>
#include <infuse/fs/kv_types.h>

#ifdef CONFIG_WIFI
#define IF_DELAY K_SECONDS(20)
#else
#define IF_DELAY K_SECONDS(5)
#endif

K_SEM_DEFINE(l4_up, 0, 1);
K_SEM_DEFINE(time_ref_updated, 0, 1);

Expand Down Expand Up @@ -59,23 +66,27 @@ ZTEST(auto_sntp, test_auto_sntp)
{
struct timeutil_sync_instant reference;
static struct epoch_time_cb time_cb;
struct net_if *iface = net_if_get_default();

/* Register for time callbacks */
time_cb.reference_time_updated = reference_time_updated;
time_cb.user_ctx = &time_ref_updated;
epoch_time_register_callback(&time_cb);

#ifdef CONFIG_NET_NATIVE_OFFLOADED_SOCKETS
struct net_if *iface = net_if_get_default();
struct in_addr addr;

/* Add the IP address to trigger NET_EVENT_L4_CONNECTED */
zassert_equal(0, net_addr_pton(AF_INET, "192.0.2.1", &addr));
zassert_not_null(net_if_ipv4_addr_add(iface, &addr, NET_ADDR_MANUAL, 0));
net_addr_pton(AF_INET, "192.0.2.1", &addr);
net_if_ipv4_addr_add(iface, &addr, NET_ADDR_MANUAL, 0);
#else
/* Turn on all interfaces */
conn_mgr_all_if_up(false);
conn_mgr_all_if_connect(false);
#endif /* CONFIG_NET_NATIVE_OFFLOADED_SOCKETS */

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Wait for time to be updated */
zassert_equal(0, k_sem_take(&time_ref_updated, K_SECONDS(2)));
Expand Down Expand Up @@ -129,10 +140,19 @@ void *test_init(void)
{
static struct net_mgmt_event_callback mgmt_cb;

#ifdef CONFIG_WIFI
KV_STRING_CONST(ssid, CONFIG_WIFI_SSID);
KV_STRING_CONST(psk, CONFIG_WIFI_PSK);

kv_store_write(KV_KEY_WIFI_SSID, &ssid, sizeof(ssid));
kv_store_write(KV_KEY_WIFI_PSK, &psk, sizeof(psk));
#endif /* CONFIG_WIFI */

if (IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) {
net_mgmt_init_event_callback(&mgmt_cb, l4_event_handler, NET_EVENT_L4_CONNECTED);
net_mgmt_add_event_callback(&mgmt_cb);
}

return NULL;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/net/auto_sntp/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ common:
tests:
net.auto_sntp:
build_only: true
platform_allow:
integration_platforms:
- nrf7002dk/nrf5340/cpuapp
required_snippets:
- infuse
depends_on:
- net
- netif
net.auto_sntp.native:
platform_allow:
- native_sim
Expand Down
15 changes: 15 additions & 0 deletions tests/net/coap/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build as SDK application on real hardware
configdefault INFUSE_SDK
default y if SOC_FAMILY_NORDIC_NRF

config WIFI_SSID
string "WiFi SSID"
depends on WIFI
default "test_ssid"

config WIFI_PSK
string "WiFi PSK"
depends on WIFI
default "test_psk"

source "Kconfig.zephyr"
1 change: 1 addition & 0 deletions tests/net/coap/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ CONFIG_NET_IPV6=y
CONFIG_COAP=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_DNS_RESOLVER=y
CONFIG_INFUSE_DNS=y
CONFIG_INFUSE_COAP=y
31 changes: 26 additions & 5 deletions tests/net/coap/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
#include <zephyr/ztest.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/conn_mgr_monitor.h>
#include <zephyr/net/conn_mgr_connectivity.h>
#include <zephyr/net/socket.h>

#include <infuse/net/coap.h>
#include <infuse/net/dns.h>
#include <infuse/fs/kv_store.h>
#include <infuse/fs/kv_types.h>

#ifdef CONFIG_WIFI
#define IF_DELAY K_SECONDS(20)
#else
#define IF_DELAY K_SECONDS(5)
#endif

K_SEM_DEFINE(l4_up, 0, 1);

Expand Down Expand Up @@ -118,7 +127,7 @@ ZTEST(infuse_coap, test_resource_errors)
int rc;

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Open socket */
sock = socket_setup();
Expand Down Expand Up @@ -156,7 +165,7 @@ ZTEST(infuse_coap, test_timeout)
int rc;

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Open socket */
sock = socket_setup();
Expand Down Expand Up @@ -196,7 +205,7 @@ ZTEST(infuse_coap, test_socket_close)
k_work_init_delayable(&work, async_socket_close);

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Open socket */
sock = socket_setup();
Expand All @@ -222,7 +231,7 @@ ZTEST(infuse_coap, test_download)
int rc;

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Open socket */
sock = socket_setup();
Expand Down Expand Up @@ -277,7 +286,7 @@ ZTEST(infuse_coap, test_separate_response)
int rc;

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* Open socket */
sock = socket_setup();
Expand All @@ -298,6 +307,14 @@ void *test_init(void)
{
static struct net_mgmt_event_callback mgmt_cb;

#ifdef CONFIG_WIFI
KV_STRING_CONST(ssid, CONFIG_WIFI_SSID);
KV_STRING_CONST(psk, CONFIG_WIFI_PSK);

kv_store_write(KV_KEY_WIFI_SSID, &ssid, sizeof(ssid));
kv_store_write(KV_KEY_WIFI_PSK, &psk, sizeof(psk));
#endif /* CONFIG_WIFI */

if (IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) {
net_mgmt_init_event_callback(&mgmt_cb, l4_event_handler, NET_EVENT_L4_CONNECTED);
net_mgmt_add_event_callback(&mgmt_cb);
Expand All @@ -310,6 +327,10 @@ void *test_init(void)
/* Add the IP address to trigger NET_EVENT_L4_CONNECTED */
net_addr_pton(AF_INET, "192.0.2.1", &addr);
net_if_ipv4_addr_add(iface, &addr, NET_ADDR_MANUAL, 0);
#else
/* Turn on all interfaces */
conn_mgr_all_if_up(false);
conn_mgr_all_if_connect(false);
#endif /* CONFIG_NET_NATIVE_OFFLOADED_SOCKETS */

return NULL;
Expand Down
6 changes: 4 additions & 2 deletions tests/net/coap/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ common:
tests:
net.coap:
build_only: true
platform_allow:
integration_platforms:
- nrf7002dk/nrf5340/cpuapp
required_snippets:
- infuse
depends_on:
- net
- netif
net.coap.native:
platform_allow:
- native_sim
Expand Down
15 changes: 15 additions & 0 deletions tests/net/dns/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build as SDK application on real hardware
configdefault INFUSE_SDK
default y if SOC_FAMILY_NORDIC_NRF

config WIFI_SSID
string "WiFi SSID"
depends on WIFI
default "test_ssid"

config WIFI_PSK
string "WiFi PSK"
depends on WIFI
default "test_psk"

source "Kconfig.zephyr"
1 change: 1 addition & 0 deletions tests/net/dns/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_DNS_RESOLVER=y
CONFIG_INFUSE_DNS=y
45 changes: 35 additions & 10 deletions tests/net/dns/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@
#include <zephyr/ztest.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/conn_mgr_monitor.h>
#include <zephyr/net/conn_mgr_connectivity.h>

#include <infuse/fs/kv_store.h>
#include <infuse/fs/kv_types.h>
#include <infuse/net/dns.h>

#ifdef CONFIG_WIFI
#define IF_DELAY K_SECONDS(20)
#else
#define IF_DELAY K_SECONDS(5)
#endif

K_SEM_DEFINE(l4_up, 0, 1);

static void l4_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event,
Expand All @@ -32,17 +41,8 @@ ZTEST(infuse_dns, test_dns_query)
struct sockaddr address;
socklen_t address_len;

#ifdef CONFIG_NET_NATIVE_OFFLOADED_SOCKETS
struct net_if *iface = net_if_get_default();
struct in_addr addr;

/* Add the IP address to trigger NET_EVENT_L4_CONNECTED */
zassert_equal(0, net_addr_pton(AF_INET, "192.0.2.1", &addr));
zassert_not_null(net_if_ipv4_addr_add(iface, &addr, NET_ADDR_MANUAL, 0));
#endif /* CONFIG_NET_NATIVE_OFFLOADED_SOCKETS */

/* Wait for the interface to come up */
zassert_equal(0, k_sem_take(&l4_up, K_SECONDS(5)));
zassert_equal(0, k_sem_take(&l4_up, IF_DELAY));

/* IPv4 lookups */
zassert_equal(
Expand All @@ -52,23 +52,48 @@ ZTEST(infuse_dns, test_dns_query)
zassert_not_equal(0, infuse_sync_dns("not.a.real.address", 80, AF_INET, SOCK_STREAM,
&address, &address_len));

/* Not working on WiFi network, not sure how to validate at runtime if this should work */
#if defined(CONFIG_NET_IPV6) && !defined(CONFIG_WIFI)
/* IPv6 lookups */
zassert_equal(0, infuse_sync_dns("google.com", 80, AF_INET6, SOCK_STREAM, &address,
&address_len));
zassert_equal(sizeof(struct sockaddr_in6), address_len);

zassert_not_equal(0, infuse_sync_dns("not.a.real.address", 80, AF_INET6, SOCK_STREAM,
&address, &address_len));
#endif /* defined(CONFIG_NET_IPV6) && !defined(CONFIG_WIFI) */
}

void *test_init(void)
{
static struct net_mgmt_event_callback mgmt_cb;

#ifdef CONFIG_WIFI
KV_STRING_CONST(ssid, CONFIG_WIFI_SSID);
KV_STRING_CONST(psk, CONFIG_WIFI_PSK);

kv_store_write(KV_KEY_WIFI_SSID, &ssid, sizeof(ssid));
kv_store_write(KV_KEY_WIFI_PSK, &psk, sizeof(psk));
#endif /* CONFIG_WIFI */

if (IS_ENABLED(CONFIG_NET_CONNECTION_MANAGER)) {
net_mgmt_init_event_callback(&mgmt_cb, l4_event_handler, NET_EVENT_L4_CONNECTED);
net_mgmt_add_event_callback(&mgmt_cb);
}

#ifdef CONFIG_NET_NATIVE_OFFLOADED_SOCKETS
struct net_if *iface = net_if_get_default();
struct in_addr addr;

/* Add the IP address to trigger NET_EVENT_L4_CONNECTED */
net_addr_pton(AF_INET, "192.0.2.1", &addr);
net_if_ipv4_addr_add(iface, &addr, NET_ADDR_MANUAL, 0);
#else
/* Turn on all interfaces */
conn_mgr_all_if_up(false);
conn_mgr_all_if_connect(false);
#endif /* CONFIG_NET_NATIVE_OFFLOADED_SOCKETS */

return NULL;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/net/dns/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ common:
tests:
net.dns:
build_only: true
platform_allow:
integration_platforms:
- nrf7002dk/nrf5340/cpuapp
required_snippets:
- infuse
depends_on:
- net
- netif
net.dns.native:
platform_allow:
- native_sim
Expand Down
Loading