Skip to content

Commit 6f4f72d

Browse files
nordic-krchkartben
authored andcommitted
tests: subsys: Fix zassert string
Fix wrong parameter used in zassert macros. Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent a068293 commit 6f4f72d

File tree

35 files changed

+339
-345
lines changed

35 files changed

+339
-345
lines changed

tests/modules/thrift/ThriftTest/src/client.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ZTEST(thrift, test_struct)
9999
Xtruct response_struct;
100100
context.client->testStruct(response_struct, request_struct);
101101

102-
zassert_equal(response_struct, request_struct, NULL);
102+
zassert_equal(response_struct, request_struct);
103103
}
104104

105105
ZTEST(thrift, test_nested_struct)
@@ -111,7 +111,7 @@ ZTEST(thrift, test_nested_struct)
111111
Xtruct2 response_struct;
112112
context.client->testNest(response_struct, request_struct);
113113

114-
zassert_equal(response_struct, request_struct, NULL);
114+
zassert_equal(response_struct, request_struct);
115115
}
116116

117117
ZTEST(thrift, test_map)
@@ -150,7 +150,8 @@ ZTEST(thrift, test_list)
150150
{
151151
vector<int32_t> response_list;
152152
context.client->testList(response_list, vector<int32_t>());
153-
zassert_true(response_list.empty(), "Unexpected list size: %llu", response_list.size());
153+
zassert_true(response_list.empty(), "Unexpected list size: %u",
154+
(uint32_t)response_list.size());
154155

155156
static const vector<int32_t> request_list = {-2, -1, 0, 1, 2};
156157

@@ -162,13 +163,13 @@ ZTEST(thrift, test_list)
162163
ZTEST(thrift, test_enum)
163164
{
164165
Numberz::type response = context.client->testEnum(Numberz::ONE);
165-
zassert_equal(response, Numberz::ONE, NULL);
166+
zassert_equal(response, Numberz::ONE);
166167

167168
response = context.client->testEnum(Numberz::TWO);
168-
zassert_equal(response, Numberz::TWO, NULL);
169+
zassert_equal(response, Numberz::TWO);
169170

170171
response = context.client->testEnum(Numberz::EIGHT);
171-
zassert_equal(response, Numberz::EIGHT, NULL);
172+
zassert_equal(response, Numberz::EIGHT);
172173
}
173174

174175
ZTEST(thrift, test_typedef)
@@ -182,15 +183,15 @@ ZTEST(thrift, test_nested_map)
182183
map<int32_t, map<int32_t, int32_t>> mm;
183184
context.client->testMapMap(mm, 1);
184185

185-
zassert_equal(mm.size(), 2, NULL);
186-
zassert_equal(mm[-4][-4], -4, NULL);
187-
zassert_equal(mm[-4][-3], -3, NULL);
188-
zassert_equal(mm[-4][-2], -2, NULL);
189-
zassert_equal(mm[-4][-1], -1, NULL);
190-
zassert_equal(mm[4][4], 4, NULL);
191-
zassert_equal(mm[4][3], 3, NULL);
192-
zassert_equal(mm[4][2], 2, NULL);
193-
zassert_equal(mm[4][1], 1, NULL);
186+
zassert_equal(mm.size(), 2);
187+
zassert_equal(mm[-4][-4], -4);
188+
zassert_equal(mm[-4][-3], -3);
189+
zassert_equal(mm[-4][-2], -2);
190+
zassert_equal(mm[-4][-1], -1);
191+
zassert_equal(mm[4][4], 4);
192+
zassert_equal(mm[4][3], 3);
193+
zassert_equal(mm[4][2], 2);
194+
zassert_equal(mm[4][1], 1);
194195
}
195196

196197
ZTEST(thrift, test_exception)

tests/subsys/debug/cs_trace_defmt/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ static uint8_t cb_cnt;
1313

