Skip to content

Commit f6f2b52

Browse files
rodrigopexkartben
authored andcommitted
tests: zbus: Adjust runtime observers tests
Reverse the changes the affected API and add test to the new dynamic and static variations. Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
1 parent 6ae9a98 commit f6f2b52

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

tests/subsys/zbus/runtime_observers_registration/testcase.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ tests:
22
message_bus.zbus.runtime_obs_reg.add_and_remove_observers:
33
tags: zbus
44
integration_platforms:
5-
- native_sim
5+
- qemu_x86
6+
extra_configs:
7+
- CONFIG_HEAP_MEM_POOL_SIZE=2048
8+
message_bus.zbus.runtime_obs_reg.add_and_remove_observers_static_memory:
9+
tags: zbus
10+
integration_platforms:
11+
- qemu_x86
12+
extra_configs:
13+
- CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_POOL_SIZE=6

tests/subsys/zbus/unittests/src/main.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ static struct action_msg ga;
137137

138138
static void isr_handler(const void *operation)
139139
{
140-
static struct zbus_observer_node fast_node, aux_node;
141-
enum operation *op = (enum operation *)operation;
140+
const enum operation *op = (const enum operation *)operation;
142141

143142
switch (*op) {
144143
case PUB_ISR_INVAL:
@@ -157,7 +156,7 @@ static void isr_handler(const void *operation)
157156
isr_return = zbus_chan_finish(NULL);
158157
break;
159158
case ADD_OBS_ISR_INVAL:
160-
isr_return = zbus_chan_add_obs(&aux2_chan, &fast_lis, &fast_node, K_MSEC(200));
159+
isr_return = zbus_chan_add_obs(&aux2_chan, &fast_lis, K_MSEC(200));
161160
break;
162161
case RM_OBS_ISR_INVAL:
163162
isr_return = zbus_chan_rm_obs(&aux2_chan, &fast_lis, K_MSEC(200));
@@ -178,7 +177,7 @@ static void isr_handler(const void *operation)
178177
isr_return = zbus_chan_finish(&aux2_chan);
179178
break;
180179
case ADD_OBS_ISR:
181-
isr_return = zbus_chan_add_obs(&aux2_chan, NULL, &aux_node, K_MSEC(200));
180+
isr_return = zbus_chan_add_obs(&aux2_chan, NULL, K_MSEC(200));
182181
break;
183182
case RM_OBS_ISR:
184183
isr_return = zbus_chan_rm_obs(&aux2_chan, NULL, K_MSEC(200));
@@ -245,7 +244,6 @@ const STRUCT_SECTION_ITERABLE(zbus_observer, invalid_obs) = {
245244

246245
ZTEST(basic, test_specification_based__zbus_chan)
247246
{
248-
static struct zbus_observer_node node;
249247
struct action_msg a = {0};
250248

251249
/* Trying invalid parameters */
@@ -271,11 +269,9 @@ ZTEST(basic, test_specification_based__zbus_chan)
271269

272270
zassert_equal(-EFAULT, zbus_chan_finish(NULL), "It must be -EFAULT");
273271

274-
zassert_equal(-EFAULT, zbus_chan_add_obs(NULL, &sub1, &node, K_MSEC(200)), NULL);
272+
zassert_equal(-EFAULT, zbus_chan_add_obs(NULL, &sub1, K_MSEC(200)), NULL);
275273

276-
zassert_equal(-EFAULT, zbus_chan_add_obs(&aux2_chan, NULL, &node, K_MSEC(200)), NULL);
277-
278-
zassert_equal(-EFAULT, zbus_chan_add_obs(&aux2_chan, &sub1, NULL, K_MSEC(200)), NULL);
274+
zassert_equal(-EFAULT, zbus_chan_add_obs(&aux2_chan, NULL, K_MSEC(200)), NULL);
279275

280276
zassert_equal(-EFAULT, zbus_chan_rm_obs(NULL, &sub1, K_MSEC(200)), NULL);
281277

@@ -330,7 +326,7 @@ ZTEST(basic, test_specification_based__zbus_chan)
330326

331327
k_msleep(100);
332328

333-
zassert_equal(0, zbus_chan_add_obs(&stuck_chan, &sub1, &node, K_MSEC(200)), NULL);
329+
zassert_equal(0, zbus_chan_add_obs(&stuck_chan, &sub1, K_MSEC(200)), NULL);
334330

335331
zassert_equal(0, zbus_chan_notify(&stuck_chan, K_MSEC(200)), "It must finish correctly");
336332

@@ -603,7 +599,6 @@ ZTEST(basic, test_hard_channel)
603599

604600
ZTEST(basic, test_specification_based__zbus_obs_set_enable)
605601
{
606-
struct zbus_observer_node node;
607602
bool enable;
608603

609604
count_fast = 0;
@@ -622,7 +617,7 @@ ZTEST(basic, test_specification_based__zbus_obs_set_enable)
622617
zbus_obs_is_enabled(&rt_fast_lis, &enable);
623618
zassert_equal(false, enable);
624619

625-
zassert_equal(0, zbus_chan_add_obs(&aux1_chan, &rt_fast_lis, &node, K_MSEC(200)), NULL);
620+
zassert_equal(0, zbus_chan_add_obs(&aux1_chan, &rt_fast_lis, K_MSEC(200)), NULL);
626621

627622
zassert_equal(0, zbus_obs_set_enable(&fast_lis, false),
628623
"Must be zero. The observer must be disabled");

0 commit comments

Comments
 (0)