@@ -179,8 +179,8 @@ void on_drop(void *context) {
179179 _context_notify (c , DROP );
180180}
181181
182- void test_matching_listener_publisher (bool background ) {
183- printf ("test_matching_listener_publisher: background=%d\n" , background );
182+ void test_matching_listener_publisher (bool background , bool history ) {
183+ printf ("test_matching_listener_publisher: background=%d, history=%d \n" , background , history );
184184 context_t context = {0 };
185185 _context_init (& context );
186186
@@ -212,22 +212,36 @@ void test_matching_listener_publisher(bool background) {
212212 z_closure_matching_status (& closure , on_receive , on_drop , (void * )(& context ));
213213
214214 z_owned_matching_listener_t matching_listener ;
215- if (background ) {
216- assert_ok (z_publisher_declare_background_matching_listener (z_publisher_loan (& pub ),
217- z_closure_matching_status_move (& closure )));
218- } else {
219- assert_ok (z_publisher_declare_matching_listener (z_publisher_loan (& pub ), & matching_listener ,
220- z_closure_matching_status_move (& closure )));
221- }
222215 z_owned_subscriber_t sub , sub2 ;
223216 z_owned_closure_sample_t callback , callback2 ;
224217 z_closure_sample (& callback , NULL , NULL , NULL );
225- assert_ok (z_declare_subscriber (z_session_loan (& s2 ), & sub , z_view_keyexpr_loan (& k_pub ),
226- z_closure_sample_move (& callback ), NULL ));
218+ z_closure_sample (& callback2 , NULL , NULL , NULL );
219+
220+ if (history ) {
221+ assert_ok (z_declare_subscriber (z_session_loan (& s2 ), & sub , z_view_keyexpr_loan (& k_pub ),
222+ z_closure_sample_move (& callback ), NULL ));
223+ z_sleep_s (3 );
224+ if (background ) {
225+ assert_ok (z_publisher_declare_background_matching_listener (z_publisher_loan (& pub ),
226+ z_closure_matching_status_move (& closure )));
227+ } else {
228+ assert_ok (z_publisher_declare_matching_listener (z_publisher_loan (& pub ), & matching_listener ,
229+ z_closure_matching_status_move (& closure )));
230+ }
231+ } else {
232+ if (background ) {
233+ assert_ok (z_publisher_declare_background_matching_listener (z_publisher_loan (& pub ),
234+ z_closure_matching_status_move (& closure )));
235+ } else {
236+ assert_ok (z_publisher_declare_matching_listener (z_publisher_loan (& pub ), & matching_listener ,
237+ z_closure_matching_status_move (& closure )));
238+ }
239+ assert_ok (z_declare_subscriber (z_session_loan (& s2 ), & sub , z_view_keyexpr_loan (& k_pub ),
240+ z_closure_sample_move (& callback ), NULL ));
241+ }
227242
228243 assert (_context_wait (& context , MATCH , DEFAULT_TIMEOUT_S ));
229244
230- z_closure_sample (& callback2 , NULL , NULL , NULL );
231245 assert_ok (z_declare_subscriber (z_session_loan (& s2 ), & sub2 , z_view_keyexpr_loan (& k_sub ),
232246 z_closure_sample_move (& callback2 ), NULL ));
233247 z_sleep_s (1 );
@@ -747,8 +761,10 @@ static void test_matching_status_querier_locality(z_locality_t locality, bool cr
747761int main (int argc , char * * argv ) {
748762 (void )argc ;
749763 (void )argv ;
750- test_matching_listener_publisher (true);
751- test_matching_listener_publisher (false);
764+ test_matching_listener_publisher (true, false);
765+ test_matching_listener_publisher (false, false);
766+ test_matching_listener_publisher (true, true);
767+ test_matching_listener_publisher (false, true);
752768 test_matching_status_publisher ();
753769
754770 test_matching_listener_querier (false, false);
0 commit comments