1414
static void callback(uint32_t id, const uint8_t *data, size_t len)
1515
{
16-
zassert_equal(exp_id[cb_cnt], id, NULL);
17-
zassert_equal(len, exp_len[cb_cnt], NULL);
18-
zassert_equal(memcmp(data, exp_data[cb_cnt], len), 0, NULL);
16+
zassert_equal(exp_id[cb_cnt], id);
17+
zassert_equal(len, exp_len[cb_cnt]);
18+
zassert_equal(memcmp(data, exp_data[cb_cnt], len), 0);
1919
cb_cnt++;
2020
}
2121

tests/subsys/debug/mipi_stp_decoder/src/main.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ static void cb(enum mipi_stp_decoder_ctrl_type type, union mipi_stp_decoder_data
2020
zassert_equal(exp_type[d_cnt], type, "Expected: %d got:%d", exp_type[d_cnt], type);
2121

2222
if (exp_ts[d_cnt] == UINT64_MAX) {
23-
zassert_equal(ts, NULL, NULL);
23+
zassert_equal(ts, NULL);
2424
} else {
25-
zassert_true(ts != NULL, NULL);
25+
zassert_true(ts != NULL);
2626
zassert_equal(exp_ts[d_cnt], *ts, "exp:%llx got:%llx", exp_ts[d_cnt], *ts);
2727
}
2828

29-
zassert_equal(exp_marked[d_cnt], marked, NULL);
29+
zassert_equal(exp_marked[d_cnt], marked);
3030
zassert_equal(
31-
memcmp((uint8_t *)&exp_data[d_cnt], (uint8_t *)&data.data, exp_data_len[d_cnt]), 0,
32-
NULL);
31+
memcmp((uint8_t *)&exp_data[d_cnt], (uint8_t *)&data.data, exp_data_len[d_cnt]), 0);
3332
d_cnt++;
3433
}
3534

@@ -56,7 +55,7 @@ ZTEST(mipi_stp_decoder_test, test_chunk_null)
5655
ADD_ITEM(cnt, STP_DECODER_NULL, UINT64_MAX, false, (uint8_t)0);
5756

5857
mipi_stp_decoder_decode(data, sizeof(data));
59-
zassert_equal(cnt, d_cnt, NULL);
58+
zassert_equal(cnt, d_cnt);
6059
}
6160

6261
ZTEST(mipi_stp_decoder_test, test_chunk_major)
@@ -69,7 +68,7 @@ ZTEST(mipi_stp_decoder_test, test_chunk_major)
6968
ADD_ITEM(cnt, STP_DECODER_MAJOR, UINT64_MAX, false, (uint16_t)0x4321);
7069

7170
mipi_stp_decoder_decode(data, sizeof(data));
72-
zassert_equal(cnt, d_cnt, NULL);
71+
zassert_equal(cnt, d_cnt);
7372
}
7473

7574
ZTEST(mipi_stp_decoder_test, test_chunk_channel)

tests/subsys/fs/ext2/src/testfs_ext_specific.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void write_to_file(const char *file_path, uint32_t bytes_to_write)
6161
ret = fs_stat(file_path, &entry);
6262
zassert_equal(ret, 0, "File stat failed (ret=%d)", ret);
6363
zassert_equal(entry.size, bytes_to_write,
64-
"Wrong file size %d (expected %d)", entry.size,
64+
"Wrong file size %d (expected %d)", (uint32_t)entry.size,
6565
bytes_to_write);
6666

6767
fs_file_t_init(&file);
@@ -96,7 +96,7 @@ static void truncate_file(const char *file_path, uint32_t new_size)
9696
ret = fs_stat(file_path, &entry);
9797
zassert_equal(ret, 0, "File stat failed (ret=%d)", ret);
9898
zassert_equal(entry.size, new_size,
99-
"Wrong file size %d (expected %d)", entry.size, new_size);
99+
"Wrong file size %d (expected %d)", (uint32_t)entry.size, new_size);
100100

