diff options
| author | Vadim Revyakin <vadimr@intel.com> | 2006-11-29 12:59:15 +0000 |
|---|---|---|
| committer | Vadim Revyakin <vadimr@intel.com> | 2006-11-29 12:59:15 +0000 |
| commit | 36f9a3ac075bf0dd60079861a23b1cc5779ee76c (patch) | |
| tree | b4405ea2e264057b7b14ad90cecfb0b5e685643b | |
| parent | ca13d8a5f92ea6e2c92fb8ba57e3d3436451ef0c (diff) | |
| download | wsmancli-36f9a3ac075bf0dd60079861a23b1cc5779ee76c.tar.gz wsmancli-36f9a3ac075bf0dd60079861a23b1cc5779ee76c.tar.xz wsmancli-36f9a3ac075bf0dd60079861a23b1cc5779ee76c.zip | |
Test development
| -rw-r--r-- | tests/cunit/common.c | 38 | ||||
| -rw-r--r-- | tests/cunit/common.h | 2 | ||||
| -rw-r--r-- | tests/cunit/enumeration.c | 315 |
3 files changed, 216 insertions, 139 deletions
diff --git a/tests/cunit/common.c b/tests/cunit/common.c index 7c6e3b4..8887c02 100644 --- a/tests/cunit/common.c +++ b/tests/cunit/common.c @@ -76,3 +76,41 @@ void check_response_header(WsXmlDocH doc, long resp_code, char *action) { CU_ASSERT_PTR_NOT_NULL(xp); u_free(xp); } + + + +void handle_filters(WsXmlDocH doc, char *f[]) +{ + int j; + char *xp = NULL; + + if (f == NULL) { + return; + } + for (j = 0; f[j] != NULL && f[j + 1] != NULL; j += 2) { + if (f[j] == NULL) { + continue; + } + char *val; + u_free(xp); + xp = ws_xml_get_xpath_value(doc, f[j]); + CU_ASSERT_PTR_NOT_NULL(xp); + if (xp == NULL) { + if (verbose) { + printf("\n No Xpath: %s ", f[j]); + } + continue; + } + if (f[j + 1]) { + val = u_strdup_printf(f[j + 1], host); + CU_ASSERT_STRING_EQUAL(xp, val); + if (verbose && strcmp(xp, val)) { + printf("\nExpected: %s\nReturned: %s ", val, xp); + } + u_free(val); + } + } +} + + + diff --git a/tests/cunit/common.h b/tests/cunit/common.h index d6e50f8..d0ce0ab 100644 --- a/tests/cunit/common.h +++ b/tests/cunit/common.h @@ -61,6 +61,6 @@ int add_invoke_tests(CU_pSuite ps); int add_pull_tests(CU_pSuite ps); void check_response_header(WsXmlDocH doc, long resp_code, char *action); - +void handle_filters(WsXmlDocH doc, char *f[]); #endif diff --git a/tests/cunit/enumeration.c b/tests/cunit/enumeration.c index 9126b7e..bf94faf 100644 --- a/tests/cunit/enumeration.c +++ b/tests/cunit/enumeration.c @@ -63,7 +63,9 @@ static char *filters1[] = { static char *filters2[] = { - "/s:Envelope/s:Body/wsen:EnumerateResponse/wsman:Items[1]/wsa:EndpointReference/wsa:Address", + "/s:Envelope/s:Body/wsen:EnumerateResponse/wsman:Items[1]/wsa:EndpointReference[1]/wsa:Address", + NULL, + "/s:Envelope/s:Body/wsen:EnumerateResponse/wsman:Items[last()]/wsa:EndpointReference[last()]/wsa:Address", NULL, NULL, NULL, }; @@ -74,161 +76,205 @@ static char *filters3[] = { NULL, NULL, }; +static char *filters4[] = { + NULL, // "/s:Envelope/s:Body/wsen:EnumerateResponse/wsman:Items[1]/p:OMC_InitdService[1]/p:SystemName", + "%s", + NULL, NULL, +}; + +static char *filters5[] = { + "/s:Envelope/s:Body/s:EnumerateResponse/wsman:EndOfSequence", + "", + NULL, NULL, +}; +static char *filters[] = { + "/s:Envelope/s:Body/s:EnumerateResponse/s:EnumerationContext", + NULL, + NULL, NULL, +}; + static TestData tests[] = { { "Enumeration with non existent Resource URI.", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemxx", - NULL, - NULL, NULL, NULL, NULL, NULL, NULL, -/* - "/s:Envelope/s:Body/s:Fault/s:Code/s:Subcode/s:Value", - "wsa:DestinationUnreachable", - "/s:Envelope/s:Body/s:Fault/s:Detail/wsman:FaultDetail", - "http://schemas.dmtf.org/wbem/wsman/1/wsman/faultDetail/InvalidResourceURI", -*/ + NULL, + NULL, 500, FLAG_NONE, 0, filters1, }, { - "Enumeration (Optimized)", - "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", - NULL, + "Enumeration with valid Resource URI.", + "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 200, + FLAG_NONE, + 0, + }, + { + "Enumeration (Count Estimation).", + "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", NULL, NULL, NULL, NULL, NULL, NULL, + NULL, + 200, + FLAG_ENUMERATION_COUNT_ESTIMATION, + 0, + filters3, + }, + { + "Enumeration (Optimized)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, 200, FLAG_ENUMERATION_OPTIMIZATION, - 200 + 200, }, { - "Enumeration (Optimized/EPR/Count)", - "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", - NULL, - NULL, - NULL, + "Enumeration (EPR)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 200, + FLAG_ENUMERATION_ENUM_EPR, + 200, + }, + { + "Enumeration (ObjEPR)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + 200, + FLAG_ENUMERATION_ENUM_OBJ_AND_EPR, + 200, + }, + { + "Enumeration (Optimized/EPR/Count Estimation)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, NULL, - NULL, NULL, - NULL, 200, FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_EPR | - FLAG_ENUMERATION_COUNT_ESTIMATION , + FLAG_ENUMERATION_COUNT_ESTIMATION, 200, filters2, + filters3, }, { - "Enumeration (Optimized/EPR)", - "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + "Enumeration (Optimized/EPR)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, 200, FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_EPR, - 200 + 200, + filters2, }, { - "Enumeration (Optimized/ObjEPR)", - "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + "Enumeration (Optimized/ObjEPR)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, 200, FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_OBJ_AND_EPR, - 200 + 200, + filters2, }, + { - "Enumeration with valid Resource URI and Items Count Estimation.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - NULL, - NULL, - "/s:Envelope/s:Header/wsman:TotalItemsCountEstimate", + "Enumeration (Optimized/ObjEPR/Count Estimation)", + "http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + NULL, + NULL, + NULL, NULL, NULL, NULL, 200, - FLAG_ENUMERATION_COUNT_ESTIMATION, - 0, + FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_COUNT_ESTIMATION | + FLAG_ENUMERATION_ENUM_OBJ_AND_EPR, + 200, filters3, - }, /* - { - "Enumeration with valid Resource URI.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_NONE, - 0 - }, - { - "Enumeration with valid Resource URI and additional invalid selectors.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_NONE, - 1 - }, - { - "Enumeration with valid Resource URI/Count Estimation.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_ENUMERATION_COUNT_ESTIMATION, - 0 - }, - { - "Enumeration with valid Resource URI/Optimization.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_ENUMERATION_OPTIMIZATION, - 0 - }, - { - "Enumeration with Count Estimation/Optimzation and get all elements.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_COUNT_ESTIMATION, - 10 - - }, - { - "Enumeration with Count Estimation/Optimzation/Epr and get all elements.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_COUNT_ESTIMATION | FLAG_ENUMERATION_ENUM_EPR, - 10 - - }, - { - "Enumeration with Count Estimation/Optimzation/ObjAndEpr and get all elements.", - "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem", - NULL, - 200, - FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_COUNT_ESTIMATION | FLAG_ENUMERATION_ENUM_OBJ_AND_EPR, - 10 - - } */ + }, + { + "Enumeration with valid Resource URI and additional invalid selectors.", + "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + "SystemCreationClassName=OMC_UnitaryComputerSystem&SystemName=%s&Namex=DUMMYDUMMY", + NULL, + NULL, + NULL, + NULL, + NULL, + 500, + FLAG_NONE, + 0, + NULL, + }, + { + "Enumeration (Optimized) and unexisting selector set.", + "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/OMC_InitdService", + NULL, + "SystemCreationClassName=OMC_UnitaryComputerSystem&SystemName=%s&Name=DUMMYDUMMY", + NULL, + NULL, + NULL, + NULL, + NULL, + 200, + FLAG_ENUMERATION_OPTIMIZATION, + 0, + filters5, + }, }; @@ -239,26 +285,38 @@ extern WsManClient *cl; actionOptions options; + + static void enumeration_test() { char *enumContext = NULL; static int i = 0; - char *xp = NULL; int num; - int j; + char *selectors = NULL; + reinit_client_connection(cl); initialize_action_options(&options); options.flags = tests[i].flags; - if (tests[i].selectors != NULL) - wsman_add_selectors_from_query_string(&options, tests[i].selectors); + if (tests[i].selectors) { + selectors = + u_strdup_printf(tests[i].selectors, host, host, host); + wsman_add_selectors_from_query_string(&options, selectors); + } options.max_elements = tests[i].max_elements; WsXmlDocH enum_response = wsenum_enumerate(cl, (char *)tests[i].resource_uri, options); - CU_ASSERT_TRUE(wsman_get_client_response_code(cl) == tests[i].final_status ); + CU_ASSERT_TRUE(wsman_get_client_response_code(cl) == tests[i].final_status); + if (wsman_get_client_response_code(cl) != tests[i].final_status) { + if (verbose) { + printf("\nExpected = %ld\nReturned = %ld ", + tests[i].final_status, wsman_get_client_response_code(cl)); + } + goto RETURN; + } CU_ASSERT_PTR_NOT_NULL(enum_response); if (enum_response) { enumContext = wsenum_get_enum_context(enum_response); @@ -268,32 +326,14 @@ static void enumeration_test() { check_response_header(enum_response, wsman_get_client_response_code(cl), ENUM_ACTION_ENUMERATERESPONSE); - if (_debug) wsman_output(enum_response); +if (i==11) ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(enum_response)); - if (tests[i].filters == NULL) { - goto RETURN; - } - - for (j = 0; tests[i].filters[j] != NULL; j += 2) { - u_free(xp); - xp = ws_xml_get_xpath_value(enum_response, tests[i].filters[j]); - CU_ASSERT_PTR_NOT_NULL(xp); - if (xp == NULL) { - if (verbose) { - printf("\n No Xpath: %s ", tests[i].filters[j]); - } - continue; - } - if (tests[i].filters[j + 1]) { - CU_ASSERT_STRING_EQUAL(xp, tests[i].filters[j + 1]); - if (verbose && strcmp(xp, tests[i].filters[j + 1])) { - printf("\nExpected: %s\nReturned: %s ", - tests[i].filters[j + 1], xp); - } - } - } + 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) { wsenum_release(cl, (char *)tests[i].resource_uri, @@ -303,7 +343,6 @@ RETURN: if (enum_response) { ws_xml_destroy_doc(enum_response); } - u_free(xp); destroy_action_options(&options); i++; // decrease executed test number } |
