int test_cb_service_check_processed() { assert(OK == neb_register_callback(NEBCALLBACK_SERVICE_CHECK_DATA, test_nebmodule->module_handle, 0, _test_cb)); event_broker_options = BROKER_EVERYTHING; check_result *cr = check_result_new(0, "Some output"); host *host = host_new("MyHost"); service *service = service_new(host, "MyService"); nebstruct_service_check_data *ds = NULL; assert(OK == handle_async_service_check_result(service, cr)); ds = (nebstruct_service_check_data *) received_callback_data[NEBCALLBACK_SERVICE_CHECK_DATA][NEBTYPE_SERVICECHECK_PROCESSED]; ok(ds != NULL, "SERVICE_CHECK_DATA callback invoked"); ok(ds->type == NEBTYPE_SERVICECHECK_PROCESSED, "nebstruct has expected type") || diag("Type was %d", ds->type); ok(!strcmp(ds->host_name, "MyHost"), "nebstruct has expected hostname"); ok(!strcmp(ds->service_description, "MyService"), "nebstruct has expected service description"); ok(ds->attr == NEBATTR_NONE, "nebstruct has no attributes set"); clear_callback_data(); /* test stalking */ /* a change in plugin output should result in the NEBATTR_CHECK_ALERT attribute being set * for a service, for which stalking is enabled * * This output change is emulated implicitly by our fixture where service->plugin_output * is "Initial state" and cr->output is "Some output" * */ service->stalking_options |= ~0; /*stalk all the states*/ assert(OK == handle_async_service_check_result(service, cr)); ds = (nebstruct_service_check_data *) received_callback_data[NEBCALLBACK_SERVICE_CHECK_DATA][NEBTYPE_SERVICECHECK_PROCESSED]; ok(ds->attr == NEBATTR_CHECK_ALERT, "nebstruct has NEBATTR_CHECK_ALERT attribute set"); clear_callback_data(); check_result_destroy(cr); service_destroy(service); host_destroy(host); return 0; }
static script_t * script_new(GSocketConnection *connection) { script_t *obj = NULL; g_assert(connection); obj = g_new0(script_t, 1); g_assert(obj); obj->service = service_new(connection); g_assert(obj->service); return obj; }
static bool server_bind(Server* server, DsmeDbusMethod method, const char* service, const char* interface, const char* name, const char* rules) { bool bound = false; Service* s; if (!(s = g_datalist_get_data(&server->services, service))) { if ((s = service_new(service))) { g_datalist_set_data(&server->services, service, s); } } if (s) { service_bind(s, method, interface, name, rules); bound = true; } return bound; }
Service *servicertp_new(int serviceid) { Service *this = service_new(UDP); return this; }