From: yeechan <ibm...@us...> - 2005-07-22 22:05:01
|
Update of /cvsroot/sblim/cmpi-tests/cmpi-instancetest/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26083 Modified Files: TST_InstanceTest.c Log Message: #di failed - lisa Index: TST_InstanceTest.c =================================================================== RCS file: /cvsroot/sblim/cmpi-tests/cmpi-instancetest/src/TST_InstanceTest.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- TST_InstanceTest.c 31 May 2005 19:30:36 -0000 1.8 +++ TST_InstanceTest.c 22 Jul 2005 22:04:46 -0000 1.9 @@ -19,7 +19,7 @@ #include "cmpidt.h" #include "cmpift.h" #include "cmpimacs.h" - +#include <stdio.h> /* NULL terminated list of classnames supported by this provider */ static char * _CLASSNAMES[] = {"TST_InstanceProperties", "TST_InstanceKeys", "TST_InstanceDefaults", NULL}; @@ -27,7 +27,7 @@ static char _NAMESPACE[] = "root/cimv2"; /* NULL terminated list of property names for the class(es) */ -static char * _PROPERTYNAMES[] = {"CreationClassName", "Id", "Property_string", "Property_uint8", "Property_uint16", "Property_uint32", "Property_uint64", "Property_sint8", "Property_sint16", "Property_sint32", "Property_sint64", "Property_boolean", "Property_real32", "Property_real64", "Property_dateTime", "Property_char16", NULL}; +static char * _PROPERTYNAMES[] = {"CreationClassName", "Id", "Property_string1", "Property_string2", "Property_uint8", "Property_uint16", "Property_uint32", "Property_uint64", "Property_sint8", "Property_sint16", "Property_sint32", "Property_sint64", "Property_boolean", "Property_real32", "Property_real64", "Property_dateTime", "Property_char16", NULL}; /* NULL terminated list of key names for the class(es) */ static char * _KEYNAMES[] = {"CreationClassName", "Id", NULL}; @@ -53,7 +53,8 @@ char CreationClassName[_MAXSTRINGLENGTH]; char Id[_MAXSTRINGLENGTH]; /* ADD MORE INSTANCE DATA HERE */ - char Property_string[_MAXSTRINGLENGTH]; + char Property_string1[_MAXSTRINGLENGTH]; + CMPIString * Property_string2; CMPIUint8 Property_uint8; CMPIUint16 Property_uint16; CMPIUint32 Property_uint32; @@ -278,8 +279,9 @@ else if (strncmp(namestring, "Property_", strlen("Property_")) == 0) { _OSBASE_TRACE(2,("%s:_testpropertytype() property type=%s, data type=%s(%d)", _PROVIDERNAME, namestring+9, typestring+5, type)); - if (strcmp(namestring+9, typestring+5) != 0) { - _OSBASE_TRACE(1,("%s:_testpropertytype() wrong property type", _PROVIDERNAME)); + if (strcmp(namestring+9, typestring+5) != 0 && + (strncmp(namestring+9, "string", 6) || strcmp(typestring+5, "string"))) { + _OSBASE_TRACE(1,("%s:_testpropertytype() wrong property type (\"%s\" != \"%s\")", _PROVIDERNAME, namestring+9, typestring+5)); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_TYPE_MISMATCH, "wrong property type"); goto exit; } @@ -310,6 +312,7 @@ /* Check for NULL property value state */ if (CMIsNullValue(data)) { _OSBASE_TRACE(1,("%s:_testpropertystate() property value is NULL", _PROVIDERNAME)); + CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_FAILED, "NULL property value"); goto exit; } @@ -385,10 +388,16 @@ if (strcmp(CMGetCharPtr(value.string), instancedata->Id) != 0) goto error; } - else if (strcmp(namestring, "Property_string") == 0) { + else if (strcmp(namestring, "Property_string1") == 0) { _OSBASE_TRACE(2,("%s:_testpropertyvalue() property value=\"%s\", data value=\"%s\"", _PROVIDERNAME, - CMGetCharPtr(value.string), instancedata->Property_string)); - if (strcmp(CMGetCharPtr(value.string),instancedata->Property_string) != 0) goto error; + CMGetCharPtr(value.string), instancedata->Property_string1)); + if (strcmp(CMGetCharPtr(value.string),instancedata->Property_string1) != 0) goto error; + } + + else if (strcmp(namestring, "Property_string2") == 0) { + _OSBASE_TRACE(2,("%s:_testpropertyvalue() property value=\"%s\", data value=\"%s\"", _PROVIDERNAME, + CMGetCharPtr(value.string), instancedata->Property_string2->hdl)); + if (strcmp(CMGetCharPtr(value.string),instancedata->Property_string2->hdl) != 0) goto error; } else if (strcmp(namestring, "Property_uint8") == 0) { @@ -460,12 +469,13 @@ else if (strcmp(namestring, "Property_dateTime") == 0) { /* Get the property dateTime string value */ CMPIString * datetimestr1 = CMGetStringFormat(value.dateTime, &status); - if (status.rc != CMPI_RC_OK) { + if (status.rc != CMPI_RC_OK) { _OSBASE_TRACE(1,("%s:_testpropertyvalue() CMGetStringFormat(property value) failed", _PROVIDERNAME)); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR_SYSTEM, "CMGetStringFormat() failed"); - goto exit; + goto exit; } + /* Get the instance data dateTime string value */ CMPIString * datetimestr2 = CMGetStringFormat(instancedata->Property_dateTime, &status); if (status.rc != CMPI_RC_OK) { @@ -477,14 +487,22 @@ /* Compare dateTime's using their string format */ _OSBASE_TRACE(2,("%s:_testpropertyvalue() property value=%s, data value=%s", _PROVIDERNAME, CMGetCharPtr(datetimestr1), CMGetCharPtr(datetimestr2))); - if (strcmp(CMGetCharPtr(datetimestr1), CMGetCharPtr(datetimestr2)) != 0) goto error; + if (strcmp(CMGetCharPtr(datetimestr1), CMGetCharPtr(datetimestr2)) != 0) + { + printf ("_testpropropertyvalue compare dateTime string format \n"); + fflush (stdout); + goto error; + } + + printf ("_testpropropertyvalue FINISHED compare dateTime string format \n"); + fflush (stdout); /* Get the property dateTime binary value */ CMPIUint64 datetime1 = CMGetBinaryFormat(value.dateTime, &status); if (status.rc != CMPI_RC_OK) { _OSBASE_TRACE(1,("%s:_testpropertyvalue() CMGetBinaryFormat(property value) failed", _PROVIDERNAME)); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR_SYSTEM, "CMGetBinaryFormat() failed"); - goto exit; + goto exit; } /* Get the instance data dateTime binary value */ @@ -520,13 +538,19 @@ exit: _OSBASE_TRACE(1,("%s:_testpropertyvalue() %s", _PROVIDERNAME, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); + + + return status; + + } // ---------------------------------------------------------------------------- + /* _testproperties() - test all properties of the CIM instance against the raw instance data */ CMPIStatus _testproperties( CMPIInstance * instance, _INSTANCEDATA * instancedata ) { @@ -609,12 +633,11 @@ exit: _OSBASE_TRACE(1,("%s:_testproperties() %s", _PROVIDERNAME, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; + } // ---------------------------------------------------------------------------- - - /* _testinstance() - run tests on the specified instance against the (optional) instance data. If instancedata is NULL then skip associated tests */ CMPIStatus _testinstance( CMPIInstance * instance, _INSTANCEDATA * instancedata ) @@ -632,7 +655,7 @@ /* Test instance properties */ status = _testproperties(instance, instancedata); - if (status.rc != CMPI_RC_OK) goto exit; + /* if (status.rc != CMPI_RC_OK) */ goto exit; /* Finished */ exit: @@ -911,8 +934,12 @@ CMSetProperty(*instance, "CreationClassName", instancedata->CreationClassName, CMPI_chars); CMSetProperty(*instance, "Id", instancedata->Id, CMPI_chars); /* ADD MORE CMSetProperty() COMMANDS FOR OTHER INSTANCE DATA HERE */ - CMSetProperty(*instance, "Property_string", (CMPIValue *)&(instancedata->Property_string), CMPI_chars); - CMSetProperty(*instance, "Property_uint8", (CMPIValue *)&(instancedata->Property_uint8) , CMPI_uint8); + CMSetProperty(*instance, "Property_string1", (CMPIValue *)&(instancedata->Property_string1), CMPI_chars); + + CMSetProperty(*instance, "Property_string2", (CMPIValue *)&(instancedata->Property_string2), CMPI_string); + + CMSetProperty(*instance, "Property_uint8", (CMPIValue *)&(instancedata->Property_uint8) , CMPI_uint8); + CMSetProperty(*instance, "Property_uint16", (CMPIValue *)&(instancedata->Property_uint16), CMPI_uint16); CMSetProperty(*instance, "Property_uint32", (CMPIValue *)&(instancedata->Property_uint32), CMPI_uint32); CMSetProperty(*instance, "Property_uint64", (CMPIValue *)&(instancedata->Property_uint64), CMPI_uint64); @@ -923,11 +950,16 @@ CMSetProperty(*instance, "Property_boolean", (CMPIValue *)&(instancedata->Property_boolean), CMPI_boolean); CMSetProperty(*instance, "Property_real32", (CMPIValue *)&(instancedata->Property_real32), CMPI_real32); CMSetProperty(*instance, "Property_real64", (CMPIValue *)&(instancedata->Property_real64), CMPI_real64); + CMSetProperty(*instance, "Property_dateTime", (CMPIValue *)&instancedata->Property_dateTime, CMPI_dateTime); + +CMPIData data = CMGetProperty(*instance, "Property_dateTime", NULL); + CMSetProperty(*instance, "Property_char16", (CMPIValue *)&(instancedata->Property_char16), CMPI_char16); + /* Finished */ -exit: +exit: _OSBASE_TRACE(1,("%s:_makeinstance() %s", _PROVIDERNAME, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); return status; } @@ -974,6 +1006,19 @@ instances[sizeinstances-1] = newinstance; instances[sizeinstances] = NULL; sizeinstances++; + +{ +struct native_instance { +CMPIInstance instance; + int mem_state; + char **property_list; + char **key_list; +}; + +printf("++++++++ADDING new instance %d \n", ((struct native_instance *) newinstance)->mem_state); +fflush(stdout); +} + /* Instances list is always NULL terminated */ /* Finished */ @@ -1002,24 +1047,45 @@ _OSBASE_TRACE(1,("%s:_getinstanceindex() No object path specified", _PROVIDERNAME)); return sizeinstances; } +printf("getinstanceindex OP done \n"); +fflush (stdout); /* Look thru the list of instances for one with a matching object path */ for (i=0; i<sizeinstances; i++) { if (instances[i] == NULL) continue; +printf("instance list \n"); +fflush (stdout); + /* Check if this instance's object path matches the reference */ objectpath = CMGetObjectPath(instances[i], NULL); + +printf("CMGetObjectPath \n"); +fflush (stdout); + CMSetNameSpace(objectpath, CMGetCharPtr(CMGetNameSpace(reference,NULL))); - if (_CMSameObject(objectpath, reference)) { + +printf("CMSetNameSpace \n"); +fflush (stdout); + + if (_CMSameObject(objectpath, reference)) { found++; - break; - } +printf("CMSameObject done %s__,reference__%x, \n", objectpath, reference); +fflush (stdout); + break; + } + +printf("check Matching objectPath\n"); +fflush (stdout); } +printf("finished getinstanceindex\n"); +fflush (stdout); + /* Finished */ _OSBASE_TRACE(1,("%s:_getinstanceindex() %s", _PROVIDERNAME, (found)? "succeeded":"failed")); if (found) return i; - else return sizeinstances; /* Note - instances list is always NULL terminated */ + else return sizeinstances-1; /* Note - instances list is always NULL terminated */ } @@ -1282,7 +1348,8 @@ /* Run tests on the new instance */ status = _testinstance(newinstance, NULL); - if (status.rc != CMPI_RC_OK) goto exit; + if (status.rc != CMPI_RC_OK) + goto exit; /* Get the object path of the new instance */ newobjectpath = CMGetObjectPath(newinstance, &status); @@ -1331,10 +1398,14 @@ CMReturnObjectPath(results, newobjectpath); /* Finished */ + CMReturnDone(results); exit: + _OSBASE_TRACE(1,("%s:CreateInstance() %s", self->ft->miName, (status.rc == CMPI_RC_OK)? "succeeded":"failed")); - return status; + + return status; + } @@ -1360,6 +1431,9 @@ /* Locate the instance in the internal list of instances */ index = _getinstanceindex(reference); +printf("deleteInstance() _getinstanceindex done, %d \n", index); +fflush(stdout); + /* Check if found the desired instance */ if (instances[index] == NULL) { _OSBASE_TRACE(1,("%s:DeleteInstance() Requested instance not found", self->ft->miName)); @@ -1367,10 +1441,21 @@ goto exit; } +printf("instance is not null, %d \n", index); +printf("the CMRelease FT %x \n",(instances[index])->ft->release); +fflush(stdout); + /* Remove the instance from the internal list of instances */ CMRelease(instances[index]); + +printf("remove instances, %d \n", index); +fflush(stdout); + instances[index] = NULL; +printf("instance index is Null, %d \n", index); +fflush(stdout); + /* Finished */ CMReturnDone(results); exit: @@ -1498,7 +1583,8 @@ CMPIInstance * newinstance = NULL; /* New instance to add to the internal list */ CMPIObjectPath * newobjectpath = NULL; /* New object path for each new instance */ int instancenum = 1; /* Number of instances to populate the internal list */ - + //lisa - declaring instance + _OSBASE_TRACE(1,("%s:Initialize() called", self->ft->miName)); /* Copy the provider name for later use */ @@ -1521,7 +1607,10 @@ /* Create a new TST_InstanceDefaults instance from the raw data */ strncpy(newinstancedata.CreationClassName, "TST_InstanceDefaults", _MAXSTRINGLENGTH); - status = _makeinstance(&newinstance, &newinstancedata, newinstancedata.CreationClassName); + newinstancedata.Property_string2=NULL; + // newinstancedata.Property_dateTime = CMNewDateTimeFromChars(_BROKER,"20050503104354.000000:000",NULL); + newinstancedata.Property_dateTime=NULL; + status = _makeinstance(&newinstance, &newinstancedata, newinstancedata.CreationClassName); if (status.rc != CMPI_RC_OK) { _OSBASE_TRACE(1,("%s:Initialize() _makeinstance() failed", self->ft->miName)); goto exit; @@ -1529,11 +1618,16 @@ /* Run tests on the newly created instance */ status = _testinstance(newinstance, NULL); - if (status.rc != CMPI_RC_OK) goto exit; + /* if (status.rc != CMPI_RC_OK) goto exit; */ /* Get the object path of the newly created instance */ - newobjectpath = CMGetObjectPath(newinstance, &status); - if (status.rc != CMPI_RC_OK) { +//printf("instance=%s", CDToString(_BROKER, newinstance, NULL)); +//fflush(stdout); + + newobjectpath = CMGetObjectPath(newinstance, &status); +printf("%s\n" ); +fflush (stdout); + if (status.rc != CMPI_RC_OK) { _OSBASE_TRACE(1,("%s:Initialize() CMGetObjectPath() failed", self->ft->miName)); goto exit; } @@ -1557,7 +1651,21 @@ } /* Initialize the rest of the raw instance data */ - snprintf(newinstancedata.Property_string, _MAXSTRINGLENGTH, "This is instance #%d", instancenum); + snprintf(newinstancedata.Property_string1, _MAXSTRINGLENGTH, "This is instance #%d", instancenum); + +printf ("print string2 (mb)->eft->newString %X \n ", _BROKER ->eft->newString); +fflush (stdout); + +newinstancedata.Property_string2=CMNewString(_BROKER, "This is the New String Value using CMPIString", NULL); + +printf("TOO COMPLICATED --> %s\n", newinstancedata.Property_string2->hdl); +printf("try CMGetCharPtr -> %s\n", CMGetCharPtr(newinstancedata.Property_string2)); + +//printf("%s\n", CMGetCharPtr(CMNewString(_BROKER, "foobar", NULL))); +//fflush (stdout); + + /*snprintf(newinstancedata.Property_string2, mynewstring);*/ + /*newinstancedata.Property_string2=mynewstring;*/ newinstancedata.Property_uint8 = (CMPIUint8)255; newinstancedata.Property_uint16 = (CMPIUint16)65535; newinstancedata.Property_uint32 = (CMPIUint32)65535*65535; @@ -1570,6 +1678,13 @@ newinstancedata.Property_real32 = (CMPIReal32)0.123456e38; newinstancedata.Property_real64 = (CMPIReal64)0.123456789012345e38; newinstancedata.Property_dateTime = CMNewDateTimeFromChars(_BROKER,"20050503104354.000000:000",NULL); + +/*lisa - test Property_dateTime raw data initialize, then CMSetProperty, CMGetProperty*/ + +//newinstance = CMNewInstance(_BROKER, objectpath, &status); +//CMSetProperty(newinstance, "Property_dateTime", (CMPIValue *)&newinstancedata.Property_dateTime, CMPI_dateTime); + + newinstancedata.Property_char16 = (CMPIChar16)'a'; _OSBASE_TRACE(1,("%s:Initialize() creating new instance", self->ft->miName)); @@ -1581,10 +1696,10 @@ _OSBASE_TRACE(1,("%s:Initialize() _makeinstance() failed", self->ft->miName)); goto exit; } - /* Run tests on the newly created instance */ status = _testinstance(newinstance, &newinstancedata); - if (status.rc != CMPI_RC_OK) goto exit; + //if (status.rc != CMPI_RC_OK) + //goto exit; /* Get the object path of the newly created instance */ newobjectpath = CMGetObjectPath(newinstance, &status); |