Skip to content

Commit c970356

Browse files
[nrf fromlist] tests: mgmt: Adapt to API changes in zcbor 0.8.0
zcbor_new_state and zcbor_tstr_put_term Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent 2aefab6 commit c970356

File tree

16 files changed

+97
-93
lines changed

16 files changed

+97
-93
lines changed

Diff for: tests/subsys/mgmt/mcumgr/cb_notifications/src/smp_test_util.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool create_mcumgr_format_packet(zcbor_state_t *zse, uint8_t *buffer, uint8_t *o
2929

3030
ok = zcbor_map_start_encode(zse, 2) &&
3131
zcbor_tstr_put_lit(zse, "d") &&
32-
zcbor_tstr_put_term(zse, "some test data") &&
32+
zcbor_tstr_put_lit(zse, "some test data") &&
3333
zcbor_map_end_encode(zse, 2);
3434

3535
*buffer_size = (zse->payload_mut - buffer);

Diff for: tests/subsys/mgmt/mcumgr/fs_mgmt_hash_supported/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ZTEST(fs_mgmt_hash_supported, test_supported)
9797

9898
/* Search expected type array for this type and update details */
9999
zcbor_new_decode_state(state, 10, &nb->data[sizeof(struct smp_hdr)],
100-
(nb->len - sizeof(struct smp_hdr)), 1);
100+
(nb->len - sizeof(struct smp_hdr)), 1, NULL, 0);
101101

102102
ok = zcbor_map_start_decode(state);
103103

Diff for: tests/subsys/mgmt/mcumgr/mcumgr_client/src/img_gr_stub.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ void img_read_response(int count)
120120
zcbor_tstr_put_lit(zse, "slot") &&
121121
zcbor_uint32_put(zse, image_dummy_info[i].slot_num) &&
122122
zcbor_tstr_put_lit(zse, "version") &&
123-
zcbor_tstr_put_term(zse, image_dummy_info[i].version) &&
123+
zcbor_tstr_put_term(zse, image_dummy_info[i].version,
124+
sizeof(image_dummy_info[i].version)) &&
124125

125-
zcbor_tstr_put_term(zse, "hash") &&
126+
zcbor_tstr_put_lit(zse, "hash") &&
126127
zcbor_bstr_encode_ptr(zse, image_dummy_info[i].hash, IMG_MGMT_DATA_SHA_LEN) &&
127128
ZCBOR_ENCODE_FLAG(zse, "bootable", image_dummy_info[i].flags.bootable) &&
128129
ZCBOR_ENCODE_FLAG(zse, "pending", image_dummy_info[i].flags.pending) &&
@@ -180,7 +181,8 @@ void img_state_write_verify(struct net_buf *nb)
180181
ZCBOR_MAP_DECODE_KEY_DECODER("hash", zcbor_bstr_decode, &hash)
181182
};
182183

183-
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1);
184+
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1,
185+
NULL, 0);
184186

185187
decoded = 0;
186188
/* Init buffer values */
@@ -231,7 +233,8 @@ void img_upload_init_verify(struct net_buf *nb)
231233
ZCBOR_MAP_DECODE_KEY_DECODER("sha", zcbor_bstr_decode, &sha)
232234
};
233235

234-
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1);
236+
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1,
237+
NULL, 0);
235238

236239
decoded = 0;
237240
/* Init buffer values */

Diff for: tests/subsys/mgmt/mcumgr/mcumgr_client/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,12 @@ ZTEST(mcumgr_client, test_os_echo)
225225
smp_stub_set_rx_data_verify(NULL);
226226
smp_client_send_status_stub(MGMT_ERR_EOK);
227227
/* Test timeout */
228-
rc = os_mgmt_client_echo(&os_client, os_echo_test);
228+
rc = os_mgmt_client_echo(&os_client, os_echo_test, sizeof(os_echo_test));
229229
zassert_equal(MGMT_ERR_ETIMEOUT, rc, "Expected to receive %d response %d",
230230
MGMT_ERR_ETIMEOUT, rc);
231231
/* Test successfully operation */
232232
smp_stub_set_rx_data_verify(os_echo_verify);
233-
rc = os_mgmt_client_echo(&os_client, os_echo_test);
233+
rc = os_mgmt_client_echo(&os_client, os_echo_test, sizeof(os_echo_test));
234234
zassert_equal(MGMT_ERR_EOK, rc, "Expected to receive %d response %d", MGMT_ERR_EOK, rc);
235235
}
236236