101101
ret = fs_seek(&file, 0, FS_SEEK_SET);
102102
zassert_equal(ret, 0, "File seek failed (ret=%d)", ret);

tests/subsys/fs/ext2/src/testfs_mount.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ void mkfs_custom_config(struct ext2_cfg *cfg)
115115
sbuf.f_bsize, sbuf.f_frsize, sbuf.f_blocks, sbuf.f_bfree);
116116

117117
zassert_equal(sbuf.f_bsize, cfg->block_size,
118-
"Wrong block size %lu (expected %zu)", sbuf.f_bsize, cfg->block_size);
118+
"Wrong block size %lu (expected %u)", sbuf.f_bsize, cfg->block_size);
119119
zassert_equal(sbuf.f_frsize, cfg->block_size,
120-
"Wrong frag size %lu (expected %zu)", sbuf.f_frsize, cfg->block_size);
120+
"Wrong frag size %lu (expected %u)", sbuf.f_frsize, cfg->block_size);
121121
zassert_equal(sbuf.f_blocks, partition_size / cfg->block_size,
122122
"Wrong block count %lu (expected %zu)",
123123
sbuf.f_blocks, partition_size / cfg->block_size);

tests/subsys/fs/fat_fs_api/src/test_fat_file_reentrant.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ static int test_reentrant_access(void)
2727
int res;
2828

2929
TC_PRINT("\nReentrant tests:\n");
30-
zassert_ok(k_sem_init(&mutex_unlocked_sem, 0, 1), NULL);
31-
zassert_ok(k_sem_init(&run_non_thread_sem, 0, 1), NULL);
30+
zassert_ok(k_sem_init(&mutex_unlocked_sem, 0, 1));
31+
zassert_ok(k_sem_init(&run_non_thread_sem, 0, 1));
3232

3333
/* Start mutex locking thread */
3434
k_tid_t tid = k_thread_create(&tlock_mutex_data, tlock_mutex_stack_area,
@@ -173,7 +173,7 @@ void tfile2_access(void *p1, void *p2, void *p3)
173173

174174
void test_fat_file_reentrant(void)
175175
{
176-
zassert_true(test_reentrant_access() == TC_PASS, NULL);
177-
zassert_true(test_reentrant_parallel_file_access() == TC_PASS, NULL);
176+
zassert_true(test_reentrant_access() == TC_PASS);
177+
zassert_true(test_reentrant_parallel_file_access() == TC_PASS);
178178
}
179179
#endif /* CONFIG_FS_FATFS_REENTRANT */

tests/subsys/llext/src/test_llext.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ ZTEST(llext, test_find_section)
521521

522522
zassert_equal(symbol_ptr, section_ptr,
523523
"symbol at %p != .data section at %p (%zd bytes in the ELF)",
524-
symbol_ptr, section_ptr, section_ofs);
524+
(void *)symbol_ptr, (void *)section_ptr, section_ofs);
525525

526526
llext_unload(&ext);
527527
}

tests/subsys/logging/log_api/src/mock_backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void process(const struct log_backend *const backend,
160160
source_id = log_source_id(source);
161161
}
162162

163-
zassert_equal(source_id, exp->source_id, "source_id:%p (exp: %d)",
163+
zassert_equal(source_id, exp->source_id, "source_id:%d (exp: %d)",
164164
source_id, exp->source_id);
165165

166166
size_t len;

tests/subsys/logging/log_cache/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ZTEST(test_log_cache, test_log_cache_basic)
103103
};
104104

105105
err = log_cache_init(&cache, &config);
106-
zassert_equal(err, 0, NULL);
106+
zassert_equal(err, 0);
107107

108108
/* Try to find id0, cache is empty */
109109
cache_get(&cache, id0.raw, &buf, false, __LINE__);

tests/subsys/logging/log_frontend_stmesp_demux/src/main.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ static void claim_packet(uint16_t exp_m_idx, uint64_t exp_ts, uint16_t exp_len,
4545
}
4646

