1515
1616static enum test_id cur_test_id ;
1717
18+ static int first_cnt ;
1819static int early_cnt ;
1920static int normal_cnt ;
2021
21- static bool event_handler_early (const struct event_header * eh )
22+ static bool event_handler_first (const struct event_header * eh )
2223{
2324 if (is_test_start_event (eh )) {
2425 struct test_start_event * event = cast_test_start_event (eh );
@@ -30,6 +31,28 @@ static bool event_handler_early(const struct event_header *eh)
3031
3132 if (is_order_event (eh )) {
3233 if (cur_test_id == TEST_SUBSCRIBER_ORDER ) {
34+ first_cnt ++ ;
35+ }
36+
37+ return false;
38+ }
39+
40+ zassert_true (false, "Event unhandled" );
41+ return false;
42+ }
43+
44+ /* Create one first listener. */
45+ EVENT_LISTENER (first , event_handler_first );
46+ EVENT_SUBSCRIBE_FIRST (first , order_event );
47+ EVENT_SUBSCRIBE_EARLY (first , test_start_event );
48+
49+
50+ static bool event_handler_early (const struct event_header * eh )
51+ {
52+ if (is_order_event (eh )) {
53+ if (cur_test_id == TEST_SUBSCRIBER_ORDER ) {
54+ zassert_equal (first_cnt , 1 , "Incorrect subscriber order"
55+ " - early before first" );
3356 early_cnt ++ ;
3457 }
3558
@@ -43,21 +66,20 @@ static bool event_handler_early(const struct event_header *eh)
4366/* Create 3 early listeners. */
4467EVENT_LISTENER (early1 , event_handler_early );
4568EVENT_SUBSCRIBE_EARLY (early1 , order_event );
46- EVENT_SUBSCRIBE_EARLY (early1 , test_start_event );
4769
4870EVENT_LISTENER (early2 , event_handler_early );
4971EVENT_SUBSCRIBE_EARLY (early2 , order_event );
50- EVENT_SUBSCRIBE_EARLY (early2 , test_start_event );
5172
5273EVENT_LISTENER (early3 , event_handler_early );
5374EVENT_SUBSCRIBE_EARLY (early3 , order_event );
54- EVENT_SUBSCRIBE_EARLY (early3 , test_start_event );
5575
5676
5777static bool event_handler_normal (const struct event_header * eh )
5878{
5979 if (is_order_event (eh )) {
6080 if (cur_test_id == TEST_SUBSCRIBER_ORDER ) {
81+ zassert_equal (first_cnt , 1 , "Incorrect subscriber order"
82+ " - normal before first" );
6183 zassert_equal (early_cnt , 3 , "Incorrect subscriber order"
6284 " - normal before early" );
6385 normal_cnt ++ ;
@@ -83,16 +105,10 @@ EVENT_SUBSCRIBE(listener3, order_event);
83105
84106static bool event_handler_final (const struct event_header * eh )
85107{
86- if (is_test_start_event (eh )) {
87- struct test_start_event * event = cast_test_start_event (eh );
88-
89- cur_test_id = event -> test_id ;
90-
91- return false;
92- }
93-
94108 if (is_order_event (eh )) {
95109 if (cur_test_id == TEST_SUBSCRIBER_ORDER ) {
110+ zassert_equal (first_cnt , 1 , "Incorrect subscriber order"
111+ " - late before first" );
96112 zassert_equal (early_cnt , 3 , "Incorrect subscriber order"
97113 " - late before early" );
98114 zassert_equal (normal_cnt , 3 ,
0 commit comments