Diff for: tests/subsys/mgmt/mcumgr/mcumgr_client/src/os_gr_stub.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ void os_echo_verify(struct net_buf *nb)
8181
ZCBOR_MAP_DECODE_KEY_DECODER("d", zcbor_tstr_decode, &echo_data)
8282
};
8383

84-
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1);
84+
zcbor_new_decode_state(zsd, ARRAY_SIZE(zsd), nb->data + sizeof(struct smp_hdr), nb->len, 1,
85+
NULL, 0);
8586
echo_data.len = 0;
8687

8788
rc = zcbor_map_decode_bulk(zsd, list_res_decode, ARRAY_SIZE(list_res_decode), &decoded);

Diff for: tests/subsys/mgmt/mcumgr/os_mgmt_datetime/src/main.c

+22-22
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_get_not_set_v1)
191191

192192
/* Process received data by removing header */
193193
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
194-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
194+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
195195

196196
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
197197
zassert_true(ok, "Expected decode to be successful");
@@ -253,7 +253,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_get_not_set_v2)
253253

254254
/* Process received data by removing header */
255255
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
256-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
256+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
257257

258258
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
259259
zassert_true(ok, "Expected decode to be successful");
@@ -318,7 +318,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_1)
318318

319319
/* Process received data by removing header */
320320
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
321-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
321+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
322322

323323
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
324324
zassert_true(ok, "Expected decode to be successful");
@@ -365,7 +365,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_1)
365365

366366
/* Process received data by removing header */
367367
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
368-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
368+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
369369

370370
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
371371
zassert_true(ok, "Expected decode to be successful");
@@ -428,7 +428,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_2)
428428

429429
/* Process received data by removing header */
430430
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
431-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
431+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
432432

433433
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
434434
zassert_true(ok, "Expected decode to be successful");
@@ -475,7 +475,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_2)
475475

476476
/* Process received data by removing header */
477477
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
478-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
478+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
479479

480480
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
481481
zassert_true(ok, "Expected decode to be successful");
@@ -538,7 +538,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_3)
538538

539539
/* Process received data by removing header */
540540
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
541-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
541+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
542542

543543
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
544544
zassert_true(ok, "Expected decode to be successful");
@@ -585,7 +585,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v1_3)
585585

586586
/* Process received data by removing header */
587587
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
588-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
588+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
589589

590590
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
591591
zassert_true(ok, "Expected decode to be successful");
@@ -648,7 +648,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_1)
648648

649649
/* Process received data by removing header */
650650
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
651-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
651+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
652652

653653
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
654654
zassert_true(ok, "Expected decode to be successful");
@@ -695,7 +695,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_1)
695695

696696
/* Process received data by removing header */
697697
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
698-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
698+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
699699

700700
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
701701
zassert_true(ok, "Expected decode to be successful");
@@ -760,7 +760,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_2)
760760

761761
/* Process received data by removing header */
762762
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
763-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
763+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
764764

765765
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
766766
zassert_true(ok, "Expected decode to be successful");
@@ -807,7 +807,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_2)
807807

808808
/* Process received data by removing header */
809809
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
810-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
810+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
811811

812812
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
813813
zassert_true(ok, "Expected decode to be successful");
@@ -872,7 +872,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_3)
872872

873873
/* Process received data by removing header */
874874
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
875-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
875+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
876876

877877
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
878878
zassert_true(ok, "Expected decode to be successful");
@@ -919,7 +919,7 @@ ZTEST(os_mgmt_datetime_not_set, test_datetime_set_invalid_v2_3)
919919

920920
/* Process received data by removing header */
921921
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
922-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
922+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
923923

924924
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
925925
zassert_true(ok, "Expected decode to be successful");
@@ -984,7 +984,7 @@ ZTEST(os_mgmt_datetime_set, test_datetime_set_v1)
984984

985985
/* Process received data by removing header */
986986
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
987-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
987+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
988988

989989
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
990990
zassert_true(ok, "Expected decode to be successful");
@@ -1030,7 +1030,7 @@ ZTEST(os_mgmt_datetime_set, test_datetime_set_v1)
10301030

10311031
/* Process received data by removing header */
10321032
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1033-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1033+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
10341034

10351035
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
10361036
zassert_true(ok, "Expected decode to be successful");
@@ -1098,7 +1098,7 @@ ZTEST(os_mgmt_datetime_set, test_datetime_set_v2)
10981098

10991099
/* Process received data by removing header */
11001100
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1101-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1101+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
11021102