4747
zassert_equal(packet.generic_packet->type, LOG_FRONTEND_STMESP_DEMUX_TYPE_LOG);
48-
zassert_equal(exp_ts, packet.log->timestamp, "%d: Unexpected ts %llu/%x (exp:%llu/%x)",
49-
line, packet.log->timestamp, packet.log->timestamp, exp_ts, exp_ts);
48+
zassert_equal(exp_ts, packet.log->timestamp, "%d: Unexpected ts %llu/%llx (exp:%llu/%llx)",
49+
line, (uint64_t)packet.log->timestamp, (uint64_t)packet.log->timestamp,
50+
exp_ts, exp_ts);
5051
zassert_equal(exp_m_idx, ids[packet.log->hdr.major], "%d: Unexpected major:%d (exp:%d)",
5152
line, packet.log->hdr.major, exp_m_idx);
5253
zassert_equal(exp_len, packet.log->hdr.total_len, "%d: Unexpected len:%d (exp:%d)", line,
@@ -70,8 +71,9 @@ static void claim_trace_point(uint16_t exp_m_idx, uint16_t exp_id, uint64_t exp_
7071

7172
zassert_equal(packet.generic_packet->type, LOG_FRONTEND_STMESP_DEMUX_TYPE_TRACE_POINT);
7273
zassert_equal(exp_ts, packet.trace_point->timestamp,
73-
"%d: Unexpected ts %llu/%x (exp:%llu/%x)", line,
74-
packet.trace_point->timestamp, packet.trace_point->timestamp, exp_ts, exp_ts);
74+
"%d: Unexpected ts %llu/%llx (exp:%llu/%llx)", line,
75+
(uint64_t)packet.trace_point->timestamp,
76+
(uint64_t)packet.trace_point->timestamp, exp_ts, exp_ts);
7577
zassert_equal(exp_id, packet.trace_point->id, "%d: Unexpected id:%d (exp:%d)", line,
7678
packet.trace_point->id, exp_id);
7779
zassert_equal(exp_m_idx, ids[packet.trace_point->major],
@@ -97,8 +99,10 @@ static void claim_hw_event(uint8_t exp_evt, uint64_t exp_ts, int line)
9799
union log_frontend_stmesp_demux_packet packet = log_frontend_stmesp_demux_claim();
98100

99101
zassert_equal(packet.generic_packet->type, LOG_FRONTEND_STMESP_DEMUX_TYPE_HW_EVENT);
100-
zassert_equal(exp_ts, packet.hw_event->timestamp, "%d: Unexpected ts %llu/%x (exp:%llu/%x)",
101-
line, packet.hw_event->timestamp, packet.hw_event->timestamp, exp_ts, exp_ts);
102+
zassert_equal(exp_ts, packet.hw_event->timestamp,
103+
"%d: Unexpected ts %llu/%llx (exp:%llu/%llx)",
104+
line, (uint64_t)packet.hw_event->timestamp,
105+
(uint64_t)packet.hw_event->timestamp, exp_ts, exp_ts);
102106
zassert_equal(exp_evt, packet.hw_event->evt, "%d: Unexpected id:%d (exp:%d)", line,
103107
packet.hw_event->evt, exp_evt);
104108

@@ -204,7 +208,7 @@ static void demux_init(void)
204208
int err;
205209

206210
err = log_frontend_stmesp_demux_init(&config);
207-
zassert_equal(err, 0, NULL);
211+
zassert_equal(err, 0);
208212
}
209213

210214
ZTEST(log_frontend_stmesp_demux_test, test_init)
@@ -216,11 +220,11 @@ ZTEST(log_frontend_stmesp_demux_test, test_init)
216220
int err;
217221

218222
err = log_frontend_stmesp_demux_init(&config);
219-
zassert_equal(err, -EINVAL, NULL);
223+
zassert_equal(err, -EINVAL);
220224

221225
config.m_ids_cnt = 8;
222226
err = log_frontend_stmesp_demux_init(&config);
223-
zassert_equal(err, 0, NULL);
227+
zassert_equal(err, 0);
224228
}
225229

