summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Revyakin <vadimr@intel.com>2006-11-28 14:07:48 +0000
committerVadim Revyakin <vadimr@intel.com>2006-11-28 14:07:48 +0000
commit5b8f030aff092a4ac16dd033e5dc9cac6f07d3b1 (patch)
tree278b20b16f4608451530c9a9b19c9390fac75566
parent229cdcefcb6bc29052fc4cd839d9df5454843bac (diff)
downloadwsmancli-5b8f030aff092a4ac16dd033e5dc9cac6f07d3b1.tar.gz
wsmancli-5b8f030aff092a4ac16dd033e5dc9cac6f07d3b1.tar.xz
wsmancli-5b8f030aff092a4ac16dd033e5dc9cac6f07d3b1.zip
Test development
-rw-r--r--tests/cunit/common.c4
-rw-r--r--tests/cunit/common.h6
-rw-r--r--tests/cunit/enumeration.c88
-rw-r--r--tests/cunit/run_tests.c4
-rw-r--r--tests/cunit/transfer_get.c5
5 files changed, 73 insertions, 34 deletions
diff --git a/tests/cunit/common.c b/tests/cunit/common.c
index 7295fc6..d55c9f9 100644
--- a/tests/cunit/common.c
+++ b/tests/cunit/common.c
@@ -45,3 +45,7 @@ int clean_test(void) {
wsman_client_transport_fini();
return 0;
}
+
+void check_response_header(char *action) {
+ }
+
diff --git a/tests/cunit/common.h b/tests/cunit/common.h
index 33ac369..0e3863c 100644
--- a/tests/cunit/common.h
+++ b/tests/cunit/common.h
@@ -41,6 +41,10 @@ typedef struct {
unsigned int max_elements;
+ /* pairs of string filter/value. The last pair is NULL/NULL */
+ char **filters;
+ char **common_filters;
+
} TestData;
extern char *host;
@@ -55,4 +59,6 @@ int add_transfer_put_tests(CU_pSuite ps);
int add_invoke_tests(CU_pSuite ps);
int add_pull_tests(CU_pSuite ps);
+void check_response_header(char *action);
+
#endif
diff --git a/tests/cunit/enumeration.c b/tests/cunit/enumeration.c
index d2e0236..8924bb6 100644
--- a/tests/cunit/enumeration.c
+++ b/tests/cunit/enumeration.c
@@ -53,6 +53,25 @@
static int _debug = 0;
+static char *filters1[] = {
+ "/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
+};
+
+static char *filters2[] = {
+ "s:Envelope/s:Body/wsen:EnumerateResponse/wsman:Items/wsa:EndpointReference/wsa:Address",
+ NULL,
+ NULL, NULL,
+};
+
+static char *filters3[] = {
+ "/s:Envelope/s:Header/wsman:TotalItemsCountEstimate",
+ NULL,
+ NULL, NULL,
+};
static TestData tests[] = {
{
@@ -60,14 +79,21 @@ static TestData tests[] = {
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemxx",
NULL,
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",
+*/
500,
FLAG_NONE,
- 0
+ 0,
+ &filters1,
},
{
"Enumeration (Optimized)",
@@ -89,14 +115,15 @@ static TestData tests[] = {
NULL,
NULL,
NULL,
+ NULL,
NULL,
- NULL,
- NULL,
+ NULL,
NULL,
200,
FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_EPR |
FLAG_ENUMERATION_COUNT_ESTIMATION ,
- 200
+ 200,
+ &filters2,
},
{
"Enumeration (Optimized/EPR)",
@@ -138,7 +165,9 @@ static TestData tests[] = {
NULL,
200,
FLAG_ENUMERATION_COUNT_ESTIMATION,
- 0
+ 0,
+ &filters3,
+
}, /*
{
"Enumeration with valid Resource URI.",
@@ -214,6 +243,7 @@ static void enumeration_test() {
static int i = 0;
char *xp = NULL;
int num;
+ int j;
reinit_client_connection(cl);
initialize_action_options(&options);
@@ -231,44 +261,42 @@ static void enumeration_test() {
CU_ASSERT_PTR_NOT_NULL(enum_response);
if (enum_response) {
enumContext = wsenum_get_enum_context(enum_response);
- if (enumContext)
- wsenum_release(cl,
- (char *)tests[i].resource_uri,
- enumContext,
- options);
} else {
goto RETURN;
}
if (_debug) wsman_output(enum_response);
- if (tests[i].expr1 == NULL) {
- goto RETURN;
- }
- xp = ws_xml_get_xpath_value(enum_response, tests[i].expr1);
- CU_ASSERT_PTR_NOT_NULL(xp);
- if (!xp) {
+ if (tests[i].filters == NULL) {
goto RETURN;
}
- if (tests[i].value1) {
- CU_ASSERT_STRING_EQUAL(xp, tests[i].value1);
- if (strcmp(xp, tests[i].value1)) {
+
+ 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("\nExpected <positive digital>\nReturned %s ", xp);
+ printf("\n No Xpath: %s ", tests[i].filters[j]);
}
+ continue;
}
- goto RETURN;
- } else {
- num = atoi(xp);
- CU_ASSERT_TRUE(num > 0);
- if (num <= 0) {
- if (verbose) {
- printf("\nExpected <positive digital>\nReturned %s ", xp);
- }
+ 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);
+ }
}
- goto RETURN;
}
+
RETURN:
+ if (enumContext) {
+ wsenum_release(cl,
+ (char *)tests[i].resource_uri,
+ enumContext,
+ options);
+ }
if (enum_response) {
ws_xml_destroy_doc(enum_response);
}
diff --git a/tests/cunit/run_tests.c b/tests/cunit/run_tests.c
index dd2a1cc..4004221 100644
--- a/tests/cunit/run_tests.c
+++ b/tests/cunit/run_tests.c
@@ -56,8 +56,8 @@ setup_client_suite(void) {
num_tests += add_pull_tests(ps);
num_tests += add_identify_tests(ps);
num_tests += add_transfer_get_tests(ps);
- num_tests += add_transfer_put_tests(ps);
- num_tests += add_invoke_tests(ps);
+// num_tests += add_transfer_put_tests(ps);
+// num_tests += add_invoke_tests(ps);
if (num_tests == 0) {
printf("No tests to run\n");
// nothing to do
diff --git a/tests/cunit/transfer_get.c b/tests/cunit/transfer_get.c
index 3439925..df4d0fa 100644
--- a/tests/cunit/transfer_get.c
+++ b/tests/cunit/transfer_get.c
@@ -108,7 +108,7 @@ TestData get_tests[] = {
},
{
- "Transfer Get with all selectors but with wrong values 1.",
+ "Transfer Get with all selectors but with wrong values.",
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
NULL,
"CreationClassName=OpenWBEM_UnitaryComputerSystem&Name=%sx",
@@ -125,7 +125,8 @@ TestData get_tests[] = {
"Transfer Get with all selectors (CIM_OperatingSystem).",
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_OperatingSystem",
NULL,
- "CSCreationClassName=OMC_UnitaryComputerSystem&CSName=%s&CreationClassName=OMC_OperatingSystem&Name=Linux",
+ "CSCreationClassName=OMC_UnitaryComputerSystem&CSName=%s"
+ "&CreationClassName=OMC_OperatingSystem&Name=Linux",
NULL,
NULL,
NULL,