11031103
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
11041104
zassert_true(ok, "Expected decode to be successful");
@@ -1144,7 +1144,7 @@ ZTEST(os_mgmt_datetime_set, test_datetime_set_v2)
11441144

11451145
/* Process received data by removing header */
11461146
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1147-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1147+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
11481148

11491149
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
11501150
zassert_true(ok, "Expected decode to be successful");
@@ -1225,7 +1225,7 @@ ZTEST(os_mgmt_datetime_hook, test_datetime_set_valid_hook_v1)
12251225

12261226
/* Process received data by removing header */
12271227
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1228-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1228+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
12291229

12301230
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
12311231
zassert_true(ok, "Expected decode to be successful");
@@ -1287,7 +1287,7 @@ ZTEST(os_mgmt_datetime_hook, test_datetime_set_valid_hook_v1)
12871287

12881288
/* Process received data by removing header */
12891289
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1290-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1290+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
12911291

12921292
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
12931293
zassert_true(ok, "Expected decode to be successful");
@@ -1357,7 +1357,7 @@ ZTEST(os_mgmt_datetime_hook, test_datetime_set_valid_hook_v2)
13571357

13581358
/* Process received data by removing header */
13591359
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1360-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1360+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
13611361

13621362
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
13631363
zassert_true(ok, "Expected decode to be successful");
@@ -1418,7 +1418,7 @@ ZTEST(os_mgmt_datetime_hook, test_datetime_set_valid_hook_v2)
14181418

14191419
/* Process received data by removing header */
14201420
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
1421-
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1);
1421+
zcbor_new_decode_state(zsd, 4, nb->data, nb->len, 1, NULL, 0);
14221422

14231423
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
14241424
zassert_true(ok, "Expected decode to be successful");

Diff for: tests/subsys/mgmt/mcumgr/os_mgmt_datetime/src/smp_test_util.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ bool create_mcumgr_datetime_set_packet_str(zcbor_state_t *zse, bool version2, co
4949
uint8_t *buffer, uint8_t *output_buffer,
5050
uint16_t *buffer_size)
5151
{
52-
bool ok = zcbor_map_start_encode(zse, 2) &&
53-
zcbor_tstr_put_lit(zse, "datetime") &&
54-
zcbor_tstr_put_term(zse, data) &&
52+
bool ok = zcbor_map_start_encode(zse, 2) &&
53+
zcbor_tstr_put_lit(zse, "datetime") &&
54+
zcbor_tstr_put_term(zse, data, CONFIG_ZCBOR_MAX_STR_LEN) &&
5555
zcbor_map_end_encode(zse, 2);
5656

5757
*buffer_size = (zse->payload_mut - buffer);

Diff for: tests/subsys/mgmt/mcumgr/os_mgmt_info/src/build_date.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ZTEST(os_mgmt_info_build_date, test_info_build_date_1_build_date)
121121

122122
/* Process received data by removing header */
123123
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
124-
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1);
124+
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1, NULL, 0);
125125

126126
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
127127

@@ -197,7 +197,7 @@ ZTEST(os_mgmt_info_build_date, test_info_build_date_2_all)
197197

198198
/* Process received data by removing header */
199199
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
200-
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1);
200+
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1, NULL, 0);
201201

202202
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
203203

Diff for: tests/subsys/mgmt/mcumgr/os_mgmt_info/src/limited.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ZTEST(os_mgmt_info_limited, test_info_1_kernel_name)
8181

8282
/* Process received data by removing header */
8383
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
84-
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1);
84+
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1, NULL, 0);
8585

8686
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
8787

@@ -147,15 +147,15 @@ ZTEST(os_mgmt_info_limited, test_info_2_all)
147147

148148
/* Process received data by removing header */
149149
(void)net_buf_pull(nb, sizeof(struct smp_hdr));
150-
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1);
150+
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1, NULL, 0);
151151

152152
/* Ensure only an error is received */
153153
ok = zcbor_map_decode_bulk(zsd, output_decode, ARRAY_SIZE(output_decode), &decoded) == 0;
154154

155155
zassert_true(ok, "Expected decode to be successful\n");
156156
zassert_equal(decoded, 0, "Expected to receive 0 decoded zcbor element\n");
157157

158-
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1);
158+
zcbor_new_decode_state(zsd, 3, nb->data, nb->len, 1, NULL, 0);
159159
ok = zcbor_map_decode_bulk(zsd, error_decode, ARRAY_SIZE(error_decode), &decoded) == 0;
160160

161161
zassert_true(ok, "Expected decode to be successful\n");

0 commit comments

Comments
 (0)