int main(int argc, char **argv) { int suite = ALL_SUITES, tcase = ALL_TESTS; srandom(getpid()); clm_init(); if (argc > 1) { suite = atoi(argv[1]); } if (argc > 2) { tcase = atoi(argv[2]); } if (suite == 0) { test_list(); return 0; } return test_run(suite, tcase); }
SaErrorT saClmInitialize(SaClmHandleT *clmHandle, const SaClmCallbacksT *clmCallbacks, const SaVersionT *version) { int ret; oc_ev_t *ev_token; __clm_handle_t *hd; SaClmHandleT *hash_key; fd_set rset; struct timeval tv; SaErrorT rc; oc_ev_register(&ev_token); if ((ret = oc_ev_set_callback(ev_token, OC_EV_MEMB_CLASS , ccm_events, NULL)) != 0) { if (ret == ENOMEM){ rc = SA_ERR_NO_MEMORY; goto err_nomem_exit; } else{ assert(0); /* Never runs here */ } } /* We must call it to get non-quorum partition info */ oc_ev_special(ev_token, OC_EV_MEMB_CLASS, 0); clm_init(); hash_key = (SaClmHandleT *)g_malloc(sizeof(SaClmHandleT)); if (!hash_key){ rc = SA_ERR_NO_MEMORY; goto err_nomem_exit; } hd = (__clm_handle_t *)g_malloc(sizeof(__clm_handle_t)); if (!hd){ g_free(hash_key); rc = SA_ERR_NO_MEMORY; goto err_nomem_exit; } *clmHandle = __handle_counter++; *hash_key = *clmHandle; hd->ev_token = ev_token; hd->callbacks = *clmCallbacks; hd->trackflags = CLM_TRACK_STOP; cl_log(LOG_INFO, "g_hash_table_insert hd = [%p]", hd); g_hash_table_insert(__handle_hash, hash_key, hd); if ((ret = oc_ev_activate(hd->ev_token, &hd->fd)) != 0) { cl_log(LOG_ERR, "oc_ev_activate error [%d]", ret); rc = SA_ERR_LIBRARY; goto err_lib_exit; } /* Prepare information for saClmClusterNodeGet() series calls */ while (!__ccm_data) { FD_ZERO(&rset); FD_SET(hd->fd, &rset); tv.tv_sec = 2; tv.tv_usec = 0; if ((ret = select(hd->fd + 1, &rset, NULL, NULL, &tv)) == -1) { cl_log(LOG_ERR, "%s: select error [%d]" , __FUNCTION__, ret); rc = SA_ERR_LIBRARY; goto err_lib_exit; } else if (ret == 0) { cl_log(LOG_WARNING, "%s: select timeout", __FUNCTION__); rc = SA_ERR_TIMEOUT; goto err_lib_exit; } if ((ret = oc_ev_handle_event(hd->ev_token) != 0)) { cl_log(LOG_ERR, "%s: oc_ev_handle_event error [%d]" , __FUNCTION__, ret); rc = SA_ERR_LIBRARY; goto err_lib_exit; } } return SA_OK; err_lib_exit: g_hash_table_remove(__handle_hash, hash_key); g_free(hd); g_free(hash_key); err_nomem_exit: oc_ev_unregister(ev_token); return rc; }