Hi Archie, On Mon, May 3, 2021 at 3:04 AM Archie Pusaka <apusaka@xxxxxxxxxx> wrote: > > From: Archie Pusaka <apusaka@xxxxxxxxxxxx> > > There are instances where timer is removed because timeout has > occurred, yet we still remove it again by the end of the test. This > causes double removal and prints ugly messages which obscures the > real culprit. > > Reviewed-by: Sonny Sasaka <sonnysasaka@xxxxxxxxxxxx> > Reviewed-by: Yun-Hao Chung <howardchung@xxxxxxxxxxxx> > --- > > unit/test-gobex.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/unit/test-gobex.c b/unit/test-gobex.c > index 6fbfa183ec..25a3646630 100644 > --- a/unit/test-gobex.c > +++ b/unit/test-gobex.c > @@ -266,7 +266,8 @@ static void send_req(GObexPacket *req, GObexResponseFunc rsp_func, > g_main_loop_unref(mainloop); > mainloop = NULL; > > - g_source_remove(timer_id); > + if (!g_error_matches(gerr, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); That is weird way to check if the timer is active, usually the callback shall set the id to 0 and then we check it before removing, and we might want to consider consolidating this code into a function. > g_io_channel_unref(io); > g_obex_unref(obex); > > @@ -450,7 +451,8 @@ static void test_cancel_req_delay(int transport_type) > > g_assert_no_error(r.err); > > - g_source_remove(timer_id); > + if (!g_error_matches(r.err, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_io_channel_unref(io); > g_source_remove(io_id); > g_obex_unref(r.obex); > @@ -551,7 +553,8 @@ static void test_send_connect(int transport_type) > g_main_loop_unref(mainloop); > mainloop = NULL; > > - g_source_remove(timer_id); > + if (!g_error_matches(r.err, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_io_channel_unref(io); > if (!r.completed) > g_source_remove(io_id); > @@ -612,7 +615,8 @@ static void test_recv_unexpected(void) > g_main_loop_unref(mainloop); > mainloop = NULL; > > - g_source_remove(timer_id); > + if (!g_error_matches(err, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_io_channel_unref(io); > g_obex_unref(obex); > > @@ -667,7 +671,8 @@ static void test_send_on_demand(int transport_type, GObexDataProducer func) > g_main_loop_unref(mainloop); > mainloop = NULL; > > - g_source_remove(timer_id); > + if (!g_error_matches(r.err, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_io_channel_unref(io); > if (!r.completed) > g_source_remove(io_id); > @@ -748,7 +753,8 @@ static void recv_connect(int transport_type) > > g_main_loop_run(mainloop); > > - g_source_remove(timer_id); > + if (!g_error_matches(gerr, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_obex_unref(obex); > g_io_channel_unref(io); > > @@ -800,7 +806,8 @@ static void test_disconnect(void) > > g_assert_no_error(gerr); > > - g_source_remove(timer_id); > + if (!g_error_matches(gerr, TEST_ERROR, TEST_ERROR_TIMEOUT)) > + g_source_remove(timer_id); > g_io_channel_unref(io); > g_obex_unref(obex); > > -- > 2.31.1.527.g47e6f16901-goog > -- Luiz Augusto von Dentz