summaryrefslogtreecommitdiffstats
path: root/tests/cunit
diff options
context:
space:
mode:
authorVadim Revyakin <vadimr@intel.com>2006-11-27 14:12:24 +0000
committerVadim Revyakin <vadimr@intel.com>2006-11-27 14:12:24 +0000
commit481be6651f5d4c0193e629f49be17a1b469b754a (patch)
treec0cc4fd06f7a43668d212a3d7ff682bf4ad30228 /tests/cunit
parentf48eef6c38d41f779550ba3555462355b775532a (diff)
downloadwsmancli-481be6651f5d4c0193e629f49be17a1b469b754a.tar.gz
wsmancli-481be6651f5d4c0193e629f49be17a1b469b754a.tar.xz
wsmancli-481be6651f5d4c0193e629f49be17a1b469b754a.zip
Tests improvement
Diffstat (limited to 'tests/cunit')
-rw-r--r--tests/cunit/enumeration.c23
-rwxr-xr-xtests/cunit/invoke.c48
-rw-r--r--tests/cunit/pull.c59
-rwxr-xr-xtests/cunit/transfer_put.c8
4 files changed, 104 insertions, 34 deletions
diff --git a/tests/cunit/enumeration.c b/tests/cunit/enumeration.c
index 2fb4229..8468596 100644
--- a/tests/cunit/enumeration.c
+++ b/tests/cunit/enumeration.c
@@ -132,7 +132,7 @@ static TestData tests[] = {
NULL,
NULL,
"/s:Envelope/s:Header/wsman:TotalItemsCountEstimate",
- "3",
+ NULL,
NULL,
NULL,
200,
@@ -212,6 +212,7 @@ static void enumeration_test() {
char *enumContext = NULL;
static int i = 0;
char *xp = NULL;
+ int num;
reinit_client_connection(cl);
initialize_action_options(&options);
@@ -242,8 +243,24 @@ static void enumeration_test() {
if (!xp) {
goto RETURN;
}
- CU_ASSERT_STRING_EQUAL(xp, tests[i].value1 );
-
+ if (tests[i].value1) {
+ CU_ASSERT_STRING_EQUAL(xp, tests[i].value1);
+ if (strcmp(xp, tests[i].value1)) {
+ if (verbose) {
+ printf("\nExpected <positive digital>\nReturned %s ", xp);
+ }
+ }
+ goto RETURN;
+ } else {
+ num = atoi(xp);
+ CU_ASSERT_TRUE(num > 0);
+ if (num <= 0) {
+ if (verbose) {
+ printf("\nExpected <positive digital>\nReturned %s ", xp);
+ }
+ }
+ goto RETURN;
+ }
RETURN:
if (enum_response) {
ws_xml_destroy_doc(enum_response);
diff --git a/tests/cunit/invoke.c b/tests/cunit/invoke.c
index 542eded..df816ad 100755
--- a/tests/cunit/invoke.c
+++ b/tests/cunit/invoke.c
@@ -189,29 +189,40 @@ static void invoke_test() {
char *xpf = NULL;
char *xpd = NULL;
static int i = 0; // executed test number.
- char *old_selectors = invoke_tests[i].selectors;
+ char *selectors = NULL;
+ initialize_action_options(&options);
if (invoke_tests[i].selectors) {
- invoke_tests[i].selectors =
+ selectors =
u_strdup_printf(invoke_tests[i].selectors, host, host, host);
}
reinit_client_connection(cl);
- initialize_action_options(&options);
- if (invoke_tests[i].selectors != NULL) {
- wsman_add_selectors_from_query_string (&options, invoke_tests[i].selectors);
+ if (selectors != NULL) {
+ wsman_add_selectors_from_query_string (&options, selectors);
}
if (invoke_tests[i].properties != NULL) {
- wsman_add_properties_from_query_string (&options, invoke_tests[i].properties);
+ wsman_add_properties_from_query_string (&options,
+ invoke_tests[i].properties);
}
options.flags = invoke_tests[i].flags;
- doc = wsman_invoke (cl, (char *)invoke_tests[i].resource_uri, (char *)invoke_tests[i].method, options);
+ doc = wsman_invoke(cl, (char *)invoke_tests[i].resource_uri,
+ (char *)invoke_tests[i].method, options);
//ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
- CU_ASSERT_TRUE(wsman_get_client_response_code(cl) == invoke_tests[i].final_status);
-
+ CU_ASSERT_TRUE(wsman_get_client_response_code(cl) ==
+ invoke_tests[i].final_status);
+ if (wsman_get_client_response_code(cl) !=
+ invoke_tests[i].final_status) {
+ if (verbose) {
+ printf("\nExpected = %ld\nReturned = %ld ",
+ invoke_tests[i].final_status,
+ wsman_get_client_response_code(cl));
+ }
+ goto RETURN;
+ }
CU_ASSERT_PTR_NOT_NULL(doc);
if (!doc) {
goto RETURN;
@@ -229,7 +240,14 @@ static void invoke_test() {
goto RETURN;
}
CU_ASSERT_STRING_EQUAL(xpf, invoke_tests[i].value1);
-
+ if (strcmp(xpf, invoke_tests[i].value1)) {
+ if (verbose) {
+ printf("\nExpected = %s\nReturned = %s ",
+ invoke_tests[i].value1,
+ xpf);
+ }
+ goto RETURN;
+ }
if (invoke_tests[i].expr2 == NULL) {
goto RETURN;
}
@@ -243,14 +261,20 @@ static void invoke_test() {
goto RETURN;
}
CU_ASSERT_STRING_EQUAL(xpd, invoke_tests[i].value2 );
+ if (strcmp(xpd, invoke_tests[i].value2)) {
+ if (verbose) {
+ printf("\nExpected = %s\nReturned = %s ",
+ invoke_tests[i].value2,
+ xpd);
+ }
+ }
RETURN:
u_free(xpf);
u_free(xpd);
if (doc) {
ws_xml_destroy_doc(doc);
}
- u_free((char *)invoke_tests[i].selectors);
- invoke_tests[i].selectors = old_selectors;
+ u_free(selectors);
destroy_action_options(&options);
i++; // increase executed test number
}
diff --git a/tests/cunit/pull.c b/tests/cunit/pull.c
index 60155b9..c90c823 100644
--- a/tests/cunit/pull.c
+++ b/tests/cunit/pull.c
@@ -55,7 +55,7 @@
static TestData pull_tests[] = {
{
- "Enumeration with non existent Resource URI.",
+ "Pull. Enumeration with non existent Resource URI.",
"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemxx",
NULL,
NULL,
@@ -69,7 +69,7 @@ static TestData pull_tests[] = {
0
},
{
- "Enumeration with non existent Resource URI. (Optimized)",
+ "Pull. Enumeration with non existent Resource URI. (Optimized)",
"http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService",
NULL,
NULL,
@@ -83,7 +83,7 @@ static TestData pull_tests[] = {
200
},
{
- "Enumeration with non existent Resource URI. (Optimized/EPR/Count)",
+ "Pull. Enumeration with non existent Resource URI. (Optimized/EPR/Count)",
"http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService",
NULL,
NULL,
@@ -93,11 +93,12 @@ static TestData pull_tests[] = {
NULL,
NULL,
200,
- FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_EPR | FLAG_ENUMERATION_COUNT_ESTIMATION ,
+ FLAG_ENUMERATION_OPTIMIZATION | FLAG_ENUMERATION_ENUM_EPR |
+ FLAG_ENUMERATION_COUNT_ESTIMATION ,
200
},
{
- "Enumeration with non existent Resource URI. (Optimized/EPR)",
+ "Pull. Enumeration with non existent Resource URI. (Optimized/EPR)",
"http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService",
NULL,
NULL,
@@ -111,7 +112,7 @@ static TestData pull_tests[] = {
200
},
{
- "Enumeration with non existent Resource URI. (Optimized/ObjEPR)",
+ "Pull. Enumeration with non existent Resource URI. (Optimized/ObjEPR)",
"http://schema.omc-project.org/wbem/wscim/1/cim-schema/2/OMC_InitdService",
NULL,
NULL,
@@ -125,13 +126,13 @@ static TestData pull_tests[] = {
200
},
{
- "Enumeration with valid Resource URI and Items Count Estimation.",
+ "Pull. 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",
- "3",
+ NULL,
NULL,
NULL,
200,
@@ -211,6 +212,7 @@ static void pull_test() {
char *enumContext = NULL;
static int i = 0;
char *xp = NULL;
+ int num;
reinit_client_connection(cl);
initialize_action_options(&options);
@@ -223,7 +225,16 @@ static void pull_test() {
options.max_elements = pull_tests[i].max_elements;
WsXmlDocH enum_response = wsenum_enumerate(cl,
(char *)pull_tests[i].resource_uri, options);
- CU_ASSERT_TRUE(wsman_get_client_response_code(cl) == pull_tests[i].final_status );
+ CU_ASSERT_TRUE(wsman_get_client_response_code(cl) ==
+ pull_tests[i].final_status);
+ if (wsman_get_client_response_code(cl) != pull_tests[i].final_status) {
+ if (verbose) {
+ printf("\nExpected = %ld\nReturned = %ld ",
+ pull_tests[i].final_status,
+ wsman_get_client_response_code(cl));
+ }
+ goto RETURN;
+ }
CU_ASSERT_PTR_NOT_NULL(enum_response);
if (enum_response) {
@@ -232,13 +243,12 @@ static void pull_test() {
enumContext = NULL;
}
- while (enumContext != NULL)
- {
- WsXmlDocH docp = wsenum_pull(cl, (char *)pull_tests[i].resource_uri, enumContext,
- options);
+ while (enumContext != NULL) {
+ WsXmlDocH docp = wsenum_pull(cl, (char *)pull_tests[i].resource_uri,
+ enumContext, options);
CU_ASSERT_PTR_NOT_NULL(docp);
if (!docp) {
- break;
+ goto RETURN;
}
if (pull_tests[i].expr1 == NULL) {
goto RETURN;
@@ -248,7 +258,26 @@ static void pull_test() {
if (!xp) {
goto RETURN;
}
- CU_ASSERT_STRING_EQUAL(xp, pull_tests[i].value1 );
+ if (pull_tests[i].value1) {
+ CU_ASSERT_STRING_EQUAL(xp, pull_tests[i].value1);
+ if (strcmp(xp, pull_tests[i].value1)) {
+ if (verbose) {
+ printf("\nExpected <positive digital>\nReturned %s ",
+ xp);
+ }
+ }
+ goto RETURN;
+ } else {
+ num = atoi(xp);
+ CU_ASSERT_TRUE(num > 0);
+ if (num <= 0) {
+ if (verbose) {
+ printf("\nExpected <positive digital>\nReturned %s ",
+ xp);
+ }
+ }
+ goto RETURN;
+ }
enumContext = wsenum_get_enum_context(docp);
ws_xml_destroy_doc(docp);
}
diff --git a/tests/cunit/transfer_put.c b/tests/cunit/transfer_put.c
index 46bfd6c..924e98e 100755
--- a/tests/cunit/transfer_put.c
+++ b/tests/cunit/transfer_put.c
@@ -201,10 +201,10 @@ static void transfer_put_test() {
if (wsman_get_client_response_code(cl) !=
put_tests[i].final_status) {
if (verbose) {
- printf("Expected = %ld, Returned = %ld\n",
+ printf("\nExpected = %ld, Returned = %ld ",
put_tests[i].final_status,
wsman_get_client_response_code(cl));
- ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
+ // ws_xml_dump_node_tree(stdout, ws_xml_get_doc_root(doc));
}
goto RETURN;
}
@@ -228,7 +228,7 @@ static void transfer_put_test() {
if (strcmp(xpf, put_tests[i].value1)) {
if (verbose) {
- printf("Expected %s; returned %s\n",
+ printf("Expected %s\nReturned %s ",
put_tests[i].value1, xpf);
}
goto RETURN;
@@ -248,7 +248,7 @@ static void transfer_put_test() {
CU_ASSERT_STRING_EQUAL(xpd, put_tests[i].value2 );
if (strcmp(xpd, put_tests[i].value2)) {
if (verbose) {
- printf("Expected %s; returned %s\n",
+ printf("\nExpected %sReturned %s ",
put_tests[i].value2, xpd);
}
goto RETURN;