static void generateIndication2(const char *methodname, const CMPIContext *ctx) { CMPIInstance *inst; CMPIObjectPath *cop; CMPIDateTime *dat; CMPIArray *ar; CMPIStatus rc; char buffer[32]; if (enabled && activated2) { cop = CMNewObjectPath(broker, "root/interop2", "Test_Indication", &rc); inst = CMNewInstance(broker, cop, &rc); sprintf(buffer, "%d", _nextUID++); CMSetProperty(inst, "IndicationIdentifier", buffer, CMPI_chars); dat = CMNewDateTime(broker, &rc); CMSetProperty(inst, "IndicationTime", &dat, CMPI_dateTime); CMSetProperty(inst, "MethodName", methodname, CMPI_chars); ar = CMNewArray(broker, 0, CMPI_string, &rc); CMSetProperty(inst, "CorrelatedIndications", &ar, CMPI_stringA); rc = CBDeliverIndication(broker, ctx, "root/interop", inst); if (rc.rc != CMPI_RC_OK) { fprintf(stderr, "+++ Could not send the indication!\n"); } gen2++; } fprintf(stderr, "+++ generateIndication2() done %d\n", gen2); }
int _setProperty1 (CMPIInstance * ci, const char *p) { CMPIValue val; const char *property; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIData retData; property = p; PROV_LOG ("--- _setProperty: %s -> %s", p, property); if ((strncmp (property, "ElementName", 11) == 0) && (strlen (property) == 11)) { rc = CMSetProperty (ci, "ElementName", (CMPIValue *) _ClassName, CMPI_chars); } else if ((strncmp (property, "s", 1) == 0) && (strlen (property) == 1)) { rc = CMSetProperty (ci, "s", (CMPIValue *) "s", CMPI_chars); } else if ((strncmp (property, "c", 1) == 0) && (strlen (property) == 1)) { rc = CMSetProperty (ci, "c", (CMPIValue *) "c", CMPI_char16); } else if ((strncmp (property, "n32", 3) == 0) && (strlen (property) == 3)) { val.uint32 = 32; rc = CMSetProperty (ci, "n32", &val, CMPI_uint32); } else if ((strncmp (property, "n64", 3) == 0) && (strlen (property) == 3)) { val.uint64 = 64; rc = CMSetProperty (ci, "n64", &val, CMPI_uint64); } else if ((strncmp (property, "n16", 3) == 0) && (strlen (property) == 3)) { val.uint16 = 16; rc = CMSetProperty (ci, "n16", &val, CMPI_uint16); } else if ((strncmp (property, "n8", 2) == 0) && (strlen (property) == 2)) { val.uint8 = 8; rc = CMSetProperty (ci, "n8", &val, CMPI_uint8); } else if ((strncmp (property, "r32", 3) == 0) && (strlen (property) == 3)) { val.real32 = (CMPIReal32)1.23; rc = CMSetProperty (ci, "r32", &val, CMPI_real32); } else if ((strncmp (property, "r64", 3) == 0) && (strlen (property) == 3)) { val.real64 = 3.1415678928283; rc = CMSetProperty (ci, "r64", &val, CMPI_real64); } else if ((strncmp (property, "s64", 3) == 0) && (strlen (property) == 3)) { val.sint64 = 0xFFFFFFF; rc = CMSetProperty (ci, "s64", &val, CMPI_sint64); } else if ((strncmp (property, "s32", 3) == 0) && (strlen (property) == 3)) { val.sint32 = 0xDEADBEEF; rc = CMSetProperty (ci, "s32", &val, CMPI_sint32); } else if ((strncmp (property, "s16", 3) == 0) && (strlen (property) == 3)) { val.sint16 = (CMPISint16)0xFFFF; rc = CMSetProperty (ci, "s16", &val, CMPI_sint16); } else if ((strncmp (property, "s8", 2) == 0) && (strlen (property) == 2)) { val.sint8 = (CMPISint8)0xFF; rc = CMSetProperty (ci, "s8", &val, CMPI_sint8); } else if ((strncmp (property, "b", 1) == 0) && (strlen (property) == 1)) { val.boolean = 1; rc = CMSetProperty (ci, "b", &val, CMPI_boolean); } else if ((strncmp (property, "d", 1) == 0) && (strlen (property) == 1)) { PROV_LOG ("---- CMNewDateTime"); val.dateTime = CMNewDateTime (_broker, &rc); rc = CMSetProperty (ci, "d", &val, CMPI_dateTime); } else if ((strncmp (property, "*", 1) == 0) && (strlen (property) == 1)) { PROV_LOG ("---- All properties"); _setProperty1 (ci, "ElementName"); _setProperty1 (ci, "s"); _setProperty1 (ci, "c"); _setProperty1 (ci, "n64"); _setProperty1 (ci, "n32"); _setProperty1 (ci, "n16"); _setProperty1 (ci, "s64"); _setProperty1 (ci, "s32"); _setProperty1 (ci, "s16"); _setProperty1 (ci, "r64"); _setProperty1 (ci, "r32"); _setProperty1 (ci, "d"); _setProperty1 (ci, "b"); } else { PROV_LOG ("---- No implementation for property: %s", property); return 1; } return 0; }
// To increase the coverage in CMPIBrokerEnc.cpp static int _testBrokerEnc (const CMPIContext * ctx, const CMPIResult * rslt) { int flag = 1 ; int count; char* msgId; char* illegal; char path[100]; void* hdl; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *type; CMPIString *cmpiStr; CMPIBoolean bol=0; CMPIBoolean bool=0; CMPIArray* cmpiArray = NULL ; CMPIInstance* instance = NULL; CMPIInstance* instance1 = NULL; CMPIInstance* instanceErr = NULL; CMPIObjectPath* objPath = NULL; CMPIObjectPath* objPath1 = NULL; CMPICount cmpiCnt = 5; CMPIType cmpiType = CMPI_uint64; CMPIDateTime* cmpiDateTime = NULL ; CMPIMsgFileHandle msgFileHandle; CMPIEnumeration* cmpiEnum; CMPISelectExp* selExp; CMPIValue val; CMPIError* err; CMPIStatus* rc1 = NULL; CMPIArgs* args = NULL; void* handle; CMPIInstanceFT* funcTable; PROV_LOG ("++++ _testBrokerEnc "); PROV_LOG ("++++ ObjectPath testing"); objPath1 = CMNewObjectPath (_broker, NULL, _ClassName, &rc); PROV_LOG ("++++ New object path with NULL namespace creation : (%s)", strCMPIStatus (rc)); CMRelease(objPath1); objPath1 = CMNewObjectPath (_broker, _Namespace, "abc", &rc); PROV_LOG ("++++ New object path with wrong classname : (%s)", strCMPIStatus (rc)); instance = CMNewInstance(_broker, NULL, &rc); PROV_LOG ("++++ New Instance with NULL object path : (%s)", strCMPIStatus (rc)); handle = objPath1->hdl; objPath1->hdl=NULL; instance = CMNewInstance(_broker, objPath1, &rc); PROV_LOG ("++++ New Instance with object path handle set to NULL: (%s)", strCMPIStatus (rc)); objPath1->hdl = handle; objPath = make_ObjectPath(_broker, _Namespace, _ClassName); instance = CMNewInstance(_broker, objPath, &rc); PROV_LOG ("++++ New Instance creation status: (%s)", strCMPIStatus (rc)); instance1 = CMClone(instance, &rc); instanceErr = CMClone(instance, &rc); cmpiStr = CMNewString(_broker, NULL, &rc); PROV_LOG ("++++ Status of mbNewString with NULL parameter:(%s)", strCMPIStatus (rc)); err = CMNewCMPIError(_broker, "abc", "abc", "abc", 4, 5, 6, rc1); if (err) { PROV_LOG ("++++ CMNewCMPIError called with null rc"); } cmpiDateTime = CMNewDateTimeFromChars(_broker, "datetime", &rc); PROV_LOG ("++++ Status of CMNewDateTimeFromChars with junk parameter:(%s)", strCMPIStatus (rc)); if (!CMClassPathIsA(_broker, NULL, NULL, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } if (!CMClassPathIsA(_broker, objPath, NULL, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } illegal = "$"; if (!CMClassPathIsA(_broker, objPath, illegal, &rc)) { PROV_LOG ("++++ Error Status of CMClassPathIsA:(%s)", strCMPIStatus (rc)); } rc = CMLogMessage(_broker, 2, "TestProvider", "Testing Severity 2 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 2:(%s)", strCMPIStatus (rc)); rc = CMLogMessage(_broker, 3, "TestProvider", "Testing Severity 3 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 3:(%s)", strCMPIStatus (rc)); rc = CMLogMessage(_broker, 4, "TestProvider", "Testing Severity 4 in TestCMPIBrokerEnc", NULL); PROV_LOG ("++++ Status of CMLogMessage with Severity 4:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 2, "CMPIProvider", "Tracing for level 2", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 2:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 3, "CMPIProvider", "Tracing for level 3", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 3:(%s)", strCMPIStatus (rc)); rc = CMTraceMessage(_broker, 4, "CMPIProvider", "Tracing for level 4", NULL); PROV_LOG ("++++ Status of CMTraceMessage with level 4:(%s)", strCMPIStatus (rc)); cmpiStr = CMNewString(_broker, "Tracing for level 5", &rc); rc = CMTraceMessage(_broker, 5, "CMPIProvider", NULL, cmpiStr); PROV_LOG ("++++ Status of CMTraceMessage with level 5:(%s)", strCMPIStatus (rc)); CMRelease(cmpiStr); PROV_LOG ("++++ Calling mbEncToString function "); type = CDToString (_broker, _broker, &rc); PROV_LOG ("++++ Error status of mbEncToString with wrong object path:" " (%s)", strCMPIStatus (rc)); type = CDToString (_broker, NULL, &rc); PROV_LOG ("++++ Error status of mbEncToString with NULL parameter:" " (%s)", strCMPIStatus (rc)); type = CDToString (_broker, type, &rc); PROV_LOG ("++++ Passing CMPIString to mbEncToString successes : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, objPath, &rc); PROV_LOG ("++++ Passing CMPIObjectPath to mbEncToString successes : (%s)", strCMPIStatus (rc)); handle = objPath1->hdl; objPath1->hdl = NULL; type = CDToString (_broker, objPath1, &rc); if ( rc.rc == CMPI_RC_ERR_INVALID_PARAMETER) { PROV_LOG ("++++ Error status of mbEncToString with object path with " "NULL handle: (%s)", strCMPIStatus (rc)); } objPath1->hdl = handle; val.boolean = 1; rc = CMSetProperty (instance, "Boolean", &val, CMPI_boolean); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_boolean : (%s)", strCMPIStatus (rc)); val.uint8 = 8; rc = CMSetProperty (instance, "Uint8", &val, CMPI_uint8); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint8 : (%s)", strCMPIStatus (rc)); val.uint16 = 16; rc = CMSetProperty (instance, "Uint16", &val, CMPI_uint16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint16 : (%s)", strCMPIStatus (rc)); val.uint32 = 32; rc = CMSetProperty (instance, "Uint32", &val, CMPI_uint32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint32 : (%s)", strCMPIStatus (rc)); val.uint64 = 64; rc = CMSetProperty (instance, "Uint64", &val, CMPI_uint64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_uint64 : (%s)", strCMPIStatus (rc)); val.sint8 = -8; rc = CMSetProperty (instance, "Sint8", &val, CMPI_sint8); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint8 : (%s)", strCMPIStatus (rc)); val.sint16 = -16; rc = CMSetProperty (instance, "Sint16", &val, CMPI_sint16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint16 : (%s)", strCMPIStatus (rc)); val.sint32 = -32; rc = CMSetProperty (instance, "Sint32", &val, CMPI_sint32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint32 : (%s)", strCMPIStatus (rc)); val.sint64 = -64; rc = CMSetProperty (instance, "Sint64", &val, CMPI_sint64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_sint64 : (%s)", strCMPIStatus (rc)); val.real32 = 32.32; rc = CMSetProperty (instance, "Real32", &val, CMPI_real32); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real32 : (%s)", strCMPIStatus (rc)); val.real64 = 64.64; rc = CMSetProperty (instance, "Real64", &val, CMPI_real64); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_real64 : (%s)", strCMPIStatus (rc)); val.char16 = 'c'; rc = CMSetProperty (instance, "Char16", &val, CMPI_char16); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_char16 : (%s)", strCMPIStatus (rc)); cmpiDateTime = CMNewDateTime (_broker, &rc); val.dateTime = cmpiDateTime; rc = CMSetProperty (instance, "DateTime", &val, CMPI_dateTime); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_dateTime : (%s)", strCMPIStatus (rc)); val.ref = objPath; rc = CMSetProperty (instance, "Ref", &val, CMPI_ref); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_ref : (%s)", strCMPIStatus (rc)); val.inst = instance1; rc = CMSetProperty (instance, "Instance", &val, CMPI_instance); PROV_LOG ("++++ Status of CMSetProperty of type CMPI_instance : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, instance, &rc); PROV_LOG ("++++ Passing CMPIInstance to mbEncToString successes : (%s)", strCMPIStatus (rc)); args = CMNewArgs(_broker, &rc); PROV_LOG ("++++ Status of CMNewArgs : (%s)", strCMPIStatus (rc)); type = CDToString (_broker, args, &rc); PROV_LOG ("++++ Passing CMPIArgs to mbEncToString successes : (%s)", strCMPIStatus (rc)); PROV_LOG ("++++ Calling mbEncGetType function "); rc1 = NULL; type = CDGetType (_broker, NULL, rc1); if (!type) { PROV_LOG ("++++ Error calling mbEncGetType with NULL rc"); } rc1 = NULL; funcTable = instanceErr->ft; instanceErr->ft = NULL; type = CDGetType (_broker, instanceErr, rc1); if (!type) { PROV_LOG ("++++ Error calling mbEncGetType with wrong parameter and" " NULL rc"); } type = CDGetType (_broker, instanceErr, &rc); PROV_LOG ("++++ Error status of mbEncGetType with wrong input : (%s)", strCMPIStatus (rc)); instanceErr->ft = funcTable; type = CDGetType (_broker, NULL, &rc); PROV_LOG ("++++ Error status of mbEncGetType with NULL input : (%s)", strCMPIStatus (rc)); type = CDGetType (_broker, instance, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIInstance" " : (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, objPath, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIObjectPath:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); cmpiStr = CMNewString(_broker, "Test1", & rc); type = CDGetType (_broker, cmpiStr, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIString:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, _broker, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIBroker:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); cmpiArray = CMNewArray(_broker, cmpiCnt,cmpiType, &rc); type = CDGetType (_broker, cmpiArray, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIArray:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, cmpiDateTime, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIDateTime:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, ctx, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIContext:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, rslt, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIResult:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); rc1 = NULL; selExp = CMNewSelectExp(_broker, "SELECT c,b FROM TestCMPI_Indication WHERE c='c' OR b=1", "WQL", NULL, rc1); PROV_LOG ("++++ CMNewSelectExp with rc set to NULL Called"); selExp = CMNewSelectExp(_broker, "SELECT c,b FROM TestCMPI_Indication", "WQL", NULL, &rc); PROV_LOG ("++++ Status of CMNewSelectExp: (%s) ", strCMPIStatus (rc)); type = CDGetType (_broker, selExp, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPISelectExp:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); handle = objPath1->hdl; objPath1->hdl = NULL; rc = CMRelease(objPath1); PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)", strCMPIStatus (rc)); objPath1->hdl = handle; rc = CMRelease(objPath1); PROV_LOG ("++++ Status of CMRelease(objPath1): (%s)", strCMPIStatus (rc)); objPath1 = CMNewObjectPath(_broker, "test/TestProvider", "TestCMPI_Instance", &rc); PROV_LOG ("++++ Status of CMNewObjectPath for TestCMPI_Instance : (%s)", strCMPIStatus (rc)); PROV_LOG_CLOSE(); cmpiEnum = CBEnumInstances(_broker, ctx, objPath1, NULL, &rc); PROV_LOG_OPEN (_ClassName, _ProviderLocation); PROV_LOG ("++++ Status of CBEnumInstances : (%s)", strCMPIStatus (rc)); type = CDGetType (_broker, cmpiEnum, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIEnumeration:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CDGetType (_broker, args, &rc); PROV_LOG ("++++ Status of mbEncGetType with input of type CMPIArgs:" " (%s) type(%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); PROV_LOG ("++++ Calling mbEncIsOfType function "); bol = CDIsOfType (_broker, NULL, "No object", rc1); if(!bol) { PROV_LOG ("++++Calling mbEncIsOfType with NULL rc and wrong" " parameters"); } bol = CDIsOfType (_broker, instance, "CMPIInstance", rc1); if(!bol) { PROV_LOG ("++++ Calling mbEncIsOfType with NULL rc"); } bol = CDIsOfType (_broker, NULL, "No object", &rc); PROV_LOG ("++++ Error Status of mbEncIsOfType : (%s)", strCMPIStatus (rc)); bol = CDIsOfType (_broker, instance, "CMPIInstance", &rc); if ( bol ) { PROV_LOG ("++++ CDIsOfType for CMPIInstance status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, instance, "CMPI", &rc); if ( !bol ) { PROV_LOG ("++++ CDIsOfType for CMPIInstance status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, objPath, "CMPIObjectPath", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIObjectPath status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, objPath, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIObjectPath status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiDateTime, "CMPIDateTime", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIDateTime status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiDateTime, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIDateTime status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiStr, "CMPIString", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIString status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiStr, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIString status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, _broker, "CMPIBroker", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIBroker status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, _broker, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIBroker status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiArray, "CMPIArray", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIArray status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiArray, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIArray status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, rslt, "CMPIResult", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIResult status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, rslt, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIResult status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, ctx, "CMPIContext", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, ctx, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIContext status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiEnum, "CMPIEnumeration", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIEnumeration status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, cmpiEnum, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPIEnumeration status is (%s) : %d", strCMPIStatus (rc), bol); } /* Testcase to increase coverage in CMPI_Enumeration.cpp*/ rc = CMRelease(cmpiEnum); PROV_LOG ("++++ Status of CMRelease on cmpiEnum :(%s)", strCMPIStatus (rc)); /**********************************************************/ bol = CDIsOfType (_broker, selExp, "CMPISelectExp", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPISelectExp status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, selExp, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CDIsOfType for CMPISelectExp status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, args, "CMPIArgs", &rc); if (bol) { PROV_LOG ("++++ CDIsOfType for CMPIArgs status is (%s) : %d", strCMPIStatus (rc), bol); } bol = CDIsOfType (_broker, args, "CMPI", &rc); if (!bol) { PROV_LOG ("++++ CdIsOfType for CMPIArgs status is (%s) : %d", strCMPIStatus (rc), bol); } type = CMGetMessage (_broker, "msgid", "Test 0 arguments", &rc, 0); PROV_LOG ("++++ Status of GetMessage with 0 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0", &rc, CMFmtArgs1(CMFmtChars("one argument"))); PROV_LOG ("++++ Status of GetMessage with 1 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1", &rc, CMFmtArgs2(CMFmtChars("Sint32 ::"), CMFmtSint(-1))); PROV_LOG ("++++ Status of GetMessage with 2 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2", &rc, CMFmtArgs3(CMFmtChars("Sint32, Uint32 ::"), CMFmtSint(-1), CMFmtUint(1))); PROV_LOG ("++++ Status of GetMessage with 3 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3", &rc, CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64))); PROV_LOG ("++++ Status of GetMessage with 4 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4", &rc, CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64))); PROV_LOG ("++++ Status of GetMessage with 5 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5", &rc, CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 ::"), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64))); PROV_LOG ("++++ Status of GetMessage with 6 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6", &rc, CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean:: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1))); PROV_LOG ("++++ Status of GetMessage with 7 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6, $7", &rc, CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars:: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"))); PROV_LOG ("++++ Status of GetMessage with 8 arguments(%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage (_broker, "msgid", "Test $0 $1, $2, $3, $4, $5, $6, $7, $8", &rc, CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars, String :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"), CMFmtString(cmpiStr))); PROV_LOG ("++++ Status of GetMessage with 9 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); strcpy(path,"path"); rc = CMOpenMessageFile(_broker, path, &msgFileHandle); PROV_LOG ("++++ Status of CMOpenMessageFile (%s) ", strCMPIStatus (rc)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test zero arguments", &rc, 0); PROV_LOG ("++++ Status of GetMessage2 with 0 argument (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0", &rc, CMFmtArgs1(CMFmtChars("Single argument"))); PROV_LOG ("++++ Status of GetMessage2 with 1 argument (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2(_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1", &rc, CMFmtArgs2(CMFmtChars("Sint32 ::"),CMFmtSint(1))); PROV_LOG ("++++ Status of GetMessage2 with 2 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2", &rc, CMFmtArgs3(CMFmtChars("Sint32, Uint32 :: "), CMFmtSint(-1), CMFmtUint(1))); PROV_LOG ("++++ Status of GetMessage2 with 3 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3", &rc, CMFmtArgs4(CMFmtChars("Sint32, Uint32, Sint64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64))); PROV_LOG ("++++ Status of GetMessage2 with 4 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4", &rc, CMFmtArgs5(CMFmtChars("Sint32, Uint32, Sint64, Uint64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64))); PROV_LOG ("++++ Status of GetMessage2 with 5 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5", &rc, CMFmtArgs6(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64 :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64))); PROV_LOG ("++++ Status of GetMessage2 with 6 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6", &rc, CMFmtArgs7(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1))); PROV_LOG ("++++ Status of GetMessage2 with 7 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6, $7", &rc, CMFmtArgs8(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"))); PROV_LOG ("++++ Status of GetMessage2 with 8 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); type = CMGetMessage2 (_broker, "Common.CIMStatusCode.CIM_ERR_SUCCESS", msgFileHandle, "Test $0 $1, $2, $3, $4, $5, $6, $7, $8", &rc, CMFmtArgs9(CMFmtChars("Sint32, Uint32, Sint64, Uint64, Real64," " Boolean, chars, String :: "), CMFmtSint(-1), CMFmtUint(1), CMFmtSint64(-64), CMFmtUint64(64), CMFmtReal(64.64), CMFmtBoolean(1), CMFmtChars("chars"), CMFmtString(cmpiStr))); PROV_LOG ("++++ Status of GetMessage2 with 9 arguments (%s) type (%s)", strCMPIStatus (rc), CMGetCharsPtr(type, NULL)); rc = CMCloseMessageFile(_broker, msgFileHandle); PROV_LOG ("++++ Status of CMCloseMessageFile (%s) ", strCMPIStatus (rc)); CMRelease(instance1); CMRelease(instanceErr); return flag ; }
static int _testCMPIDateTime() { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIBoolean isInterval = 0; CMPIBoolean interval = 0; CMPIBoolean cloneSuccessful = 0; CMPIBoolean binaryDateTimeEqual = 0; CMPIDateTime *dateTime = NULL; CMPIDateTime *new_dateTime = NULL; CMPIDateTime *clonedDateTime = NULL; CMPIDateTime *dateTimeFromBinary = NULL; CMPIUint64 dateTimeInBinary = UINT64_LITERAL(1150892800000000); CMPIUint64 returnedDateTimeInBinary = 0; CMPIString *stringDate = NULL; CMPIString *clonedStringDate = NULL; const char *normalString = NULL; const char *clonedString = NULL; void *dtptr; dateTime = CMNewDateTime(_broker, &rc); if (dateTime == NULL) { return 1; } dateTimeFromBinary = CMNewDateTimeFromBinary(_broker, dateTimeInBinary, interval, &rc); returnedDateTimeInBinary = CMGetBinaryFormat(dateTimeFromBinary, &rc); if (dateTimeInBinary == returnedDateTimeInBinary) { binaryDateTimeEqual = 1; } isInterval = CMIsInterval(dateTime, &rc); interval = 1; new_dateTime = CMNewDateTimeFromBinary(_broker, dateTimeInBinary, interval, &rc); isInterval = CMIsInterval(new_dateTime, &rc); clonedDateTime = dateTime->ft->clone(dateTime, &rc); stringDate = CMGetStringFormat(dateTime, &rc); clonedStringDate = CMGetStringFormat(clonedDateTime, &rc); rc = clonedDateTime->ft->release(clonedDateTime); normalString = CMGetCharsPtr(stringDate, &rc); clonedString = CMGetCharsPtr(clonedStringDate, &rc); if (strcmp(normalString, clonedString) == 0) { cloneSuccessful = 1; } dtptr = dateTime->hdl; dateTime->hdl = NULL; CMGetBinaryFormat(dateTime, &rc); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } dateTime->ft->clone(dateTime, &rc); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } CMGetStringFormat(dateTime, &rc); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } rc = dateTime->ft->release(dateTime); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } dateTime->hdl = dtptr; rc = dateTime->ft->release(dateTime); return 0; }
static int _testArrayTypes() { struct array_types { CMPIType element_type; CMPIType typeA; char *typeName; char *typeAName; char *args_name; } types_arr[] = { { CMPI_uint32, CMPI_uint32A, "CMPI_uint32", "CMPI_uint32A", "CMPI_uint32_array"}, { CMPI_uint16, CMPI_uint16A, "CMPI_uint16", "CMPI_uint16A", "CMPI_uint16_array"}, { CMPI_uint8, CMPI_uint8A, "CMPI_uint8", "CMPI_uint8A", "CMPI_uint8_array"}, { CMPI_uint64, CMPI_uint64A, "CMPI_uint64", "CMPI_uint64A", "CMPI_uint64_array"}, { CMPI_sint32, CMPI_sint32A, "CMPI_sint32", "CMPI_sint32A", "CMPI_sint32_array"}, { CMPI_sint16, CMPI_sint16A, "CMPI_sint16", "CMPI_sint16A", "CMPI_sint16_array"}, { CMPI_sint8, CMPI_sint8A, "CMPI_sint8", "CMPI_sint8A", "CMPI_sint8_array"}, { CMPI_sint64, CMPI_sint64A, "CMPI_sint64", "CMPI_sint64A", "CMPI_sint64_array"}, { CMPI_real32, CMPI_real32A, "CMPI_real32", "CMPI_real32A", "CMPI_real32_array"}, { CMPI_real64, CMPI_real64A, "CMPI_real64", "CMPI_real64A", "CMPI_real64_array"}, { CMPI_char16, CMPI_char16A, "CMPI_char16", "CMPI_char16A", "CMPI_char16_array"}, { CMPI_boolean, CMPI_booleanA, "CMPI_boolean", "CMPI_booleanA", "CMPI_boolean_array"}, { CMPI_string, CMPI_stringA, "CMPI_string", "CMPI_stringA", "CMPI_string_array"}, { CMPI_dateTime, CMPI_dateTimeA, "CMPI_dateTime", "CMPI_dateTimeA", "CMPI_dateTime_array"}, { CMPI_ref, CMPI_refA, "CMPI_ref", "CMPI_refA", "CMPI_ref_array"}, { CMPI_instance, CMPI_instanceA, "CMPI_instance", "CMPI_instanceA", "CMPI_instance_array"}, { CMPI_null, CMPI_ARRAY, "Invalid", "InvalidArray", "Invalid_array"}}; int i, flag, size; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIStatus rc1 = { CMPI_RC_OK, NULL }; CMPIArray *arr = NULL; CMPIString *retNamespace = NULL; CMPIString *retClassname = NULL; CMPIValue value, value1; CMPIData data; CMPIData arr_data; CMPIData dataInst; CMPIData retDataInst; CMPIArgs *args_ptr = NULL; CMPIObjectPath *objPath = make_ObjectPath(_broker, _Namespace, _ClassName); CMPIUint64 datetime1, datetime2; const char *str1; const char *str2; size = 17; for (i = 0; i < size; i++) { args_ptr = CMNewArgs(_broker, &rc); switch (types_arr[i].element_type) { case CMPI_uint32: value.uint32 = 56; break; case CMPI_uint16: value.uint16 = 32; break; case CMPI_uint8: value.uint8 = 56; break; case CMPI_uint64: value.uint64 = 32; break; case CMPI_sint32: value.sint32 = -56; break; case CMPI_sint16: value.sint16 = -32; break; case CMPI_sint8: value.sint8 = -56; break; case CMPI_sint64: value.sint64 = -32; break; case CMPI_real32: value.real32 = (CMPIReal32) -32.78; break; case CMPI_real64: value.real64 = -899.32; break; case CMPI_char16: value.char16 = 'k'; break; case CMPI_string: value.string = CMNewString(_broker, "string", &rc); break; case CMPI_boolean: value.boolean = 1; break; case CMPI_dateTime: value.dateTime = CMNewDateTime(_broker, &rc); break; case CMPI_ref: value.ref = CMNewObjectPath(_broker, "root/cimv2", "Sample_Instance", &rc); break; case CMPI_null: value.args = NULL; break; case CMPI_instance: value.inst = make_Instance(objPath); value1.uint32 = 20; rc = CMSetProperty(value.inst, "Property1", &value1, CMPI_uint32); break; } arr = NULL; rc = CMAddArg(args_ptr, "EmptyArray", (CMPIValue *) & arr, types_arr[i].typeA); arr = CMNewArray(_broker, 1, types_arr[i].element_type, &rc); rc = CMSetArrayElementAt(arr, 0, &value, types_arr[i].element_type); rc = CMAddArg(args_ptr, types_arr[i].args_name, (CMPIValue *) & arr, types_arr[i].typeA); flag = 1; if ((types_arr[i].element_type) != CMPI_null) { data = CMGetArg(args_ptr, types_arr[i].args_name, &rc); arr_data = CMGetArrayElementAt(data.value.array, 0, &rc); switch (types_arr[i].element_type) { case CMPI_uint32: if (arr_data.value.uint32 != value.uint32) { flag = 0; } break; case CMPI_uint16: if (arr_data.value.uint16 != value.uint16) { flag = 0; } break; case CMPI_uint8: if (arr_data.value.uint8 != value.uint8) { flag = 0; } break; case CMPI_uint64: if (arr_data.value.uint64 != value.uint64) { flag = 0; } break; case CMPI_sint32: if (arr_data.value.sint32 != value.sint32) { flag = 0; } break; case CMPI_sint16: if (arr_data.value.sint16 != value.sint16) { flag = 0; } break; case CMPI_sint8: if (arr_data.value.sint8 != value.sint8) { flag = 0; } break; case CMPI_sint64: if (arr_data.value.sint64 != value.sint64) { flag = 0; } break; case CMPI_real32: if (arr_data.value.real32 != value.real32) { flag = 0; } break; case CMPI_real64: if (arr_data.value.real64 != value.real64) { flag = 0; } break; case CMPI_char16: if (arr_data.value.char16 != value.char16) { flag = 0; } break; case CMPI_string: str1 = CMGetCharsPtr(arr_data.value.string, &rc); str2 = CMGetCharsPtr(value.string, &rc1); if ((rc.rc != CMPI_RC_OK) || (rc1.rc != CMPI_RC_OK) || strcmp(str1, str2)) { flag = 0; } break; case CMPI_boolean: if (arr_data.value.boolean != value.boolean) { flag = 0; } break; case CMPI_dateTime: datetime1 = CMGetBinaryFormat(arr_data.value.dateTime, &rc); datetime2 = CMGetBinaryFormat(value.dateTime, &rc1); if ((rc.rc != CMPI_RC_OK) || (rc1.rc != CMPI_RC_OK) || (datetime1 != datetime2)) { flag = 0; } rc = CMRelease(value.dateTime); break; case CMPI_ref: retNamespace = CMGetNameSpace(arr_data.value.ref, &rc); retClassname = CMGetClassName(arr_data.value.ref, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { str1 = CMGetCharsPtr(retNamespace, &rc); str2 = CMGetCharsPtr(retClassname, &rc1); if ((rc.rc == CMPI_RC_OK) && (rc1.rc == CMPI_RC_OK)) { if ((strcmp(str1, "root/cimv2")) || (strcmp(str2, "TestCMPI_Instance"))) { flag = 0; } } else { flag = 0; } } else { flag = 0; } rc = CMRelease(value.ref); break; case CMPI_instance: retDataInst = CMGetProperty(arr_data.value.inst, "Property1", &rc); dataInst = CMGetProperty(value.inst, "Property1", &rc); if (retDataInst.value.uint32 != dataInst.value.uint32) { flag = 0; } rc = CMRelease(value.inst); break; } if (data.type == types_arr[i].typeA && flag) { } } rc = CMRelease(arr); rc = CMRelease(args_ptr); } return flag; }