Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LwM2M interoperability tests [0 - 399] #64013

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions samples/net/lwm2m_client/boards/qemu_x86.conf
@@ -1 +1,5 @@
CONFIG_FPU=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_QEMU_ETHERNET=y

CONFIG_PCIE=y
7 changes: 6 additions & 1 deletion subsys/net/lib/lwm2m/lwm2m_shell.c
Expand Up @@ -55,6 +55,11 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
"PATH is LwM2M path\n" \
"NUM how many elements to cache\n" \

static void send_cb(enum lwm2m_send_status status)
{
LOG_INF("SEND status: %d\n", status);
}

static int cmd_send(const struct shell *sh, size_t argc, char **argv)
{
int ret = 0;
Expand Down Expand Up @@ -86,7 +91,7 @@ static int cmd_send(const struct shell *sh, size_t argc, char **argv)
}
}

ret = lwm2m_send_cb(ctx, lwm2m_path_list, path_cnt, NULL);
ret = lwm2m_send_cb(ctx, lwm2m_path_list, path_cnt, send_cb);

if (ret < 0) {
shell_error(sh, "can't do send operation, request failed (%d)\n", ret);
Expand Down
121 changes: 100 additions & 21 deletions tests/net/lib/lwm2m/interop/README.md
Expand Up @@ -15,7 +15,39 @@ running Zephyr is using address `192.0.2.1`.
Follow [Networking with the host system](https://docs.zephyrproject.org/latest/connectivity/networking/networking_with_host.html#networking-with-the-host-system)
from Zephyr's documentation how to set it up, or follow [Create NAT and routing for Zephyr native network on Linux](https://github.com/zephyrproject-rtos/net-tools/blob/master/README%20NAT.md).

### Leshan server setup

### Run Lehan server from net-tools Docker container

Zephyr's net-tools Docker container already contains Leshan, so if you don't want to set the environment up manually,
use the pre-made docker.

First, build the docker container. You only need to do this one, or when you update the container.
```
cd tools/net-tools/docker
docker build -t net-tools .
```

Start the docker networking
```
cd tools/net-tools/
sudo ./net-setup.sh --config docker.conf start
```

Start the docker container and run leshan
```
docker run --hostname=net-tools --name=net-tools --ip=192.0.2.2 --ip6=2001:db8::2 -p 8080:8080 -p 8081:8081 -p 5683:5683/udp --rm -dit --network=net-tools0 net-tools
docker container exec net-tools /net-tools/start-leshan.sh
```

### Stop Leshan, docker and networking

```
cd tools/net-tools/
docker kill net-tools
sudo ./net-setup.sh --config docker.conf stop
docker network rm net-tools0
```
### Leshan server setup (manual)

* Leshan server must be reachable from the device using IP address `192.0.2.2`.
Configure the port forwarding, if you use Docker to run Leshan.
Expand Down Expand Up @@ -87,23 +119,70 @@ Or use the Docker based testing
Tests are written from test spec;
[OMA Enabler Test Specification (Interoperability) for Lightweight M2M](https://www.openmobilealliance.org/release/LightweightM2M/ETS/OMA-ETS-LightweightM2M-V1_1-20190912-D.pdf)

Following tests are implemented:
* LightweightM2M-1.1-int-0 – Client Initiated Bootstrap
* LightweightM2M-1.1-int-1 – Client Initiated Bootstrap Full (PSK)
* LightweightM2M-1.1-int-101 – Initial Registration
* LightweightM2M-1.1-int-102 – Registration Update
* LightweightM2M-1.1-int-104 – Registration Update Trigge
* LightweightM2M-1.1-int-105 - Discarded Register Update
* LightweightM2M-1.1-int-107 – Extending the lifetime of a registration
* LightweightM2M-1.1-int-108 – Turn on Queue Mode
* LightweightM2M-1.1-int-109 – Behavior in Queue Mode
* LightweightM2M-1.1-int-201 – Querying basic information in Plain Text
* LightweightM2M-1.1-int-203 – Querying basic information in TLV format
* LightweightM2M-1.1-int-204 – Querying basic information in JSON format
* LightweightM2M-1.1-int-205 – Setting basic information in Plain Text
* LightweightM2M-1.1-int-211 – Querying basic information in CBOR format
* LightweightM2M-1.1-int-212 – Setting basic information in CBOR format
* LightweightM2M-1.1-int-215 – Setting basic information in TLV format
* LightweightM2M-1.1-int-220 – Setting basic information in JSON format
* LightweightM2M-1.1-int-221 – Attempt to perform operations on Security
* LightweightM2M-1.1-int-401 – UDP Channel Security – PSK Mode
## Current status

|Test case|Status|Notes|
|---------|------|-----|
|LightweightM2M-1.1-int-0 - Client Initiated Bootstrap |:white_check_mark:| |
|LightweightM2M-1.1-int-1 - Client Initiated Bootstrap Full (PSK) |:white_check_mark:| |
|LightweightM2M-1.1-int-101 - Initial Registration |:white_check_mark:| |
|LightweightM2M-1.1-int-102 - Registration Update |:white_check_mark:| |
|LightweightM2M-1.1-int-103 - Deregistration |:large_orange_diamond:|We don't have "disabled" functionality in server object|
|LightweightM2M-1.1-int-104 - Registration Update Trigge |:white_check_mark:| |
|LightweightM2M-1.1-int-105 - Discarded Register Update |:white_check_mark:| |
|LightweightM2M-1.1-int-107 - Extending the lifetime of a registration |:white_check_mark:| |
|LightweightM2M-1.1-int-108 - Turn on Queue Mode |:white_check_mark:| |
|LightweightM2M-1.1-int-109 - Behavior in Queue Mode |:white_check_mark:| |
|LightweightM2M-1.1-int-201 - Querying basic information in Plain Text |:white_check_mark:| |
|LightweightM2M-1.1-int-203 - Querying basic information in TLV format |:white_check_mark:| |
|LightweightM2M-1.1-int-204 - Querying basic information in JSON format |:white_check_mark:| |
|LightweightM2M-1.1-int-205 - Setting basic information in Plain Text |:white_check_mark:| |
|LightweightM2M-1.1-int-211 - Querying basic information in CBOR format |:white_check_mark:| |
|LightweightM2M-1.1-int-212 - Setting basic information in CBOR format |:white_check_mark:| |
|LightweightM2M-1.1-int-215 - Setting basic information in TLV format |:white_check_mark:| |
|LightweightM2M-1.1-int-220 - Setting basic information in JSON format |:white_check_mark:| |
|LightweightM2M-1.1-int-221 - Attempt to perform operations on Security |:white_check_mark:| |
|LightweightM2M-1.1-int-222 - Read on Object |:white_check_mark:| |
|LightweightM2M-1.1-int-223 - Read on Object Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-224 - Read on Resource |:white_check_mark:| |
|LightweightM2M-1.1-int-225 - Read on Resource Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-226 - Write (Partial Update) on Object Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-222 - Read on Object |:white_check_mark:| |
|LightweightM2M-1.1-int-223 - Read on Object Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-224 - Read on Resource |:white_check_mark:| |
|LightweightM2M-1.1-int-225 - Read on Resource Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-226 - Write (Partial Update) on Object Instance |:white_check_mark:| |
|LightweightM2M-1.1-int-227 - Write (replace) on Resource |:white_check_mark:| |
|LightweightM2M-1.1-int-228 - Write on Resource Instance |:white_check_mark:|[~~#64011~~](https://github.com/zephyrproject-rtos/zephyr/issues/64011) |
|LightweightM2M-1.1-int-229 - Read-Composite Operation|:white_check_mark:|[~~#64012~~](https://github.com/zephyrproject-rtos/zephyr/issues/64012) [~~#64189~~](https://github.com/zephyrproject-rtos/zephyr/issues/64189) |
|LightweightM2M-1.1-int-230 - Write-Composite Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-231 - Querying basic information in SenML JSON format|:white_check_mark:| |
|LightweightM2M-1.1-int-232 - Querying basic information in SenML CBOR format|:white_check_mark:| |
|LightweightM2M-1.1-int-233 - Setting basic information in SenML CBOR format|:white_check_mark:| |
|LightweightM2M-1.1-int-234 - Setting basic information in SenML JSON format|:white_check_mark:| |
|LightweightM2M-1.1-int-235 - Read-Composite Operation on root path|:large_orange_diamond:|Root Path is not yet supported by Leshan.|
|LightweightM2M-1.1-int-236 - Read-Composite - Partial Presence|:white_check_mark:| |
|LightweightM2M-1.1-int-237 - Read on Object without specifying Content-Type|:white_check_mark:| |
|LightweightM2M-1.1-int-241 - Executable Resource: Rebooting the device|:white_check_mark:| |
|LightweightM2M-1.1-int-256 - Write Operation Failure|:white_check_mark:| |
|LightweightM2M-1.1-int-257 - Write-Composite Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-260 - Discover Command|:white_check_mark:| |
|LightweightM2M-1.1-int-261 - Write-Attribute Operation on a multiple resource|:large_orange_diamond:|Leshan don't allow writing attributes to resource instance|
|LightweightM2M-1.1-int-280 - Successful Read-Composite Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-281 - Partially Successful Read-Composite Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-301 - Observation and Notification of parameter values|:white_check_mark:| |
|LightweightM2M-1.1-int-302 - Cancel Observations using Reset Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-303 - Cancel observations using Observe with Cancel parameter|:large_orange_diamond:|Leshan only supports passive cancelling|
|LightweightM2M-1.1-int-304 - Observe-Composite Operation|:white_check_mark:| |
|LightweightM2M-1.1-int-305 - Cancel Observation-Composite Operation|:large_orange_diamond:|Leshan only supports passive cancelling|
|LightweightM2M-1.1-int-306 – Send Operation|:white_check_mark:|[~~#64290~~](https://github.com/zephyrproject-rtos/zephyr/issues/64290)|
|LightweightM2M-1.1-int-307 – Muting Send|:white_check_mark:| |
|LightweightM2M-1.1-int-308 - Observe-Composite and Creating Object Instance|:white_check_mark:|[~~#64634~~](https://github.com/zephyrproject-rtos/zephyr/issues/64634)|
|LightweightM2M-1.1-int-309 - Observe-Composite and Deleting Object Instance|:white_check_mark:|[~~#64634~~](https://github.com/zephyrproject-rtos/zephyr/issues/64634)|
|LightweightM2M-1.1-int-310 - Observe-Composite and modification of parameter values|:white_check_mark:| |
|LightweightM2M-1.1-int-311 - Send command|:white_check_mark:| |
|LightweightM2M-1.1-int-401 - UDP Channel Security - PSK Mode |:white_check_mark:| |

* :white_check_mark: Working OK.
* :large_orange_diamond: Feature or operation not implemented.
* :red_circle: Broken
1 change: 1 addition & 0 deletions tests/net/lib/lwm2m/interop/boards/native_posix.conf
Expand Up @@ -5,3 +5,4 @@ CONFIG_LWM2M_DNS_SUPPORT=y
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
CONFIG_NATIVE_POSIX_SLOWDOWN_TO_REAL_TIME=y
CONFIG_NATIVE_UART_0_ON_STDINOUT=y
CONFIG_ASAN=y
20 changes: 9 additions & 11 deletions tests/net/lib/lwm2m/interop/boards/qemu_cortex_m3.conf
Expand Up @@ -5,16 +5,14 @@ CONFIG_NET_QEMU_ETHERNET=y

# RAM/ROM tuning
CONFIG_IDLE_STACK_SIZE=128
CONFIG_MBEDTLS_HEAP_SIZE=7000
CONFIG_ISR_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1024
CONFIG_LWM2M_ENGINE_STACK_SIZE=2000
CONFIG_LWM2M_LOG_LEVEL_INF=y
CONFIG_LWM2M_ENGINE_MAX_MESSAGES=3
CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE=0
CONFIG_LWM2M_ENGINE_MAX_OBSERVER=5
CONFIG_LWM2M_SECURITY_DTLS_TLS_CIPHERSUITE_MAX=3
CONFIG_LWM2M_DEVICE_PWRSRC_MAX=2
CONFIG_LWM2M_DEVICE_ERROR_CODE_MAX=5
CONFIG_LWM2M_DEVICE_EXT_DEV_INFO_MAX=2
CONFIG_LWM2M_NUM_ATTR=10
CONFIG_LOG_BUFFER_SIZE=512

# qemu_cortex_m3 have smaller memory so simulate a small
# device and small network where max CoAP packet is 256+headers.
# This excercises the outgoing block-wise module intentionally.
CONFIG_LWM2M_COAP_MAX_MSG_SIZE=256
CONFIG_LWM2M_COAP_BLOCK_SIZE=256
CONFIG_LWM2M_COAP_BLOCK_TRANSFER=y
CONFIG_LWM2M_COAP_ENCODE_BUFFER_SIZE=2048
4 changes: 4 additions & 0 deletions tests/net/lib/lwm2m/interop/boards/qemu_x86.conf
@@ -0,0 +1,4 @@
CONFIG_FPU=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_QEMU_ETHERNET=y
CONFIG_PCIE=y
73 changes: 43 additions & 30 deletions tests/net/lib/lwm2m/interop/prj.conf
@@ -1,36 +1,22 @@
CONFIG_NETWORKING=y
CONFIG_LOG=y
CONFIG_LWM2M_LOG_LEVEL_DBG=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_IPV6=y
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=2
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_DHCPV4=n
CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT=3
CONFIG_NET_IF_MCAST_IPV4_ADDR_COUNT=2
CONFIG_PRINTK=y
CONFIG_NET_PKT_RX_COUNT=10
CONFIG_NET_PKT_TX_COUNT=10
CONFIG_NET_BUF_RX_COUNT=10
CONFIG_NET_BUF_TX_COUNT=10
CONFIG_NET_MAX_CONTEXTS=5
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="2001:db8::2"
CONFIG_NET_PKT_RX_COUNT=4
CONFIG_NET_PKT_TX_COUNT=4
CONFIG_NET_BUF_RX_COUNT=8
CONFIG_NET_BUF_TX_COUNT=8
CONFIG_NET_MAX_CONTEXTS=4
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"

CONFIG_NET_LOG=y

CONFIG_NET_CONFIG_NEED_IPV6=y
CONFIG_NET_CONFIG_NEED_IPV4=y
CONFIG_NET_CONFIG_SETTINGS=y

CONFIG_LWM2M=y
CONFIG_LWM2M_COAP_BLOCK_SIZE=512
CONFIG_LWM2M_IPSO_SUPPORT=y
CONFIG_LWM2M_SHELL=y
CONFIG_LWM2M_ACCESS_CONTROL_ENABLE=n

#Enable Portfolio object
CONFIG_LWM2M_PORTFOLIO_OBJ_SUPPORT=y
Expand All @@ -47,7 +33,7 @@ CONFIG_LWM2M_RW_SENML_JSON_SUPPORT=y

#Enable SenML CBOR content format
CONFIG_LWM2M_RW_SENML_CBOR_SUPPORT=y
CONFIG_LWM2M_RW_SENML_CBOR_RECORDS=60
CONFIG_LWM2M_RW_SENML_CBOR_RECORDS=40
CONFIG_ZCBOR_CANONICAL=y

#Enable legacy content formats
Expand All @@ -62,7 +48,7 @@ CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=40
CONFIG_LWM2M_QUEUE_MODE_ENABLED=y
CONFIG_LWM2M_QUEUE_MODE_UPTIME=20
CONFIG_LWM2M_UPDATE_PERIOD=30
CONFIG_LWM2M_SECONDS_TO_UPDATE_EARLY=10
CONFIG_LWM2M_RD_CLIENT_STOP_POLLING_AT_IDLE=y

# LwM2M configuration as OMA-ETS-LightweightM2M_INT-V1_1-20190912-D Configuration 3
CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=30
Expand All @@ -74,19 +60,46 @@ CONFIG_MBEDTLS_TLS_VERSION_1_2=y

# Special MbedTLS changes
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=8192
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=1500
# MTU - IPv6 header - UDP header - DTLS header
# 1280 - 40 - 8 - 21
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=1211
CONFIG_MBEDTLS_HEAP_SIZE=7168
CONFIG_MBEDTLS_CIPHER_CCM_ENABLED=y

# Disable RSA, we don't parse certs: saves flash/memory
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED=n
# Enable PSK instead
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED=y
CONFIG_LWM2M_SECURITY_DTLS_TLS_CIPHERSUITE_MAX=3

CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4
# For testing purposes, limit DTLS contexts to one,
# LwM2M engine should not use more than one on any given time.
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=1
CONFIG_NET_SOCKETS_ENABLE_DTLS=y

# MbedTLS needs a larger stack
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MBEDTLS_SSL_DTLS_CONNECTION_ID=y

# Assume that IPv6 minimum MTU is accepted
# MTU - IPv6 header - UDP header - DTLS header - CoAP header room
# 1280 - 40 - 8 - 21 - 48
CONFIG_LWM2M_COAP_MAX_MSG_SIZE=1163
CONFIG_LWM2M_COAP_BLOCK_SIZE=1024
CONFIG_LWM2M_COAP_BLOCK_TRANSFER=y
CONFIG_LWM2M_COAP_ENCODE_BUFFER_SIZE=4096
CONFIG_LWM2M_NUM_OUTPUT_BLOCK_CONTEXT=1
CONFIG_LWM2M_NUM_BLOCK1_CONTEXT=1
CONFIG_SYS_HASH_FUNC32=y
CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE=0
CONFIG_LWM2M_ENGINE_MAX_PENDING=2
CONFIG_LWM2M_ENGINE_MAX_REPLIES=2
CONFIG_LWM2M_ENGINE_MAX_MESSAGES=3
CONFIG_LWM2M_ENGINE_MAX_OBSERVER=5
CONFIG_LWM2M_DEVICE_PWRSRC_MAX=2
CONFIG_LWM2M_DEVICE_ERROR_CODE_MAX=2
CONFIG_LWM2M_DEVICE_EXT_DEV_INFO_MAX=2
CONFIG_LWM2M_NUM_ATTR=20

# Configure stack sizes
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_SHELL_STACK_SIZE=1536
CONFIG_LWM2M_ENGINE_STACK_SIZE=2048