226230
ZTEST(log_frontend_stmesp_demux_test, test_basic)
@@ -245,7 +249,7 @@ ZTEST(log_frontend_stmesp_demux_test, test_basic)
245249

246250
DEMUX_EMPTY();
247251

248-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0, NULL);
252+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0);
249253
}
250254

251255
ZTEST(log_frontend_stmesp_demux_test, test_overwrite)
@@ -260,13 +264,13 @@ ZTEST(log_frontend_stmesp_demux_test, test_overwrite)
260264
for (i = 0; i < (CONFIG_LOG_FRONTEND_STMESP_DEMUX_BUFFER_SIZE / total_wlen); i++) {
261265
write_packet(M_ID0, 1, ts + i, len, i);
262266
}
263-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0, NULL);
267+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0);
264268

265269
write_packet(M_ID0, 1, ts + i, len, i);
266270

267271
uint32_t dropped = log_frontend_stmesp_demux_get_dropped();
268272

269-
zassert_true(dropped >= 1, NULL);
273+
zassert_true(dropped >= 1);
270274

271275
for (i = dropped; i < (CONFIG_LOG_FRONTEND_STMESP_DEMUX_BUFFER_SIZE / total_wlen) + 1;
272276
i++) {
@@ -339,17 +343,17 @@ ZTEST(log_frontend_stmesp_demux_test, test_drop_too_many_active)
339343
PACKET_START(&m_id1, &c_id0, hdr.raw, ts + 2, 0);
340344
packet_data(NULL, NULL, data, 1);
341345

342-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0, NULL);
346+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0);
343347
/* Starting forth packet results in dropping. */
344348
PACKET_START(&m_id1, &c_id1, hdr.raw, ts + 3, -ENOMEM);
345-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 1, NULL);
349+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 1);
346350

347351
/* Complete first packet. */
348352
packet_data(&m_id0, &c_id0, &data[1], 3);
349353
packet_end(NULL, NULL);
350354

351355
PACKET_START(&m_id1, &c_id1, hdr.raw, ts + 3, 0);
352-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0, NULL);
356+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 0);
353357
}
354358

355359
ZTEST(log_frontend_stmesp_demux_test, test_max_utilization)
@@ -359,20 +363,20 @@ ZTEST(log_frontend_stmesp_demux_test, test_max_utilization)
359363

360364
if (!IS_ENABLED(CONFIG_LOG_FRONTEND_STMESP_DEMUX_MAX_UTILIZATION)) {
361365
utilization = log_frontend_stmesp_demux_max_utilization();
362-
zassert_equal(utilization, -ENOTSUP, NULL);
366+
zassert_equal(utilization, -ENOTSUP);
363367
return;
364368
}
365369

366370
demux_init();
367371
utilization = log_frontend_stmesp_demux_max_utilization();
368-
zassert_equal(utilization, 0, NULL);
372+
zassert_equal(utilization, 0);
369373

370374
write_packet(M_ID0, 0, 1, len, 1);
371375
utilization = log_frontend_stmesp_demux_max_utilization();
372376

373377
int exp_utilization = TOTAL_LEN(len);
374378

375-
zassert_equal(utilization, exp_utilization, NULL);
379+
zassert_equal(utilization, exp_utilization);
376380
}
377381

378382
ZTEST(log_frontend_stmesp_demux_test, test_trace_point)
@@ -465,7 +469,7 @@ ZTEST(log_frontend_stmesp_demux_test, test_reset)
465469
packet_end(NULL, NULL);
466470

467471
log_frontend_stmesp_demux_reset();
468-
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 2, NULL);
472+
zassert_equal(log_frontend_stmesp_demux_get_dropped(), 2);
469473

470474
CLAIM_PACKET(M_ID1, ts + 2, len, 1);
471475
DEMUX_EMPTY();

0 commit comments

Comments
 (0)