@@ -21,7 +21,7 @@ static int monitor_handler(sd_device_monitor *m, sd_device *d, void *userdata) {
2121 assert_se (sd_device_get_syspath (d , & s ) >= 0 );
2222 assert_se (streq (s , syspath ));
2323
24- return sd_event_exit (sd_device_monitor_get_event (m ), 0 );
24+ return sd_event_exit (sd_device_monitor_get_event (m ), 100 );
2525}
2626
2727static int test_receive_device_fail (void ) {
@@ -89,7 +89,7 @@ static void test_send_receive_one(sd_device *device, bool subsystem_filter, bool
8989 assert_se (sd_device_monitor_filter_update (monitor_client ) >= 0 );
9090
9191 assert_se (device_monitor_send_device (monitor_server , monitor_client , device ) >= 0 );
92- assert_se (sd_event_loop (sd_device_monitor_get_event (monitor_client )) == 0 );
92+ assert_se (sd_event_loop (sd_device_monitor_get_event (monitor_client )) == 100 );
9393}
9494
9595static void test_subsystem_filter (sd_device * device ) {
@@ -125,7 +125,36 @@ static void test_subsystem_filter(sd_device *device) {
125125
126126 log_info ("Sending device subsystem:%s syspath:%s" , subsystem , syspath );
127127 assert_se (device_monitor_send_device (monitor_server , monitor_client , device ) >= 0 );
128- assert_se (sd_event_loop (sd_device_monitor_get_event (monitor_client )) == 0 );
128+ assert_se (sd_event_loop (sd_device_monitor_get_event (monitor_client )) == 100 );
129+ }
130+
131+ static void test_sd_device_monitor_filter_remove (sd_device * device ) {
132+ _cleanup_ (sd_device_monitor_unrefp ) sd_device_monitor * monitor_server = NULL , * monitor_client = NULL ;
133+ const char * syspath ;
134+
135+ log_device_info (device , "/* %s */" , __func__ );
136+
137+ assert_se (sd_device_get_syspath (device , & syspath ) >= 0 );
138+
139+ assert_se (device_monitor_new_full (& monitor_server , MONITOR_GROUP_NONE , -1 ) >= 0 );
140+ assert_se (sd_device_monitor_start (monitor_server , NULL , NULL ) >= 0 );
141+ assert_se (sd_event_source_set_description (sd_device_monitor_get_event_source (monitor_server ), "sender" ) >= 0 );
142+
143+ assert_se (device_monitor_new_full (& monitor_client , MONITOR_GROUP_NONE , -1 ) >= 0 );
144+ assert_se (device_monitor_allow_unicast_sender (monitor_client , monitor_server ) >= 0 );
145+ assert_se (sd_device_monitor_start (monitor_client , monitor_handler , (void * ) syspath ) >= 0 );
146+ assert_se (sd_event_source_set_description (sd_device_monitor_get_event_source (monitor_client ), "receiver" ) >= 0 );
147+
148+ assert_se (sd_device_monitor_filter_add_match_subsystem_devtype (monitor_client , "hoge" , NULL ) >= 0 );
149+ assert_se (sd_device_monitor_filter_update (monitor_client ) >= 0 );
150+
151+ assert_se (device_monitor_send_device (monitor_server , monitor_client , device ) >= 0 );
152+ assert_se (sd_event_run (sd_device_monitor_get_event (monitor_client ), 0 ) >= 0 );
153+
154+ assert_se (sd_device_monitor_filter_remove (monitor_client ) >= 0 );
155+
156+ assert_se (device_monitor_send_device (monitor_server , monitor_client , device ) >= 0 );
157+ assert_se (sd_event_loop (sd_device_monitor_get_event (monitor_client )) == 100 );
129158}
130159
131160int main (int argc , char * argv []) {
@@ -156,6 +185,7 @@ int main(int argc, char *argv[]) {
156185 test_send_receive_one (loopback , true, true, true);
157186
158187 test_subsystem_filter (loopback );
188+ test_sd_device_monitor_filter_remove (loopback );
159189
160190 r = sd_device_new_from_subsystem_sysname (& sda , "block" , "sda" );
161191 if (r < 0 ) {
0 commit comments