|
From: Chris B. <buc...@us...> - 2012-05-18 22:57:50
|
Update of /cvsroot/sblim/sfcb/test/TestProviders
In directory vz-cvs-3.sog:/tmp/cvs-serv13638/test/TestProviders
Modified Files:
cmpiTestMiscProvider.c
Log Message:
[ 3528074 ] Improve CMPIInstance Error Codes
Index: cmpiTestMiscProvider.c
===================================================================
RCS file: /cvsroot/sblim/sfcb/test/TestProviders/cmpiTestMiscProvider.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmpiTestMiscProvider.c 6 Nov 2009 00:18:29 -0000 1.2
+++ cmpiTestMiscProvider.c 18 May 2012 22:57:48 -0000 1.3
@@ -956,6 +956,7 @@
static int _testCMPIInstance ()
{
CMPIStatus rc = { CMPI_RC_OK, NULL };
+ int errors = 0;
CMPIInstance* instance = NULL;
CMPIInstance* clonedInstance = NULL;
@@ -974,9 +975,6 @@
const char* name2 = "secondPropertyName";
CMPIValue value2;
CMPIType type = CMPI_uint64;
- CMPIBoolean dataEqual = 0;
- CMPIBoolean objectPathEqual = 0;
- CMPIBoolean cloneSuccessful = 0;
CMPIString* beforeObjPath = NULL;
CMPIString* afterObjPath = NULL;
const char* beforeString = NULL;
@@ -988,15 +986,28 @@
value2.uint32 = 20;
rc = CMSetProperty(instance, name2, &value2, type);
count = CMGetPropertyCount(instance, &rc);
+ /* count will vary based on what's in the MOF */
+ if (count != 5)
+ {
+ fprintf(stderr, "count is %d\n", count);
+ errors=1;
+ }
returnedData1 = CMGetProperty(instance, name1, &rc);
- if (returnedData1.value.uint32 == 10)
+ if (returnedData1.value.uint32 != 10)
{
- dataEqual = 1 ;
+ errors+=2;
}
- returnedData2 = CMGetPropertyAt(instance, 2, &returnedName, &rc);
- if (returnedData2.value.uint32 == 20)
+ int i;
+ for(i=0; i<count; i++) {
+ returnedData2 = CMGetPropertyAt(instance, i, &returnedName, &rc);
+ fprintf(stderr, "property %d is %s\n", i, (char*)returnedName->hdl);
+ }
+ /* this check is really SFCB-dependent, since position isn't guaranteed */
+ returnedData2 = CMGetPropertyAt(instance, 0, &returnedName, &rc);
+ if (returnedData2.value.uint32 != 20)
{
- dataEqual = 1 ;
+ fprintf(stderr, "returnedData2.value.uint32=%d\n", returnedData2.value.uint32);
+ errors+=4;
}
newObjPath = make_ObjectPath(_broker, _Namespace, _ClassName);
returnedObjPath = CMGetObjectPath(instance, &rc);
@@ -1008,34 +1019,30 @@
afterObjPath = CMObjectPathToString(returnedObjPath, &rc);
afterString = CMGetCharsPtr(afterObjPath,&rc);
afterString = CMGetCharsPtr(CMGetNameSpace(returnedObjPath, &rc), &rc);
- if (strcmp("newNamespace",afterString) == 0)
+ if (strcmp("newNamespace",afterString) != 0)
{
- objectPathEqual = 1;
+ errors+=8;
}
clonedInstance = instance->ft->clone(instance, &rc);
clonedData1 = CMGetProperty(clonedInstance, name1, &rc);
rc = clonedInstance->ft->release(clonedInstance);
- if (returnedData1.value.uint32 == clonedData1.value.uint32)
- {
- cloneSuccessful = 1;
- }
- else
+ if (returnedData1.value.uint32 != clonedData1.value.uint32)
{
- cloneSuccessful = 0;
+ errors+=16;
}
CMGetProperty(instance, "noProperty", &rc);
if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY)
{
- return 1;
+ errors+=32;
}
CMGetPropertyAt(instance, 100, &returnedName, &rc);
if (rc.rc != CMPI_RC_ERR_NO_SUCH_PROPERTY)
{
- return 1;
+ errors+=64;
}
rc = instance->ft->release(instance);
- return 0;
+ return errors;
}
static int _testCMPIObjectPath ()
|