static void identify_test(void) { WsXmlDocH response; static int i = 0; char *xp = NULL; wsmc_reinit_conn(cl); options = wsmc_options_init(); response = wsmc_action_identify(cl, options); CU_ASSERT_TRUE(wsmc_get_response_code(cl) == tests[i].final_status); CU_ASSERT_PTR_NOT_NULL(response); if (response == NULL) { goto RETURN; } if (tests[i].value1 != NULL) { xp = ws_xml_get_xpath_value(response, tests[i].expr1); CU_ASSERT_PTR_NOT_NULL(xp); if (xp) { CU_ASSERT_STRING_EQUAL(xp, tests[i].value1 ); } } RETURN: if (response) { ws_xml_destroy_doc(response); } u_free(xp); wsmc_options_destroy(options); i++; }
int wsman_send_request(WsManClient * cl, WsXmlDocH request) { int ret = 0; #ifdef BENCHMARK struct timeval tv0, tv1; long long t0, t1; #endif if (wsmc_lock(cl) != 0 ) { error("Client busy"); return 1; } wsmc_reinit_conn(cl); #ifdef BENCHMARK gettimeofday(&tv0, NULL); #endif wsmc_handler(cl, request, NULL); if (cl->last_error != WS_LASTERR_OK) { warning("Couldn't send request to client: %s\n", cl->fault_string); ret = 1; } #ifdef BENCHMARK gettimeofday(&tv1, NULL); t0 = tv0.tv_sec * 10000000 + tv0.tv_usec; t1 = tv1.tv_sec * 10000000 + tv1.tv_usec; transfer_time += t1 - t0; #endif wsmc_unlock(cl); return ret; }
int wsman_send_request(WsManClient * cl, WsXmlDocH request) { #ifdef BENCHMARK struct timeval tv0, tv1; long long t0, t1; #endif if ((g_dump_wsman_data) && (g_wsman_dumpfile != NULL)) { fprintf (g_wsman_dumpfile, "\n\n--------------------------------------------\n"); ws_xml_dump_node_tree(g_wsman_dumpfile, ws_xml_get_doc_root(request)); fprintf (g_wsman_dumpfile, "\n"); } if (wsmc_lock(cl) != 0 ) { error("Client busy"); return 1; } wsmc_reinit_conn(cl); #ifdef BENCHMARK gettimeofday(&tv0, NULL); #endif wsmc_handler(cl, request, NULL); #ifdef BENCHMARK gettimeofday(&tv1, NULL); t0 = tv0.tv_sec * 10000000 + tv0.tv_usec; t1 = tv1.tv_sec * 10000000 + tv1.tv_usec; transfer_time += t1 - t0; #endif wsmc_unlock(cl); return 0; }
static void enumeration_test(void) { char *enumContext = NULL; static int i = 0; char *selectors = NULL; wsmc_reinit_conn(cl); options = wsmc_options_init(); options->flags = tests[i].flags; if (tests[i].selectors) { selectors = u_strdup_printf(tests[i].selectors, host, host, host); wsmc_add_selectors_from_str(options, selectors); } options->max_elements = tests[i].max_elements; WsXmlDocH enum_response = wsmc_action_enumerate(cl, (char *)tests[i].resource_uri, options, NULL); CU_ASSERT_TRUE(wsmc_get_response_code(cl) == tests[i].final_status); if (wsmc_get_response_code(cl) != tests[i].final_status) { if (verbose) { printf("\nExpected = %d\nReturned = %ld ", tests[i].final_status, wsmc_get_response_code(cl)); } goto RETURN; } CU_ASSERT_PTR_NOT_NULL(enum_response); if (enum_response) { enumContext = wsmc_get_enum_context(enum_response); } else { goto RETURN; } check_response_header(enum_response, wsmc_get_response_code(cl), ENUM_ACTION_ENUMERATERESPONSE); //if (i==11) ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(enum_response)); handle_filters(enum_response, filters); handle_filters(enum_response, tests[i].common_filters); handle_filters(enum_response, tests[i].filters); RETURN: u_free(selectors); if (enumContext) { wsmc_action_release(cl, (char *)tests[i].resource_uri, options, enumContext); } if (enum_response) { ws_xml_destroy_doc(enum_response); } wsmc_options_destroy(options); i++; // decrease executed test number }