Skip to content

Commit b02dfa6

Browse files
committed
tests: pouch: downlink: test with very long device name
Use very long device name, so that pouch header does not fit into single transport MTU (19).
1 parent aa49b0c commit b02dfa6

5 files changed

Lines changed: 34 additions & 11 deletions

File tree

tests/pouch/downlink/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function(pouch_gen_lorem length)
1818
${PYTHON_EXECUTABLE}
1919
${APPLICATION_SOURCE_DIR}/scripts/pouch-gen-lorem.py
2020
--length ${length}
21+
--device-name ${CONFIG_POUCH_DEVICE_NAME}
2122
${gen_dir}/lorem-${length}.bin
2223
DEPENDS ${APPLICATION_SOURCE_DIR}/scripts/pouch-gen-lorem.py
2324
WORKING_DIRECTORY ${APPLICATION_SOURCE_DIR}/

tests/pouch/downlink/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
menu "Downlink test configuration"
2+
3+
config POUCH_DEVICE_NAME
4+
string "Device name used in encoded pouches"
5+
default "id123"
6+
7+
endmenu
8+
9+
source "Kconfig.zephyr"

tests/pouch/downlink/scripts/pouch-gen-lorem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ def payload_append(payload: bytearray, data: bytes, stream_id: int, flags: int):
7878
def main(
7979
out: Annotated[typer.FileBinaryWrite, typer.Argument()],
8080
length: Annotated[int, typer.Option(min=0)] = len(LOREM_IPSUM),
81+
device_name: Annotated[str, typer.Option()] = "id123",
8182
):
8283
obj = {
83-
"device_id": "id123",
84+
"device_id": device_name,
8485
"entries": [
8586
{
8687
"path": "/.s/lorem",

tests/pouch/downlink/src/downlink.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ LOG_MODULE_REGISTER(downlink_test);
1212

1313
#define BLOCK_SIZE 512
1414

15-
#define LEN_POUCH_HEADER 5
15+
#define LEN_DEVICE_NAME (sizeof(CONFIG_POUCH_DEVICE_NAME) - 1)
16+
17+
/*
18+
* CBOR "device name length" is encoded with more bytes if device name is more
19+
* than 23 bytes
20+
*/
21+
#define LEN_POUCH_HEADER 5 + (LEN_DEVICE_NAME > 23 ? 1 : 0)
1622
#define LEN_BLOCK_HEADER 3
1723
#define LEN_ENTRY_LENGTH 2
1824
#define LEN_ENTRY_PATH 2
1925
#define LEN_ENTRY_CONTENT_TYPE 1
2026

21-
#define FIRST_BLOCK_OFFSET (LEN_POUCH_HEADER + sizeof("id123") - 1)
27+
#define FIRST_BLOCK_OFFSET (LEN_POUCH_HEADER + LEN_DEVICE_NAME)
2228

2329
#define TRANSPORT_MTU 19
2430

tests/pouch/downlink/testcase.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
common:
2+
platform_allow:
3+
- native_sim
4+
- native_sim/native/64
5+
integration_platforms:
6+
- native_sim
7+
- native_sim/native/64
8+
tags: test_framework
19
tests:
2-
pouch.downlink:
3-
platform_allow:
4-
- native_sim
5-
- native_sim/native/64
6-
integration_platforms:
7-
- native_sim
8-
- native_sim/native/64
9-
tags: test_framework
10+
pouch.downlink.id123:
11+
extra_configs:
12+
- CONFIG_POUCH_DEVICE_NAME="id123"
13+
pouch.downlink.very-long-device-name-with-id123:
14+
extra_configs:
15+
- CONFIG_POUCH_DEVICE_NAME="very-long-device-name-with-id123"

0 commit comments

Comments
 (0)