static int clear_something (struct thread *thread) { struct work_state *ws = THREAD_ARG(thread); /* this could be like iterating through 150k of route_table * or worse, iterating through a list of peers, to bgp_stop them with * each having 150k route tables to process... */ while (ws->i < ITERS_MAX) { slow_func(ws->vty, ws->str, ws->i); ws->i++; if (thread_should_yield(thread)) { thread_add_background(master, clear_something, ws, 0); return 0; } } /* All done! */ XFREE (MTYPE_TMP, ws->str); XFREE (MTYPE_TMP, ws); return 0; }
TEST_F(QuickTest, SimpleTest) { EXPECT_EQ(1, slow_func(1)); EXPECT_EQ(44, slow_func(44)); }