|
From: Michael Chase-S. <mc...@us...> - 2013-01-24 01:05:36
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SFCB - Small Footprint CIM Broker".
The branch, master has been updated
via 01bf3a34a050f4c92855565f6f29bd7866b04158 (commit)
via b1f395024ffbe4f7939852fa2a11b856efb2457f (commit)
from 5cf6c002667121d5ecf9d5036c682582e4e16dee (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 01bf3a34a050f4c92855565f6f29bd7866b04158
Merge: b1f3950 5cf6c00
Author: Michael Chase-Salerno <br...@li...>
Date: Wed Jan 23 20:05:01 2013 -0500
Merge branch 'master' of ssh://sblim.git.sourceforge.net/gitroot/sblim/sfcb
commit b1f395024ffbe4f7939852fa2a11b856efb2457f
Author: Michael Chase-Salerno <br...@li...>
Date: Wed Jan 23 20:03:58 2013 -0500
3601943 ObjectImpl unit test
-----------------------------------------------------------------------
Summary of changes:
diff --git a/Makefile.am b/Makefile.am
index beb696b..2c127e9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -556,7 +556,7 @@ if GCOV
# Ignore errors from lcov since it always seems to have a problem
- lcov --capture --directory .libs --output-file ./coverage/lcovtest.info --ignore-errors gcov,source
lcov --remove ./coverage/lcovtest.info "/usr*" --output-file ./coverage/cov_stripped.info
- genhtml --output-directory ./coverage ./coverage/cov_stripped.info
+ genhtml --legend --output-directory ./coverage ./coverage/cov_stripped.info
@echo "****** Coverage report generated in ./coverage/index.html"
endif
diff --git a/objectImpl.c b/objectImpl.c
index 4946588..0da6d0d 100644
--- a/objectImpl.c
+++ b/objectImpl.c
@@ -2920,65 +2920,235 @@ ClArgsToString(ClArgs * arg)
return sc.str;
}
-// #define MAIN_TEST
-#ifdef MAIN_TEST
-
-extern CMPIArray *NewCMPIArray(CMPICount size, CMPIType type,
- CMPIStatus *rc);
-extern CMPIArgs *NewCMPIArgs(CMPIStatus *rc);
-extern CMPIInstance *NewCMPIInstance(CMPIObjectPath * cop, CMPIStatus *rc);
-extern CMPIObjectPath *NewCMPIObjectPath(const char *nameSpace,
- const char *className,
- CMPIStatus *rc);
-extern unsigned long getArgsSerializedSize(CMPIArgs * args);
-extern unsigned long getInstanceSerializedSize(CMPIInstance *ci);
-
+#ifdef UNITTEST
+// Embedded unittest routine
int
-main()
-{
- int val = 37,
- s;
- // SFCB_ASM("int $3");
- {
- CMPIObjectPath *cop = NewCMPIObjectPath("root", "myClass", NULL);
- CMPIInstance *inst = NewCMPIInstance(cop, NULL);
- CMPIArgs *arg = NewCMPIArgs(NULL);
- CMPIArray *ar = NewCMPIArray(1, CMPI_sint32, NULL);
- CMSetArrayElementAt(ar, 0, &val, CMPI_sint32);
- printf("CMPI_sint32A: %p\n", (void *) CMPI_sint32A);
- CMPIData ad = CMGetArrayElementAt(ar, 0, NULL);
- printf("ad.sin32: %d\n", ad.value.sint32);
- CMAddArg(arg, "test", &ar, CMPI_sint32A);
- CMPIData d = CMGetArg(arg, "test", NULL);
- ad = CMGetArrayElementAt(d.value.array, 0, NULL);
- printf("ad.sin32: %d\n", ad.value.sint32);
- s = getArgsSerializedSize(arg);
-
- CMPIArgs *narg = CMClone(arg, NULL);
- s = getArgsSerializedSize(arg);
- }
-
- {
- CMPIObjectPath *cop = NewCMPIObjectPath("root", "myClass", NULL);
- CMPIInstance *inst = NewCMPIInstance(cop, NULL);
- CMPIArray *ar = NewCMPIArray(1, CMPI_sint32, NULL);
- CMSetArrayElementAt(ar, 0, &val, CMPI_sint32);
- printf("CMPI_sint32A: %p\n", (void *) CMPI_sint32A);
- CMPIData ad = CMGetArrayElementAt(ar, 0, NULL);
- printf("ad.sin32: %d\n", ad.value.sint32);
- CMSetProperty(inst, "test", &ar, CMPI_sint32A);
- CMPIData d = CMGetProperty(inst, "test", NULL);
- ad = CMGetArrayElementAt(d.value.array, 0, NULL);
- printf("ad.sin32: %d\n", ad.value.sint32);
- s = getInstanceSerializedSize(inst);
-
- CMPIInstance *ninst = CMClone(inst, NULL);
- s = getInstanceSerializedSize(ninst);
+oi_test()
+{
+ int i,fail = 0;
+ const char *str;
+ CMPIStatus rc;
+
+ // Some CMPI based tests
+ CMPIObjectPath *cop = NewCMPIObjectPath("root", "myClass", &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to create object path, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ CMPIInstance *inst = NewCMPIInstance(cop, &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to create instance, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ i=isInstance(inst);
+ if (!i) {
+ printf("Failed isInstance check, rc=%d\n",i);
+ fail = 1;
+ }
+ i=isInstance(cop);
+ if (i) {
+ printf("Failed negative isInstance check, rc=%d\n",i);
+ fail = 1;
}
- return 0;
+ //Do some array checks
+ CMPIArray *ar = NewCMPIArray(1, CMPI_sint32, &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to create CMPI array, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ int val = 37;
+ CMSetArrayElementAt(ar, 0, &val, CMPI_sint32);
+ CMPIData ad = CMGetArrayElementAt(ar, 0, &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to get CMPI array element, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ if (ad.value.sint32 != val) {
+ printf("Fetched array element value not as expected, expected: %d got:%d\n",val,ad.value.sint32);
+ fail = 1;
+ }
+ CMSetProperty(inst, "test", &ar, CMPI_sint32A);
+ CMPIData d = CMGetProperty(inst, "test", &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to get CMPI property, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ ad = CMGetArrayElementAt(d.value.array, 0, &rc);
+ if (rc.rc != CMPI_RC_OK) {
+ printf("Failed to get CMPI array element, rc: %d msg:%s\n",rc.rc,(char *)rc.msg);
+ fail = 1;
+ }
+ if (ad.value.sint32 != val) {
+ printf("Instance array element value not as expected, expected: %d got:%d\n",val,ad.value.sint32);
+ fail = 1;
+ }
+
+ //CLobject tests
+
+ //CLObjectPath tests
+ ClObjectPath *clop=ClObjectPathNew("root","myClass");
+ if (clop == NULL) {
+ printf("Failed to create CLObjectPath\n");
+ fail = 1;
+ }
+ ClObjectPath *clop2=ClObjectPathRebuild(clop,NULL);
+ if (clop2 == NULL) {
+ printf("Failed to rebuild CLObjectPath\n");
+ fail = 1;
+ }
+ str=ClObjectPathToString(clop);
+ // Not implemented, so not checked
+
+ //Set it twice to test replace string
+ ClObjectPathSetHostName(clop,"testhost2");
+ ClObjectPathSetHostName(clop,"testhost");
+ str=ClObjectPathGetHostName(clop);
+ if (strcmp(str,"testhost") != 0) {
+ printf("Failed to get/set hostname from objectpath:%s\n",str);
+ fail = 1;
+ }
+ ClObjectPathSetNameSpace(clop, "root2");
+ str=ClObjectPathGetNameSpace(clop);
+ if (strcmp(str,"root2") != 0) {
+ printf("Failed to get/set namespace from objectpath:%s\n",str);
+ fail = 1;
+ }
+ ClObjectPathSetClassName(clop, "myClass2");
+ str=ClObjectPathGetClassName(clop);
+ if (strcmp(str,"myClass2") != 0) {
+ printf("Failed to get/set classname from objectpath:%s\n",str);
+ fail = 1;
+ }
+
+ // CLinstance checks
+ ClInstance * cli=ClInstanceNewFromMof("root", "myClass");
+ if (cli == NULL) {
+ printf("Failed to create CLinstance from MOF\n");
+ fail = 1;
+ }
+ ClInstance *cli2=ClInstanceRebuild(cli,NULL);
+ if (cli2 == NULL) {
+ printf("Failed to rebuild CLinstance\n");
+ fail = 1;
+ }
+
+ unsigned long li=ClSizeInstance(cli);
+ if (li == 0) {
+ printf("Failed to size CLinstance.\n");
+ fail = 1;
+ }
+ str=ClInstanceToString(cli);
+ if (strstr(str,"Instance") == NULL) {
+ printf("Failed to get string from instance:%s\n",str);
+ fail = 1;
+ }
+ str=ClInstanceGetNameSpace(cli);
+ if (strcmp(str,"root") != 0) {
+ printf("Failed to get namespace from instance:%s\n",str);
+ fail = 1;
+ }
+ str=ClInstanceGetClassName(cli);
+ if (strcmp(str,"myClass") != 0) {
+ printf("Failed to get namespace from instance:%s\n",str);
+ fail = 1;
+ }
+
+ ClClass * clc=ClClassNew("myClass","myPClass");
+ if (clc == NULL) {
+ printf("Failed to create ClClass.\n");
+ fail = 1;
+ }
+ unsigned char cch=ClClassAddGrandParent(clc, "myGClass");
+ // not sure of the failure case here
+
+ i=ClClassAddProperty(clc,"tprop" ,d,"testref");
+ if (i != 1) {
+ printf("Failed to add property to ClClass.\n");
+ fail = 1;
+ }
+ ClClass *clc2=ClClassRebuildClass(clc,NULL);
+ if (clc2 == NULL) {
+ printf("Failed to rebuild ClClass.\n");
+ fail = 1;
+ }
+
+ i=ClClassGetPropertyCount(clc);
+ if (i != 1) {
+ printf("Failed to get property count for ClClass.\n");
+ fail = 1;
+ }
+
+ li=ClSizeClass(clc);
+ if (li == 0) {
+ printf("Failed to size ClClass.\n");
+ fail = 1;
+ }
+ str=ClClassToString(clc);
+ if (strstr(str,"class") == NULL) {
+ printf("Failed to get string from ClClass:%s\n",str);
+ fail = 1;
+ }
+
+ //Args tests
+ ClArgs * cla=ClArgsNew();
+ if (cla == NULL) {
+ printf("Failed to create ClArgs object.\n");
+ fail = 1;
+ }
+ li=ClSizeArgs(cla);
+ if (li == 0) {
+ printf("Failed to size ClArgs.\n");
+ fail = 1;
+ }
+ ClArgs *cla2=ClArgsRebuild(cla,NULL);
+ if (cla2 == NULL) {
+ printf("Failed to rebuild ClArgs object.\n");
+ fail = 1;
+ }
+ i=ClArgsAddArg(cla,"test",d);
+ if (i == 0) {
+ printf("Failed to add arg to ClArgs.\n");
+ fail = 1;
+ }
+ i=ClArgsGetArgCount(cla);
+ if (i == 0) {
+ printf("Failed to get arg count.\n");
+ fail = 1;
+ }
+ i=ClArgsGetArgAt(cla, 2, NULL, NULL);
+ if (i != 1) {
+ printf("Failed to catch bad arg count.\n");
+ fail = 1;
+ }
+
+// Qualifiers
+ ClQualifierDeclaration * clq=ClQualifierDeclarationNew("root","myQual");
+ if (clq == NULL) {
+ printf("Failed to create ClQualifier object.\n");
+ fail = 1;
+ }
+ li=ClSizeQualifierDeclaration(clq);
+ if (li == 0) {
+ printf("Failed to size ClQualifier.\n");
+ fail = 1;
+ }
+ ClQualifierDeclaration *clq2=ClQualifierRebuildQualifier(clq,NULL);
+ if (clq2 == NULL) {
+ printf("Failed to rebuild ClQualifier object.\n");
+ fail = 1;
+ }
+
+ ClClassFreeClass(clc);
+ ClInstanceFree(cli);
+ ClObjectPathFree(clop);
+ ClArgsFree(cla);
+
+ // Return the final result
+ return fail;
}
#endif
+
/* MODELINES */
/* DO NOT EDIT BELOW THIS COMMENT */
/* Modelines are added by 'make pretty' */
diff --git a/objectImpl.h b/objectImpl.h
index 5038e02..a2e6edc 100644
--- a/objectImpl.h
+++ b/objectImpl.h
@@ -601,6 +601,10 @@ const char *ClObjectGetClObject(ClObjectHdr * hdr, ClString * id);
#endif // SETCLPFX
#endif
+#ifdef UNITTEST
+extern int oi_test();
+#endif
+
/* MODELINES */
/* DO NOT EDIT BELOW THIS COMMENT */
/* Modelines are added by 'make pretty' */
diff --git a/test/unittest/EmbeddedTests.c b/test/unittest/EmbeddedTests.c
index 4b4a744..333e309 100644
--- a/test/unittest/EmbeddedTests.c
+++ b/test/unittest/EmbeddedTests.c
@@ -21,6 +21,7 @@
// Include the header file for each embedded test routine.
#include "trace.h"
#include "queryOperation.h"
+#include "objectImpl.h"
int
main(void)
@@ -40,6 +41,11 @@ main(void)
if (rc != 0)
fail = 1;
+ printf(" Testing objectImpl.c ...\n");
+ rc = oi_test();
+ if (rc != 0)
+ fail = 1;
+
// Return the overall results.
return fail;
}
diff --git a/test/unittest/Makefile.am b/test/unittest/Makefile.am
index d9a754f..016db10 100644
--- a/test/unittest/Makefile.am
+++ b/test/unittest/Makefile.am
@@ -32,13 +32,13 @@ TESTS = xmlUnescape newCMPIInstance EmbeddedTests newDateTime
check_PROGRAMS = xmlUnescape newCMPIInstance EmbeddedTests newDateTime
xmlUnescape_SOURCES = xmlUnescape.c
-xmlUnescape_LDADD = -lsfcCimXmlCodec -lsfcHttpAdapter
+xmlUnescape_LDADD = -lsfcBrokerCore -lsfcCimXmlCodec -lsfcHttpAdapter
newCMPIInstance_SOURCES = newCMPIInstance.c
-newCMPIInstance_LDADD = -lsfcCimXmlCodec -lsfcHttpAdapter
+newCMPIInstance_LDADD = -lsfcCimXmlCodec -lsfcHttpAdapter -lsfcBrokerCore
EmbeddedTests_SOURCES = EmbeddedTests.c
-EmbeddedTests_LDADD = -lsfcCimXmlCodec -lsfcHttpAdapter
+EmbeddedTests_LDADD = -lsfcCimXmlCodec -lsfcHttpAdapter -lsfcBrokerCore
newDateTime_SOURCES = newDateTime.c
newDateTime_LDADD = -lsfcBrokerCore
diff --git a/test/unittest/xmlUnescape.c b/test/unittest/xmlUnescape.c
index 06a534f..e92801b 100644
--- a/test/unittest/xmlUnescape.c
+++ b/test/unittest/xmlUnescape.c
@@ -13,6 +13,7 @@
#include <cimRequest.h>
extern RequestHdr scanCimXmlRequest(CimRequestContext *ctx, char *xmlData, int *rc);
+int trimws;
int
main(void)
hooks/post-receive
--
SFCB - Small Footprint CIM Broker
|