Skip to content

Commit

Permalink
test: lwm2m: Add test cases 306 and 307
Browse files Browse the repository at this point in the history
Add testcases for LwM2M SEND.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
  • Loading branch information
SeppoTakalo committed Oct 24, 2023
1 parent 86eefe1 commit 4109bb9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
7 changes: 6 additions & 1 deletion subsys/net/lib/lwm2m/lwm2m_shell.c
Expand Up @@ -54,6 +54,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 @@ -85,7 +90,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
2 changes: 2 additions & 0 deletions tests/net/lib/lwm2m/interop/README.md
Expand Up @@ -170,6 +170,8 @@ Tests are written from test spec;
|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-306 – Send Operation|:red_circle:|[#64290](https://github.com/zephyrproject-rtos/zephyr/issues/64290)|
|LightweightM2M-1.1-int-307 – Muting Send|:white_check_mark:| |
|LightweightM2M-1.1-int-401 - UDP Channel Security - PSK Mode |:white_check_mark:| |

* :white_check_mark: Working OK.
Expand Down
2 changes: 1 addition & 1 deletion tests/net/lib/lwm2m/interop/prj.conf
Expand Up @@ -99,5 +99,5 @@ CONFIG_LWM2M_NUM_ATTR=10
# Configure stack sizes
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_SHELL_STACK_SIZE=1024
CONFIG_SHELL_STACK_SIZE=1536
CONFIG_LWM2M_ENGINE_STACK_SIZE=2048
34 changes: 34 additions & 0 deletions tests/net/lib/lwm2m/interop/pytest/test_lwm2m.py
Expand Up @@ -47,6 +47,8 @@ def leshan_bootstrap() -> Leshan:
# Test specification:
# https://www.openmobilealliance.org/release/LightweightM2M/ETS/OMA-ETS-LightweightM2M-V1_1-20190912-D.pdf
#
# Bootstrap Interface: [0-99}
#

def verify_LightweightM2M_1_1_int_0(shell: Shell):
logger.info("LightweightM2M-1.1-int-0 - Client Initiated Bootstrap")
Expand All @@ -60,6 +62,10 @@ def verify_LightweightM2M_1_1_int_1(shell: Shell, leshan: Leshan, endpoint: str)
verify_LightweightM2M_1_1_int_101(shell, leshan, endpoint)
verify_LightweightM2M_1_1_int_401(shell, leshan, endpoint)

#
# Registration Interface [100-199]
#

def verify_LightweightM2M_1_1_int_101(shell: Shell, leshan: Leshan, endpoint: str):
logger.info("LightweightM2M-1.1-int-101 - Initial Registration")
shell._device.readlines_until(regex='.*Registration Done', timeout=5.0)
Expand Down Expand Up @@ -129,6 +135,10 @@ def verify_LightweightM2M_1_1_int_109(shell: Shell, leshan: Leshan, endpoint: st
shell.exec_command('lwm2m write 1/0/1 -u32 86400')
shell._device.readlines_until(regex='.*Registration update complete', timeout=10)

#
# Device management & Service Enablement Interface [200-299]
#

def verify_LightweightM2M_1_1_int_201(shell: Shell, leshan: Leshan, endpoint: str):
logger.info("LightweightM2M-1.1-int-201 - Querying basic information in Plain Text format")
fmt = leshan.format
Expand Down Expand Up @@ -550,6 +560,24 @@ def verify_LightweightM2M_1_1_int_281(shell: Shell, leshan: Leshan, endpoint: st
assert resp[1][0][1] == 86400
assert resp[1][0][7] == 'U'

#
# Information Reporting Interface [300-399]
#

def verify_LightweightM2M_1_1_int_306(shell: Shell, leshan: Leshan, endpoint: str):
logger.info("LightweightM2M-1.1-int-306 - Send Operation")
shell.exec_command('lwm2m send /1 /3 /16')
shell._device.readlines_until(regex=r'.*send_cb: 0', timeout=5.0)

def verify_LightweightM2M_1_1_int_307(shell: Shell, leshan: Leshan, endpoint: str):
logger.info("LightweightM2M-1.1-int-307 – Muting Send")
leshan.write(endpoint, '1/0/23', True)
lines = shell.get_filtered_output(shell.exec_command('lwm2m send /3/0'))
assert any("can't do send operation" in line for line in lines)
leshan.write(endpoint, '1/0/23', False)
shell.exec_command('lwm2m send /3/0')
shell._device.readlines_until(regex=r'.*send_cb: 0', timeout=5.0)

def verify_LightweightM2M_1_1_int_401(shell: Shell, leshan: Leshan, endpoint: str):
logger.info("LightweightM2M-1.1-int-401 - UDP Channel Security - Pre-shared Key Mode")
lines = shell.get_filtered_output(shell.exec_command('lwm2m read 0/0/0 -s'))
Expand Down Expand Up @@ -643,6 +671,12 @@ def test_lwm2m_bootstrap_psk(shell: Shell, leshan, leshan_bootstrap):
verify_LightweightM2M_1_1_int_280(shell, leshan, endpoint)
verify_LightweightM2M_1_1_int_281(shell, leshan, endpoint)

#
# Device management & Service Enablement Interface test cases
#
verify_LightweightM2M_1_1_int_306(shell, leshan, endpoint)
verify_LightweightM2M_1_1_int_307(shell, leshan, endpoint)

shell.exec_command('lwm2m stop')
shell._device.readlines_until(regex=r'.*Deregistration success', timeout=10.0)

Expand Down

0 comments on commit 4109bb9

Please sign in to comment.