CMPIData instance_accessor ( const char *name, void *param) { CMPIData data = { 0, CMPI_null, {0} }; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIBroker *broker = (CMPIBroker *) param; PROV_LOG ("-- #4.2 instance_accessor"); PROV_LOG ("-- Property: %s", name); /* SELECT * FROM CIM_InstModification WHERE (SourceInstance="Boo" OR SourceInstance="Hello") AND PreviousInstance !="Hello again"] */ if (strcmp ("PropertyA", name) == 0) { data.type = CMPI_string; data.state = CMPI_goodValue; data.value.string = CMNewString (broker, "AccessorPropertyA", &rc); } if (strcmp ("PropertyB", name) == 0) { data.type = CMPI_string; data.state = CMPI_goodValue; data.value.string = CMNewString (broker, "AccessorPropertyB", &rc); } if (strcmp ("n", name) == 0) { data.type = CMPI_uint64; data.state = CMPI_goodValue; data.value.uint64 = 42; } if (strcmp ("f", name) == 0) { data.type = CMPI_real64; data.state = CMPI_goodValue; data.value.real64 = 0.42; } if (strcmp ("s", name) == 0) { data.type = CMPI_string; data.state = CMPI_goodValue; data.value.string = CMNewString (broker, "s", &rc); } PROV_LOG ("---- (%s)", strCMPIStatus (rc)); return data; }
CMPIString *connect_error(provider_address * addr) { CMPIString *str; char msg[512]="Unable to connect to "; strcat(msg,addr->dst_address); str=CMNewString(__init_broker,msg,NULL); return str; }
static int check_ruby_type( VALUE value, int type, const char *message, CMPIStatus *status, ProviderMIHandle* hdl ) { if (TYPE(value) != type) { status->rc = CMPI_RC_ERR_TYPE_MISMATCH; status->msg = CMNewString(hdl->broker, message, NULL); return -1; } return 0; }
CMPIBoolean KStringA_Set( KStringA* self, const CMPIBroker* cb, CMPICount i, const char* s) { CMPIString* x = CMNewString(cb, s, NULL); if (!x) return 0; return KStringA_SetString(self, i, x); }
static int TargetInitialize(ProviderMIHandle* hdl, CMPIStatus* st) { VALUE args[6] = { Qnil }; VALUE gc = Qnil; int error = 0; int have_lock = 0; /* Set _CMPI_INIT, protected by _CMPI_INIT_MUTEX * so we call ruby_finalize() only once. */ if (pthread_mutex_lock(&_CMPI_INIT_MUTEX)) { perror("Can't lock _CMPI_INIT_MUTEX"); abort(); } if (_TARGET_INIT == 0) { _TARGET_INIT = 1; /* safe, since mutex is locked */ error = RbGlobalInitialize(hdl->broker, st); } #if 0 else { /* Enforce GC.disable in provider upcalls; Ruby 1.9 crashes without */ gc = rb_const_get(rb_cObject, rb_intern("GC")); if (NIL_P(gc)) { _SBLIM_TRACE(0,("<%d> No such module 'GC'", getpid())); } else { rb_funcall(gc, rb_intern("disable"), 0 ); } } #endif pthread_mutex_unlock(&_CMPI_INIT_MUTEX); if (error != 0) { if (st != NULL) { st->rc = CMPI_RC_ERR_INVALID_CLASS; st->msg = CMNewString(hdl->broker, "Failed to init Ruby", NULL); } goto fail; } _SBLIM_TRACE(1,("<%d> TargetInitialize(Ruby) called, miName '%s', stack @ %p, pthread %p", getpid(), hdl->miName, &have_lock, pthread_self())); if (pthread_mutex_trylock(&_stack_init_mutex) == 0) { have_lock = 1; _SBLIM_TRACE(1,("<%d> RUBY_INIT_STACK for pthread %p", getpid(), pthread_self())); RUBY_INIT_STACK }
static void generateIndication(const char *methodname, const CMPIContext *ctx) { CMPIInstance *inst; CMPIObjectPath *cop; CMPIDateTime *dat; CMPIArray *ar; CMPIStatus rc; char buffer[32]; if (enabled && activated) { cop = CMNewObjectPath(broker, "root/interop", "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); CMPIObjectPath* cop1 = CMNewObjectPath(broker, "root/cimv2", "Sample_Instance", &rc); CMPIValue value3; value3.string = CMNewString(broker, "I'm an EmbeddedObject", &rc); CMPIInstance* Einst; Einst = CMNewInstance(broker, cop1, &rc); CMSetProperty(Einst, "Message", &value3, CMPI_string); CMSetProperty(inst, "EInst", &Einst, CMPI_instance); 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"); } gen1++; } fprintf(stderr, "+++ generateIndication() done %d\n", gen1); }
static int _testCMPIString() { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *string = NULL; CMPIString *clonedString = NULL; const char *actual_string = NULL; const char *cloned_string = NULL; const char *data = "dataString"; CMPIBoolean cloneSuccessful = 0; void *string_ptr; string = CMNewString(_broker, data, &rc); actual_string = CMGetCharsPtr(string, &rc); clonedString = string->ft->clone(string, &rc); cloned_string = CMGetCharsPtr(clonedString, &rc); if (strcmp(actual_string, cloned_string) == 0) { cloneSuccessful = 1; } rc = clonedString->ft->release(clonedString); string_ptr = string->hdl; string->hdl = NULL; string->ft->clone(string, &rc); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } rc = string->ft->release(string); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } CMGetCharsPtr(string, &rc); if (rc.rc != CMPI_RC_ERR_INVALID_HANDLE) { return 1; } string->hdl = string_ptr; rc = string->ft->release(string); return 0; }
CMPIStatus KString_Set( KString* self, const CMPIBroker* cb, const char* s) { if (self && cb && s) { CMPIString* value; CMPIStatus st = KSTATUS_INIT; if ((value = CMNewString(cb, s, &st)) && KOkay(st)) { memset(self, 0, sizeof(*self)); self->exists = 1; self->value = value; self->chars = KChars(value); KReturn(OK); } } KReturn(ERR_FAILED); }
CMPIStatus TestMethodProviderInvokeMethod ( CMPIMethodMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *className; CMPIData data; char result[80] = "Hello,"; const char *strCat; const char * name; char *argName = "Message"; CMPIString * str1; CMPIString * str2; CMPIValue val1, val2; /* get the class name from object-path */ className = CMGetClassName(ref, &rc); /* get a pointer to a C char* representation of this String. */ name = CMGetCharsPtr(className, &rc); if(!strcmp(name, _ClassName)) { if(!strcmp ("SayHello", methodName)) { /* gets the number of arguments contained in "in" Args. */ if(CMGetArgCount(in, &rc) > 0) { /* gets a Name argument value */ data = CMGetArg(in, "Name", &rc); /*check for data type and not null value of argument value recieved */ if(data.type == CMPI_string && !(CMIsNullValue(data))) { strCat = CMGetCharsPtr(data.value.string, &rc); strcat(result, strCat); // strcat(result, "!"); /* create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { str1 = CMNewString(_broker, result, &rc); val1.string = str1; } /* create string to add to an array */ str2 = CMNewString(_broker,"Have a good day", &rc); val2.string = str2; /* Adds a value of str2 string to out array argument */ rc = CMAddArg(out, argName, &val2, CMPI_string); } else if (!strcmp("CheckArrayNoType", methodName)) { data = CMGetArg(in, "IntArray", &rc); CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); sprintf(result,"Datatype is %s",paramType(atype)); str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } CMReturnData (rslt, (CMPIValue *) &val1, CMPI_string); CMReturnDone (rslt); return rc; }
static CMPIData make_cmpi_data( type_type lextype, int arrayspec, value_chain * vals ) { CMPIData data; CMPIData arr_data; int i = 0; data.type = make_cmpi_type(lextype,arrayspec); data.value.uint64 = 0L; /* set to binary zeros */ if ( vals == NULL ) { data.state = CMPI_nullValue; } else if (vals -> val_value == NULL) { fprintf (stderr,"*** fatal error in backend: NULL value recieved.\n"); abort(); /* paranoia */ }else { data.state = CMPI_goodValue; } if ( data.state == CMPI_goodValue ) { if (data.type & CMPI_ARRAY) { /* process array entries */ data.value.array = CMNewArray(Broker,0,data.type&~CMPI_ARRAY,NULL); while (vals && vals -> val_value) { arr_data = make_cmpi_data(lextype,-1,vals); sfcb_simpleArrayAdd(data.value.array, &arr_data.value, data.type&~CMPI_ARRAY); i++; vals = vals -> val_next; } } else { switch (data.type & ~CMPI_ARRAY) { case CMPI_uint8: sscanf(vals -> val_value, "%hhu", &data.value.uint8 ); break; case CMPI_sint8: sscanf(vals -> val_value, "%hhd", &data.value.sint8 ); break; case CMPI_uint16: sscanf(vals -> val_value, "%hu", &data.value.uint16 ); break; case CMPI_sint16: sscanf(vals -> val_value, "%hd", &data.value.sint16 ); break; case CMPI_uint32: sscanf(vals -> val_value, "%u", &data.value.uint32 ); break; case CMPI_sint32: sscanf(vals -> val_value, "%d", &data.value.sint32 ); break; case CMPI_uint64: sscanf(vals -> val_value, "%llu", &data.value.uint64); break; case CMPI_sint64: sscanf(vals -> val_value, "%lld", &data.value.uint64 ); break; case CMPI_real32: sscanf(vals -> val_value, "%f", &data.value.real32 ); break; case CMPI_real64: sscanf(vals -> val_value, "%lf", &data.value.real64 ); break; case CMPI_char16: /* this one is suspect to produce garbage */ sscanf(vals -> val_value, "%c", &data.value.uint8 ); break; case CMPI_string: data.value.string = CMNewString(Broker,vals -> val_value,NULL); break; case CMPI_boolean: if (strcasecmp("true",vals -> val_value) == 0) { data.value.boolean = 1; } else { data.value.boolean = 0; } break; case CMPI_dateTime: data.value.dateTime = CMNewDateTimeFromChars(Broker,vals -> val_value,NULL); if (data.value.dateTime == NULL) { fprintf(stderr,"failed to build datetime from %s", vals -> val_value); data.state = CMPI_nullValue; } break; default: { char *msg=NULL; data.value.ref = getObjectPath(vals -> val_value, &msg); if(msg) { fprintf(stderr, "Problem with Objectpath %s: %s\n", vals -> val_value, msg); exit(0); } } } } } return data; }
CMPIStatus TestMethodProviderInvokeMethod(CMPIMethodMI * mi, const CMPIContext *ctx, const CMPIResult *rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIString *className; CMPIData data; char result[80] = "Hello,"; const char *strCat; const char *name; char *argName = "Message"; CMPIString *str1; CMPIString *str2; CMPIValue val1, val2; /* * get the class name from object-path */ className = CMGetClassName(ref, &rc); /* * get a pointer to a C char* representation of this String. */ name = CMGetCharsPtr(className, &rc); if (!strcmp(name, _ClassName)) { if (!strcmp("SayHello", methodName)) { /* * gets the number of arguments contained in "in" Args. */ if (CMGetArgCount(in, &rc) > 0) { /* * gets a Name argument value */ data = CMGetArg(in, "Name", &rc); /* * check for data type and not null value of argument value * recieved */ if (data.type == CMPI_string && !(CMIsNullValue(data))) { strCat = CMGetCharsPtr(data.value.string, &rc); strcat(result, strCat); // strcat(result, "!"); /* * create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { str1 = CMNewString(_broker, result, &rc); val1.string = str1; } /* * create string to add to an array */ str2 = CMNewString(_broker, "Have a good day", &rc); val2.string = str2; /* * Adds a value of str2 string to out array argument */ rc = CMAddArg(out, argName, &val2, CMPI_string); /* * For: 3048960 method array types not filled in Test provider. */ } else if (!strcmp("CheckArrayNoType", methodName)) { data = CMGetArg(in, "IntArray", &rc); CMPIType atype=data.value.array->ft->getSimpleType(data.value.array,&rc); sprintf(result,"Datatype is %s",paramType(atype)); str1 = CMNewString(_broker, result, &rc); val1.string = str1; /* * This method simulates various provider problems for testing. */ } else if (!strcmp("Misbehave", methodName)) { data = CMGetArg(in, "Action", &rc); const char *strval = NULL; if (data.type == CMPI_string && !(CMIsNullValue(data))) { strval = CMGetCharsPtr(data.value.string, &rc); sprintf(result, "data type is %s, value = %s", paramType(data.type), strval); if (!strcmp(strval,"hang")) { while(sleep(60)); /* to test req handler timeout, etc. */ } else if (!strcmp(strval,"abort")) { abort(); } else if (!strcmp(strval,"fpe")) { #pragma GCC diagnostic ignored "-Wdiv-by-zero" fprintf(stderr,"ouch! %d\n",1/0); #pragma GCC diagnostic warning "-Wdiv-by-zero" } else if (!strcmp(strval,"segfault")) { void (*crashme)(void) = NULL; crashme(); } /* * These tend to behave as if the condition were raised internally */ else if (!strcmp(strval,"sigabrt")) { kill(getpid(), SIGABRT); while(sleep(3)); /* slight pause to ensure we catch signal */ } else if (!strcmp(strval,"sigfpe")) { kill(getpid(), SIGFPE); while(sleep(3)); } else if (!strcmp(strval,"sigsegv")) { kill(getpid(), SIGSEGV); while(sleep(3)); } else if (!strcmp(strval,"sigusr1")) { kill(getpid(), SIGUSR1); /* as if we received a signal from stopBroker() */ while(sleep(3)); } else if (!strcmp(strval,"sigkill")) { kill(getpid(), SIGKILL); /* this is currently not handled by providerDrv*/ while(sleep(3)); } else { sprintf(result, "Action not recognized: %s", strval); fprintf(stderr, "+++ cmpiTestMethodProvider: Action not recognized \"%s\"\n", strval); } /* * create the new string to return to client */ str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } else { sprintf(result, "Unknown method name: %s", methodName); fprintf(stderr, "+++ cmpiTestMethodProvider: Unknown method name \"%s\"\n", methodName); str1 = CMNewString(_broker, result, &rc); val1.string = str1; } } CMReturnData(rslt, (CMPIValue *) & val1, CMPI_string); CMReturnDone(rslt); return rc; }
CMPIStatus TestCMPIErrorProviderInvokeMethod (CMPIMethodMI * mi, const CMPIContext * ctx, const CMPIResult * rslt, const CMPIObjectPath * ref, const char *methodName, const CMPIArgs * in, CMPIArgs * out) { CMPIString *class_name = NULL; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIError *cmpiError; CMPIError *cmpiErrorClone; CMPICount i, arrSize; CMPIObjectPath *objPath = NULL; CMPIUint32 brokerCapabilities; /* CMPIError data */ const char* inOwningEntity = "ACME"; CMPIString* outOwningEntity; const char* inMsgID = "ACME0023"; CMPIString* outMsgID; const char* inMsg = "ACME0023 Need to restock Road Runner bait and traps."; CMPIString* outMsg; const CMPIErrorSeverity inSev = ErrorSevMedium; CMPIErrorSeverity outSev; const CMPIErrorProbableCause inPc = Equipment_Malfunction; CMPIErrorProbableCause outPc; const CMPIrc inCIMStatusCode = CMPI_RC_ERR_FAILED; CMPIrc outCIMStatusCode; const char * inCIMStatusCodeDesc = "another failed attempt at road " "runner elimination"; CMPIString* outCIMStatusCodeDesc; const CMPIErrorType inErrType = OtherErrorType; CMPIErrorType outErrType; const char* inOtherErrType = "Pervasive Coyote Incompetance"; CMPIString* outOtherErrType; const char* inPcd = "Incorrect use of equipment"; CMPIString* outPcd; CMPIArray *inRecActions; CMPIArray *outRecActions; CMPIArray *inMsgArgs; CMPIArray *outMsgArgs; CMPIValue raOne; CMPIValue raTwo; const char* inErrSource = "Acme bomb"; CMPIString* outErrSource; const CMPIErrorSrcFormat inErrSourceFormat = CMPIErrSrcOther; CMPIErrorSrcFormat outErrSourceFormat; const char* inOtherErrSourceFormat = "no idea"; CMPIString* outOtherErrSourceFormat; CMPIData retData; PROV_LOG_OPEN (_ClassName, _ProviderLocation); PROV_LOG ("Calling CBGetBrokerCapabilities"); brokerCapabilities = CBGetBrokerCapabilities(_broker); if (brokerCapabilities & CMPI_MB_Supports_Extended_Error) { PROV_LOG("CMPI_MB_Supports_Extended_Error Support : True"); } else { PROV_LOG("CMPI_MB_Supports_Extended_Error Support : False"); CMReturnWithString(CMPI_RC_ERR_NOT_SUPPORTED, CMNewString(_broker, "Extended error support not avilable", NULL)); } PROV_LOG ("--- %s CMPI InvokeMethod() called", _ClassName); class_name = CMGetClassName (ref, &rc); PROV_LOG ("InvokeMethod: checking for correct classname [%s]", CMGetCharsPtr (class_name,NULL)); PROV_LOG ("Calling CMNewCMPIError"); cmpiError = CMNewCMPIError(_broker, inOwningEntity, inMsgID, inMsg, inSev, inPc, inCIMStatusCode, &rc); PROV_LOG ("++++ (%s) CMNewCMPIError", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetErrorType"); rc = CMSetErrorType(cmpiError, inErrType); PROV_LOG ("++++ (%s) CMSetErrorType", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetOtherErrorType"); rc = CMSetOtherErrorType(cmpiError, inOtherErrType); PROV_LOG ("++++ (%s) CMSetOtherErrorType", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetProbableCauseDescription"); rc = CMSetProbableCauseDescription(cmpiError, inPcd); PROV_LOG ("++++ (%s) CMSetProbableCauseDescription", strCMPIStatus (rc)); inRecActions = CMNewArray(_broker, 2, CMPI_string, &rc); PROV_LOG ("++++ (%s) CMNewArray", strCMPIStatus (rc)); raOne.string = CMNewString(_broker, "Fire coyote.", &rc); PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc)); rc = CMSetArrayElementAt(inRecActions, 0, &raOne, CMPI_string); PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc)); raTwo.string = CMNewString(_broker, "Give peace a chance.", &rc); PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc)); rc = CMSetArrayElementAt(inRecActions, 1, &raTwo, CMPI_string); PROV_LOG ("++++ (%s) CMSetArrayElementAt [1]", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetRecommendedActions"); rc = CMSetRecommendedActions(cmpiError, inRecActions); PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetErrorSource"); rc = CMSetErrorSource(cmpiError, inErrSource); PROV_LOG ("++++ (%s) CMSetErrorSource", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetErrorSourceFormat"); rc = CMSetErrorSourceFormat(cmpiError, inErrSourceFormat); PROV_LOG ("++++ (%s) CMSetErrorSourceFormat", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetOtherErrorSourceFormat"); rc = CMSetOtherErrorSourceFormat(cmpiError, inOtherErrSourceFormat); PROV_LOG ("++++ (%s) CMSetOtherErrorSourceFormat", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetCIMStatusCodeDescription"); rc = CMSetCIMStatusCodeDescription(cmpiError, inCIMStatusCodeDesc); PROV_LOG ("++++ (%s) CMSetCIMStatusCodeDescription", strCMPIStatus (rc)); inMsgArgs = CMNewArray(_broker, 1, CMPI_string, &rc); PROV_LOG ("++++ (%s) CMNewArray", strCMPIStatus (rc)); raOne.string = CMNewString(_broker, "no real inserts", &rc); PROV_LOG ("++++ (%s) CMNewString", strCMPIStatus (rc)); rc = CMSetArrayElementAt(inMsgArgs, 0, &raOne, CMPI_string); PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetMessageArguments"); rc = CMSetMessageArguments(cmpiError, inMsgArgs); PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc)); PROV_LOG ("First clone the CMPIError."); cmpiErrorClone = CMClone(cmpiError, &rc); PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc)); PROV_LOG ("Ok, reading back fields to verify"); PROV_LOG ("Calling CMGetErrorType"); outErrType = CMGetErrorType(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc), outErrType); PROV_LOG ("Calling CMGetOtherErrorType"); outOtherErrType = CMGetOtherErrorType(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetOtherErrorType (%s)", strCMPIStatus (rc), CMGetCharsPtr(outOtherErrType,NULL)); PROV_LOG ("Calling CMGetOwningEntity"); outOwningEntity = CMGetOwningEntity(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetOwningEntity (%s)", strCMPIStatus (rc), CMGetCharsPtr(outOwningEntity,NULL)); PROV_LOG ("Calling CMGetMessageID"); outMsgID = CMGetMessageID(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetMessageID (%s)", strCMPIStatus (rc), CMGetCharsPtr(outMsgID,NULL)); PROV_LOG ("Calling CMGetErrorMessage"); outMsg = CMGetErrorMessage(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetErrorMessage (%s)", strCMPIStatus (rc), CMGetCharsPtr(outMsg,NULL)); PROV_LOG ("Calling CMGetPerceivedSeverity"); outSev = CMGetPerceivedSeverity(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetPerceivedSeverity (%d)", strCMPIStatus (rc), outSev); PROV_LOG ("Calling CMGetProbableCause"); outPc = CMGetProbableCause(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetProbableCause (%d)", strCMPIStatus (rc), outPc); PROV_LOG ("Calling CMGetProbableCauseDescription"); outPcd = CMGetProbableCauseDescription(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetProbableCauseDescription (%s)", strCMPIStatus (rc), CMGetCharsPtr(outPcd,NULL)); PROV_LOG ("Calling CMGetRecommendedActions"); outRecActions = CMGetRecommendedActions(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetRecommendedActions", strCMPIStatus (rc)); arrSize = CMGetArrayCount(outRecActions, &rc); PROV_LOG ("++++ (%s) CMGetArrayCount (%d)", strCMPIStatus (rc), arrSize); for (i = 0 ; i < arrSize ; i++) { CMPIData dta = CMGetArrayElementAt(outRecActions, i, &rc); PROV_LOG ("++++ (%s) CMGetArrayElementAt (%d:%s)", strCMPIStatus (rc), i, CMGetCharsPtr(dta.value.string,NULL)); } PROV_LOG ("Calling CMGetErrorSource"); outErrSource = CMGetErrorSource(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetErrorSource (%s)", strCMPIStatus (rc), CMGetCharsPtr(outErrSource,NULL)); PROV_LOG ("Calling CMGetErrorSourceFormat"); outErrSourceFormat = CMGetErrorSourceFormat(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetErrorSourceFormat (%d)", strCMPIStatus (rc), outErrSourceFormat); PROV_LOG ("Calling CMGetOtherErrorSourceFormat"); outOtherErrSourceFormat = CMGetOtherErrorSourceFormat(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetOtherErrorSourceFormat (%s)", strCMPIStatus (rc), CMGetCharsPtr(outOtherErrSourceFormat,NULL)); PROV_LOG ("Calling CMGetCIMStatusCode"); outCIMStatusCode = CMGetCIMStatusCode(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetCIMStatusCode (%d)", strCMPIStatus (rc), outCIMStatusCode); PROV_LOG ("Calling CMGetCIMStatusCodeDescription"); outCIMStatusCodeDesc = CMGetCIMStatusCodeDescription(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetCIMStatusCodeDescription (%s)", strCMPIStatus (rc), CMGetCharsPtr(outCIMStatusCodeDesc,NULL)); PROV_LOG ("Calling CMGetMessageArguments"); outMsgArgs = CMGetMessageArguments(cmpiErrorClone, &rc); PROV_LOG ("++++ (%s) CMGetMessageArguments", strCMPIStatus (rc)); arrSize = CMGetArrayCount(outMsgArgs, &rc); PROV_LOG ("++++ (%s) CMGetArrayCount (%d)", strCMPIStatus (rc), arrSize); for (i = 0 ; i < arrSize ; i++) { CMPIData dta = CMGetArrayElementAt(outMsgArgs, i, &rc); PROV_LOG ("++++ (%s) CMGetArrayElementAt (%d:%s)", strCMPIStatus (rc), i, CMGetCharsPtr(dta.value.string,NULL)); } PROV_LOG ("Calling CMPIResultFT.returnData"); rc = (rslt)->ft->returnError (rslt, cmpiErrorClone); PROV_LOG ("++++ (%s) returnData", strCMPIStatus (rc)); PROV_LOG ("Releasing cloned CMPIError"); rc = CMRelease(cmpiErrorClone); PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc)); //Test Error Paths PROV_LOG ("Testing for Error Paths in CMPI_Error.cpp"); PROV_LOG ("Calling CMNewCMPIError"); cmpiError = CMNewCMPIError(_broker, inOwningEntity, inMsgID, inMsg, inSev, inPc, inCIMStatusCode, &rc); PROV_LOG ("++++ (%s) CMNewCMPIError", strCMPIStatus (rc)); PROV_LOG ("Calling CMGetErrorType without setting the ErrorType"); outErrType = CMGetErrorType(cmpiError, &rc); if (!outErrType) { PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc), outErrType); } PROV_LOG ("Calling CMGetOtherErrorType without setting the OtherErrorType"); outOtherErrType = CMGetOtherErrorType(cmpiError, &rc); if (outOtherErrType == NULL) { PROV_LOG ("++++ (%s) CMGetOtherErrorType", strCMPIStatus (rc)); } PROV_LOG ("Testing CMSetMessageArguments"); CMRelease(inMsgArgs); inMsgArgs = CMNewArray(_broker, 1, CMPI_uint32, &rc); PROV_LOG ("++++ (%s) CMNewArray inMsgArgs of CMPI_uint32 type", strCMPIStatus (rc)); raOne.uint32 = 32; rc = CMSetArrayElementAt(inMsgArgs, 0, &raOne, CMPI_uint32); PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetMessageArguments with input array of uint32"); rc = CMSetMessageArguments(cmpiError, inMsgArgs); PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc)); inMsgArgs->hdl = NULL; PROV_LOG ("Calling CMSetMessageArguments with input array with NULL handle"); rc = CMSetMessageArguments(cmpiError, inMsgArgs); PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc)); PROV_LOG ("Testing CMSetRecommendedActions"); CMRelease(inRecActions); inRecActions = CMNewArray(_broker, 1, CMPI_uint32, &rc); PROV_LOG ("++++ (%s) CMNewArray inRecActions of CMPI_uint32", strCMPIStatus (rc)); raOne.uint32 = 32; rc = CMSetArrayElementAt(inRecActions, 0, &raOne, CMPI_uint32); PROV_LOG ("++++ (%s) CMSetArrayElementAt [0]", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetRecommendedActions with input array of CMPI_uint32"); rc = CMSetRecommendedActions(cmpiError, inRecActions); PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc)); inRecActions->hdl = NULL; PROV_LOG ("Calling CMSetRecommendedActions with input array" " with NULL handle"); rc = CMSetRecommendedActions(cmpiError, inRecActions); PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc)); /* Cases when CMPIError object handle is NULL*/ cmpiError->hdl = NULL; PROV_LOG ("Clone the CMPIError with NULL handle."); cmpiErrorClone = CMClone(cmpiError, &rc); if (cmpiErrorClone == NULL) { PROV_LOG ("++++ (%s) CMClone", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetErrorType with NULL handle"); outErrType = CMGetErrorType(cmpiError, &rc); if (!outErrType) { PROV_LOG ("++++ (%s) CMGetErrorType (%d)", strCMPIStatus (rc), outErrType); } PROV_LOG ("Calling CMGetOtherErrorType with NULL handle"); outOtherErrType = CMGetOtherErrorType(cmpiError, &rc); if (outOtherErrType == NULL) { PROV_LOG ("++++ (%s) CMGetOtherErrorType ", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetOwningEntity with NULL handle"); outOwningEntity = CMGetOwningEntity(cmpiError, &rc); if (outOwningEntity == NULL) { PROV_LOG ("++++ (%s) CMGetOwningEntity ", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetMessageID with NULL handle"); outMsgID = CMGetMessageID(cmpiError, &rc); if (!outMsgID) { PROV_LOG ("++++ (%s) CMGetMessageID", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetErrorMessage with NULL handle"); outMsg = CMGetErrorMessage(cmpiError, &rc); if (!outMsg) { PROV_LOG ("++++ (%s) CMGetErrorMessage", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetPerceivedSeverity with NULL handle"); outSev = CMGetPerceivedSeverity(cmpiError, &rc); if (!outSev) { PROV_LOG ("++++ (%s) CMGetPerceivedSeverity (%d)", strCMPIStatus (rc), outSev); } PROV_LOG ("Calling CMGetProbableCause with NULL handle"); outPc = CMGetProbableCause(cmpiError, &rc); if (!outPc) { PROV_LOG ("++++ (%s) CMGetProbableCause (%d)", strCMPIStatus (rc), outPc); } PROV_LOG ("Calling CMGetProbableCauseDescription with NULL handle"); outPcd = CMGetProbableCauseDescription(cmpiError, &rc); if (!outPcd) { PROV_LOG ("++++ (%s) CMGetProbableCauseDescription ", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetRecommendedActions with NULL handle"); outRecActions = CMGetRecommendedActions(cmpiError, &rc); if (!outRecActions) { PROV_LOG ("++++ (%s) CMGetRecommendedActions", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetErrorSource with NULL handle"); outErrSource = CMGetErrorSource(cmpiError, &rc); if (!outErrSource) { PROV_LOG ("++++ (%s) CMGetErrorSource", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetErrorSourceFormat with NULL handle"); outErrSourceFormat = CMGetErrorSourceFormat(cmpiError, &rc); if (!outErrSourceFormat) { PROV_LOG ("++++ (%s) CMGetErrorSourceFormat (%d)", strCMPIStatus (rc), outErrSourceFormat); } PROV_LOG ("Calling CMGetOtherErrorSourceFormat with NULL handle"); outOtherErrSourceFormat = CMGetOtherErrorSourceFormat(cmpiError, &rc); if (!outOtherErrSourceFormat) { PROV_LOG ("++++ (%s) CMGetOtherErrorSourceFormat", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetCIMStatusCode with NULL handle"); outCIMStatusCode = CMGetCIMStatusCode(cmpiError, &rc); if (!outCIMStatusCode) { PROV_LOG ("++++ (%s) CMGetCIMStatusCode (%d)", strCMPIStatus (rc), outCIMStatusCode); } PROV_LOG ("Calling CMGetCIMStatusCodeDescription with NULL handle"); outCIMStatusCodeDesc = CMGetCIMStatusCodeDescription(cmpiError, &rc); if (!outCIMStatusCodeDesc) { PROV_LOG ("++++ (%s) CMGetCIMStatusCodeDescription", strCMPIStatus (rc)); } PROV_LOG ("Calling CMGetMessageArguments with NULL handle"); outMsgArgs = CMGetMessageArguments(cmpiError, &rc); if (!outMsgArgs) { PROV_LOG ("++++ (%s) CMGetMessageArguments", strCMPIStatus (rc)); } PROV_LOG ("Calling CMSetErrorType with NULL handle"); rc = CMSetErrorType(cmpiError, inErrType); PROV_LOG ("++++ (%s) CMSetErrorType", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetOtherErrorType with NULL handle"); rc = CMSetOtherErrorType(cmpiError, inOtherErrType); PROV_LOG ("++++ (%s) CMSetOtherErrorType", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetProbableCauseDescription with NULL handle"); rc = CMSetProbableCauseDescription(cmpiError, inPcd); PROV_LOG ("++++ (%s) CMSetProbableCauseDescription", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetRecommendedActions with NULL handle"); rc = CMSetRecommendedActions(cmpiError, inRecActions); PROV_LOG ("++++ (%s) CMSetRecommendedActions", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetErrorSource with NULL handle"); rc = CMSetErrorSource(cmpiError, inErrSource); PROV_LOG ("++++ (%s) CMSetErrorSource", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetErrorSourceFormat with NULL handle"); rc = CMSetErrorSourceFormat(cmpiError, inErrSourceFormat); PROV_LOG ("++++ (%s) CMSetErrorSourceFormat", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetOtherErrorSourceFormat with NULL handle"); rc = CMSetOtherErrorSourceFormat(cmpiError, inOtherErrSourceFormat); PROV_LOG ("++++ (%s) CMSetOtherErrorSourceFormat", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetCIMStatusCodeDescription with NULL handle"); rc = CMSetCIMStatusCodeDescription(cmpiError, inCIMStatusCodeDesc); PROV_LOG ("++++ (%s) CMSetCIMStatusCodeDescription", strCMPIStatus (rc)); PROV_LOG ("Calling CMSetMessageArguments with NULL handle"); rc = CMSetMessageArguments(cmpiError, inMsgArgs); PROV_LOG ("++++ (%s) CMSetMessageArguments", strCMPIStatus (rc)); PROV_LOG_CLOSE(); // Test case to increase coverage in CMPI_Broker.cpp objPath = CMNewObjectPath (_broker, "test/TestProvider", "TestCMPI_Method", &rc); retData = CBInvokeMethod(_broker, ctx, objPath, "testReturn", in, out, &rc); PROV_LOG_OPEN (_ClassName, _ProviderLocation); if(retData.value.uint32 == 2 && rc.rc == CMPI_RC_OK) { PROV_LOG ("++++ (%s) CMInvokeMethod", strCMPIStatus (rc)); } PROV_LOG ("--- %s CMPI InvokeMethod() exited with CMPI_RC_ERR_FAILED", _ClassName); PROV_LOG_CLOSE(); CMReturnWithString(inCIMStatusCode, CMNewString(_broker, "TestError invokeMethod() expected failure", NULL)); }
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; }
/** initialize function will create three instances and add them to array. "numOfInst" will represent the number of instances in the array. */ static void initialize() { CMPIStatus rc = { CMPI_RC_OK, NULL}; CMPIArray *arr_ptr; CMPIValue value1, value2, value_inst1, value_inst2; CMPIInstance *instance1, *instance2, *instance3; CMPIObjectPath *cop1, *cop2, *cop3; CMPIObjectPath *embeddedObjPath; CMPIInstance *emInst1; CMPIValue valueEmInst; value1.uint8 = 1; value2.string = CMNewString(_broker, "\\x0C9C\\x0CA8\\x0CCD\\x0CAE" "\\x0CA6\\x0CBF\\x0CA8\\x0CA6 \\x0CB6\\x0CC1\\x0CAD\\x0CBE" "\\x0CB6\\x0CAF\\x0C97\\x0CB3\\x0CC1", &rc); /* Create an embedded instance to be returned as embedded object This is an instance of a class that does not exist which is legal in DMTF specs. */ embeddedObjPath = CMNewObjectPath ( _broker, "test/TestProvider", "TestCMPI_EmbeddedNoClass", &rc); assert(rc.rc == CMPI_RC_OK); valueEmInst.uint32 = 1; rc = CMAddKey(embeddedObjPath,"id",&valueEmInst, CMPI_uint32); assert(rc.rc == CMPI_RC_OK); emInst1 = CMNewInstance(_broker, embeddedObjPath, &rc); assert(rc.rc == CMPI_RC_OK); valueEmInst.uint32 = 1999; rc = CMSetProperty(emInst1, "id", &valueEmInst, CMPI_uint32); assert(rc.rc == CMPI_RC_OK); // set the new instance into a value container valueEmInst.inst = emInst1; /* create a new array to hold the instances created */ arr_ptr = CMNewArray(_broker, initArraySize, CMPI_instance, &rc); /* create object path for instance1 */ cop1 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); /* add key (with its value) to object path to recognize instance uniquely */ CMAddKey(cop1, "Identifier", (CMPIValue *)&value1, CMPI_uint8); /* if created object path is not null then create new instance */ if(!CMIsNullObject(cop1)) { instance1 = CMNewInstance(_broker, cop1, &rc); /* set the properties for newly created instance */ CMSetProperty(instance1, "Identifier",&value1, CMPI_uint8); CMSetProperty(instance1, "Message", &value2, CMPI_string); CMSetProperty(instance1, "emObject", &valueEmInst, CMPI_instance); value_inst1.inst = instance1; /* assign the created instance to array created */ rc = CMSetArrayElementAt( arr_ptr, numOfInst, &value_inst1, CMPI_instance); /* set the validity of instance to be true. Validity gets false if instance gets deleted using deleteInstance(). */ valid[numOfInst] = 1; numOfInst++; } /* create instance 2 and add to array */ value1.uint8 = 2; value2.string = CMNewString(_broker, "\\x0CA8\\x0CBE\\x0CB3" "\\x0CC6\\x0CA6\\x0CBF\\x0CA8", &rc); cop2 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop2)) { instance2 = CMNewInstance(_broker, cop2, &rc); CMSetProperty(instance2, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance2, "Message", &value2, CMPI_string); value_inst2.inst = instance2; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* create instance 3 and add to array */ value1.uint8 = 3; value2.string = CMNewString(_broker, "\\x0C9C", &rc); cop3 = CMNewObjectPath( _broker, "root/SampleProvider", _ClassName, &rc); CMAddKey(cop3, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop3)) { instance3 = CMNewInstance(_broker, cop3, &rc); CMSetProperty(instance3, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance3, "Message", &value2, CMPI_string); CMSetProperty(instance3, "emObject", &valueEmInst, CMPI_instance); value_inst2.inst = instance3; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* clone the array which contains instances. */ clone_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc); }
static void initialize() { CMPIStatus rc = { CMPI_RC_OK, NULL}; CMPIArray *arr_ptr; CMPIValue value1, value2, value_inst1, value_inst2; CMPIInstance *instance1, *instance2, *instance3; CMPIObjectPath *cop1, *cop2, *cop3; value1.uint8 = 1; value2.string = CMNewString(_broker, "Hello World", &rc); /* create a new array to hold the instances created */ arr_ptr = CMNewArray(_broker, initArraySize, CMPI_instance, &rc); /* create object path for instance1 */ cop1 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); /* add key (with its value) to object path to recognize instance uniquely */ CMAddKey(cop1, "Identifier", (CMPIValue *)&value1, CMPI_uint8); /* if created object path is not null then create new instance */ if(!CMIsNullObject(cop1)) { instance1 = CMNewInstance(_broker, cop1, &rc); /* set the properties for newly created instance */ CMSetProperty(instance1, "Identifier",&value1, CMPI_uint8); CMSetProperty(instance1, "Message", &value2, CMPI_string); value_inst1.inst = instance1; /* assign the created instance to array created */ rc = CMSetArrayElementAt( arr_ptr, numOfInst, &value_inst1, CMPI_instance); /* set the validity of instance to be true. Validity gets false if instance gets deleted using deleteInstance(). */ valid[numOfInst] = 1; numOfInst++; } /* create instance 2 and add to array */ value1.uint8 = 2; value2.string = CMNewString(_broker, "Yo Planet", &rc); cop2 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); CMAddKey(cop2, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop2)) { instance2 = CMNewInstance(_broker, cop2, &rc); CMSetProperty(instance2, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance2, "Message", &value2, CMPI_string); value_inst2.inst = instance2; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* create instance 3 and add to array */ value1.uint8 = 3; value2.string = CMNewString(_broker, "Hey Earth", &rc); cop3 = CMNewObjectPath( _broker, "root/cimv2", _ClassName, &rc); CMAddKey(cop3, "Identifier", (CMPIValue *)&value1, CMPI_uint8); if(!CMIsNullObject(cop3)) { instance3 = CMNewInstance(_broker, cop3, &rc); CMSetProperty(instance3, "Identifier", &value1, CMPI_uint8); CMSetProperty(instance3, "Message", &value2, CMPI_string); value_inst2.inst = instance3; rc = CMSetArrayElementAt(arr_ptr, numOfInst, &value_inst2, CMPI_instance); valid[numOfInst] = 1; numOfInst++; } /* clone the array which contains instances. */ clone_arr_ptr = arr_ptr->ft->clone(arr_ptr, &rc); }
// 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 ; }
CMPIInstance *RegisteredProfileCreateInstance( const char *ns, const char *name, CMPIStatus *status) { CMPIInstance *ci; char buf[256]; CMPIValue val; _SMI_TRACE(1,("RegisteredProfileCreateInstance() called")); if (strcasecmp(name, ArrayName) == 0 || strcasecmp(name, VolumeManagementName) == 0 || strcasecmp(name, ServerName) == 0) { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, RegisteredProfileName, status), status); } else { ci = CMNewInstance( _BROKER, CMNewObjectPath(_BROKER, ns, RegisteredSubProfileName, status), status); } if ((status->rc != CMPI_RC_OK) || CMIsNullObject(ci)) { _SMI_TRACE(1,("RegisteredProfileCreateInstance(): CMNewInstance() failed - %s", CMGetCharPtr(status->msg))); CMSetStatusWithChars(_BROKER, status, CMPI_RC_ERROR_SYSTEM, "Cannot create new instance"); goto exit; } CMSetProperty(ci, InstanceIDName, cmpiutilMakeInstanceID(name, buf, 256), CMPI_chars); CMSetProperty(ci, ElementName, name, CMPI_chars); CMSetProperty(ci, ParamName, name, CMPI_chars); CMSetProperty(ci, Caption, name, CMPI_chars); CMSetProperty(ci, RegisteredName, name, CMPI_chars); val.uint16 = 11; CMSetProperty(ci, RegisteredOrg, &val, CMPI_uint16); CMSetProperty(ci, RegisteredVersion, RegisteredVersionValue, CMPI_chars); CMPIArray *arr = CMNewArray(_BROKER, 1, CMPI_uint16, NULL); val.uint16 = 2; CMSetArrayElementAt(arr, 0, &val, CMPI_uint16); val.array = arr; CMSetProperty(ci, AdvertiseTypes, &val, CMPI_uint16A); arr = CMNewArray(_BROKER, 1, CMPI_string, NULL); val.string = CMNewString(_BROKER, NotAdvertised, NULL); CMSetArrayElementAt(arr, 0, &val, CMPI_string); val.array = arr; CMSetProperty(ci, AdvertiseTypeDesc, &val, CMPI_stringA); exit: _SMI_TRACE(1,("RegisteredProfileCreateInstance() done")); return ci; }