void test_cb_destroy () { cb_info_t *cb; cb = cb_create (&watch_list, "abc", "/test", 1, 0); cb_destroy (cb); CU_ASSERT (g_list_length (watch_list) == 1); cb_release (cb); CU_ASSERT (g_list_length (watch_list) == 0); }
void ir_init(void) { if (icData.init == _TRUE) return; icData.init = _TRUE; tim_init(); irTimers.icTimerId = tim_getSpecificTimer(TIM_IC, ir_icSrv, ir_ovfSrv, IR_IC_TIMER); irTimers.ocTimerId = tim_getTimer(TIM_OC, ir_ocSrv, NULL); tim_enableOvfInterrupts(irTimers.icTimerId); cBuffer = cb_create(irBuffer, BUFF_LENGTH); commandFifo = cb_create(commandBuffer, BUFF_LENGTH); resetTransmission(); return; }
static bool match_perf_test (PERF_TEST_INDEX index) { bool ret = false; char path[128]; char guid[128]; cb_info_t *cb; uint64_t start; int i; cb_init (); for (i = 0; i < TEST_CB_MAX_ENTRIES; i++) { sprintf (path, "/database/test%d/test%d", i, i); sprintf (guid, "%zX", (size_t)g_str_hash (path)); cb = cb_create (&watch_list, guid, path, 1, 0); cb_release (cb); } CU_ASSERT (g_list_length (watch_list) == TEST_CB_MAX_ENTRIES); start = get_time_us (); for (i = 0; i < TEST_CB_MAX_ITERATIONS; i++) { GList *matches; int test = index == INDEX_FIRST ? 0 : (index == INDEX_LAST ? (TEST_CB_MAX_ENTRIES - 1) : random () % TEST_CB_MAX_ENTRIES); sprintf (path, "/database/test%d/test%d", test, test); matches = cb_match (&watch_list, path, CB_MATCH_EXACT|CB_MATCH_WILD|CB_MATCH_CHILD); if (g_list_length (matches) != 1) goto exit; g_list_free_full (matches, (GDestroyNotify) cb_release); } printf ("%"PRIu64"us ... ", (get_time_us () - start) / TEST_CB_MAX_ITERATIONS); ret = true; exit: g_list_foreach (watch_list, cb_free, NULL); CU_ASSERT (g_list_length (watch_list) == 0); watch_list = NULL; cb_shutdown (); return ret; }