inline const char * FsBuffer::setup(Uint32 * Buffer, Uint32 Size, Uint32 Block, Uint32 MinRead, Uint32 MaxRead, Uint32 MaxWrite) { clear(); m_buffer = Buffer; m_bufSize = Size; m_blockSize = Block; if(Block == 0){ return valid(); } m_minRead = (MinRead / Block) * Block; m_maxRead = (MaxRead / Block) * Block; m_maxWrite = MaxWrite; m_start = align(Buffer, Block*4, false); Uint32 * stop = align(Buffer + Size - MaxWrite, Block*4, true); if(stop > m_start){ assert(((Uint64(stop) - Uint64(m_start)) >> 32) == 0); m_size = Uint32(stop - m_start); } else {
boost::optional<Block> JsonBlockFactory::deserialize( const Document &document) { auto des = makeFieldDeserializer(document); auto des_transactions = [this](auto array) { auto acc_transactions = [this](auto init, auto &x) { return init | [this, &x](auto transactions) { return factory_.deserialize(x) | [&transactions](auto transaction) { transactions.push_back(transaction); return boost::make_optional(std::move(transactions)); }; }; }; return std::accumulate( array.begin(), array.end(), boost::make_optional(Block::TransactionsType()), acc_transactions); }; return boost::make_optional(model::Block()) | des.Uint64(&Block::created_ts, "created_ts") | des.Uint64(&Block::height, "height") | des.Uint(&Block::txs_number, "txs_number") | des.String(&Block::hash, "hash") | des.String(&Block::prev_hash, "prev_hash") | des.Array(&Block::sigs, "signatures") | des.Array(&Block::transactions, "transactions", des_transactions); }
void drive_get_misc_functions() { try { // Get function tests CQLValue a1(Uint64(123)); CQLValue a2(Sint64(-123)); CQLValue a3(Real64(25.24)); CQLValue a4(String("Hellow")); CQLValue a5(Boolean(true)); String _date("20040811105625.000000-360"); CIMDateTime date(_date); CQLValue a6(date); String _date1("20040811105626.000000-360"); CIMDateTime date1(_date1); CQLValue a61(date1); String opStr("MyClass.z=true,y=1234,x=\"Hello World\""); CIMObjectPath op(opStr); CQLValue a7(op); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CQLValue a8(_i1); PEGASUS_TEST_ASSERT(a1.getUint() == Uint64(123)); PEGASUS_TEST_ASSERT(a2.getSint() == Sint64(-123)); PEGASUS_TEST_ASSERT(a3.getReal() == Real64(25.24)); PEGASUS_TEST_ASSERT(a4.getString() == String("Hellow")); PEGASUS_TEST_ASSERT(a5.getBool() == Boolean(true)); PEGASUS_TEST_ASSERT(a6.getDateTime() == CIMDateTime(_date)); PEGASUS_TEST_ASSERT(a6 != a61); PEGASUS_TEST_ASSERT(a6 < a61); PEGASUS_TEST_ASSERT(a7.getReference() == CIMObjectPath(opStr)); try { a1.getSint(); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } return; }
void SendIndication(int seqNum, char *UIDbuffer) { CIMInstance indicationInstance (CIMName ("IndicationStressTestClass")); indicationInstance.setPath(path); indicationInstance.addProperty (CIMProperty ("IndicationIdentifier",String(UIDbuffer))); indicationInstance.addProperty (CIMProperty ("CorrelatedIndications", correlatedIndications)); CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime (); indicationInstance.addProperty (CIMProperty ("IndicationTime", currentDateTime)); indicationInstance.addProperty (CIMProperty ("IndicationSequenceNumber", CIMValue(Uint64(seqNum)))); // cout << "IndicationStressTestProvider instance = " << ((CIMObject)indicationInstance).toString() << endl; _indication_handler->deliver (indicationInstance); return; }
static void _testIndications(const Array<CIMInstance> &indications) { Uint32 size = indications.size(); Sint64 SequenceNumber; Sint64 MaxSequenceNumber = 0; Uint64 maxSequenceId = 0; Uint64 sequenceId; for (Uint32 i = 0 ; i < size; ++i) { indications[i].getProperty( indications[i].findProperty("SequenceNumber")).getValue().get( SequenceNumber); indications[i].getProperty( indications[i].findProperty("sequenceId")).getValue().get( sequenceId); if (SequenceNumber > MaxSequenceNumber) { MaxSequenceNumber = SequenceNumber; } if (sequenceId > maxSequenceId) { maxSequenceId = sequenceId; } } #ifndef PEGASUS_TEST_VALGRIND_LOG_DIR PEGASUS_TEST_ASSERT(Uint64 (MaxSequenceNumber + 1) == maxSequenceId); #endif NextSequenceNumber = MaxSequenceNumber + 1; }
/* ================================================================================ NAME : getCaption DESCRIPTION : returns ATTN ASSUMPTIONS : PRE-CONDITIONS : POST-CONDITIONS : NOTES : ================================================================================ */ Boolean Processor::getCaption(String& s) const { char t[32]; sprintf(t, "Processor %llu", Uint64(pInfo.psp_idx)); s = String(t); return true; }
/* ================================================================================ NAME : getDeviceID DESCRIPTION : ASSUMPTIONS : None PRE-CONDITIONS : POST-CONDITIONS : NOTES : ================================================================================ */ String Processor::getDeviceID(void) const { char buf[22]; // ATTN for now, we are returning the index sprintf(buf, "%llu", Uint64(pInfo.psp_idx)); return String(buf); }
void TestFaultyInstanceProvider::initialize(CIMOMHandle& cimom) { // save cimom handle //_cimom = cimom; char namebuf[20]; char pathbuf[45]; memset(namebuf, 0x00, sizeof(namebuf)); memset(pathbuf, 0x00, sizeof(pathbuf)); // create default instances for (Uint32 i = 1; i <= 2; i++) { sprintf(namebuf, "%u", i); sprintf(pathbuf, "TST_FaultyInstanceInstance.Name=\"%u\"", i); { CIMInstance instance("TST_FaultyInstanceInstance"); instance.addProperty(CIMProperty("name", String(namebuf))); instance.addProperty(CIMProperty("s", String("specified"))); instance.addProperty(CIMProperty("n", Uint64(i))); instance.addProperty(CIMProperty("f", Real64(Real64(i)+0.001))); instance.addProperty( CIMProperty("d", CIMDateTime::getCurrentDateTime())); instance.setPath(CIMObjectPath(pathbuf)); _instances.append(instance); } } }
Uint64 System::getCurrentTimeUsec() { FILETIME ft; GetSystemTimeAsFileTime(&ft); ULARGE_INTEGER largeInt = { ft.dwLowDateTime, ft.dwHighDateTime }; largeInt.QuadPart -= 0x19db1ded53e8000; return Uint64(largeInt.QuadPart / 10); }
Uint64 getTriangleArea(gmtl::Vec<dataType, 2> a, gmtl::Vec<dataType, 2> b, gmtl::Vec<dataType, 2> c ) { // http://www.btinternet.com/~se16/hgb/triangle.htm float ab = b[0] * a[1] - a[0] * b[1]; float bc = c[0] * b[1] - b[0] * c[1]; float ac = a[0] * c[1] - c[0] * a[1]; return Uint64(myabs(ab + bc + ac) / 2); }
bool Int64(int64_t i) { if (i >= 0) { return Uint64(static_cast<uint64_t>(i)); } msgpack::object* o = queue_object(); if (!o) { return false; } o->type = msgpack::type::NEGATIVE_INTEGER; o->via.i64 = i; return true; }
static Uint64 calculate( size_t size, size_t vertexCount, const dataType* data ) { const dataType* v = data; Uint64 total = 0; for (size_t i = 0; (i + 1) < vertexCount; i += 2, v += 2 * size) { total += Uint64(std::max(myabs(v[0] - v[size]), myabs(v[1] - v[size + 1]))); } return total; }
static Uint64 calculate( size_t size, size_t vertexCount, const dataType* data ) { if (vertexCount < 2) { return 0; } typedef gmtl::Vec<dataType, 2> Vec; const dataType* v = data; Uint64 total = 0; Vec last(v[0], v[1]); Vec first(last); for (size_t i = 1; i < vertexCount; ++i, v += size) { total += Uint64(std::max(myabs(v[0] - last[0]), myabs(v[1] - last[1]))); last = Vec(v[0], v[1]); } total += Uint64(std::max(myabs(first[0] - last[0]), myabs(first[1] - last[1]))); return total; }
/** goodFreeVirtualMemorySize method for SunOS implementation of OS Provider Gets information from swapinfo -at command (the Free column) */ Boolean OSTestClient::goodFreeVirtualMemory( const Uint64 &freevmem, Boolean verbose) { char mline[80]; FILE * mswapInfo; Uint32 swapAvailable; Uint32 swapUsed; Uint32 swapFree; if (verbose) cout<<"Checking FreeVirtualMemory "<< Uint32(freevmem) << endl; swapFree = 0; // Use a pipe to invoke swapinfo. if ((mswapInfo = popen("/usr/sbin/swapinfo -at 2>/dev/null", "r")) != NULL) { // Now extract the total swap space size from the swapinfo output while (fgets(mline, 80, mswapInfo)) { sscanf(mline, "total %u %u %u", &swapAvailable, &swapUsed, &swapFree); } // end while (void)pclose (mswapInfo); } if (verbose) cout<<" Should be close to " << swapFree << endl; Sint64 raw_delta = freevmem - Uint64(swapFree); Uint64 delta = labs(raw_delta); if (verbose) { printf (" Delta should be within 65536, is %lld\n", delta); fflush(stdout); } // arbitrary choice of valid delta - typically ran within // 2048, but with many client connections, went as high as // 36,000+. Thus chose 2^16 = 65536 (still helps weed out // garbage values). return (delta < 65536); }
void test08 (CIMClient & client) { CIMObjectPath instanceName; instanceName.setNameSpace (providerNamespace); instanceName.setClassName (CLASSNAME); Array < CIMParamValue > inParams; Array < CIMParamValue > outParams; inParams.append (CIMParamValue ("Operation", CIMValue (Uint64 (1)))); CIMValue retValue = client.invokeMethod (providerNamespace, instanceName, "TestCMPIBroker", inParams, outParams); _checkUint32Value (retValue, 1); }
void _testDeliveryRetryIntervalValue( CIMInstance& instance) { CIMValue value = instance.getProperty( instance.findProperty( _PROPERTY_DELIVERYRETRYINTERVAL)).getValue(); if (value.getType() == CIMTYPE_UINT64) { // CIM Schema 2.17 experimental class PEGASUS_TEST_ASSERT( Uint64(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE) == value); } else { // CIM Schema 2.22 and up PEGASUS_TEST_ASSERT(_PROPERTY_DELIVERYRETRYINTERVAL_VALUE == value); } }
void _testSubscriptionRemovalIntervalValue( CIMInstance& instance) { CIMValue value = instance.getProperty( instance.findProperty( _PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL)).getValue(); if (value.getType() == CIMTYPE_UINT64) { // CIM Schema 2.17 experimental class PEGASUS_TEST_ASSERT( Uint64(_PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL_VALUE) == value); } else { // CIM Schema 2.22 and up PEGASUS_TEST_ASSERT( _PROPERTY_SUBSCRIPTIONREMOVALTIMEINTERVAL_VALUE == value); } }
virtual void UpdateInfo() { Sint64 crime, fine; Polit::GetCrime(&crime, &fine); const float YSEP = Gui::Screen::GetFontHeight() * 1.5f; DeleteAllChildren(); float ypos = 40.0f; Add((new Gui::Label(Lang::COMBAT_RATING))->Shadow(true), 40, ypos); Add(new Gui::Label(Pi::combatRating[ Pi::CombatRating(Pi::player->GetKillCount()) ]), 40, ypos+YSEP); ypos = 160.0f; Add((new Gui::Label(Lang::CRIMINAL_RECORD))->Shadow(true), 40, ypos); for (int i=0; i<64; i++) { if (!(crime & (Uint64(1)<<i))) continue; if (!Polit::crimeNames[i]) continue; ypos += YSEP; Add(new Gui::Label(Polit::crimeNames[i]), 40, ypos); } ShowChildren(); }
/** _totalVM method for SunOS implementation of OS Provider Gets information from swapinfo -q command (already in KB). Invoked for TotalVirtualMemory as well as TotalSwapSpaceSize. Would be more efficient to get this only once. */ static Uint64 _totalVM() { char mline[80]; FILE * mswapInfo; Uint32 swapSize; // Initialize the return parameter in case swapinfo is not available. swapSize = 0; // Use a pipe to invoke swapinfo. if ((mswapInfo = popen("/usr/sbin/swapinfo -q 2>/dev/null", "r")) != NULL) { // Now extract the total swap space size from the swapinfo output. while (fgets(mline, 80, mswapInfo)) { sscanf(mline, "%d", &swapSize); } // end while (void)pclose (mswapInfo); } return Uint64(swapSize); }
int main(int argc, char** argv) { #ifdef IO verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false; if (verbose) cout << "Test CIMValue. To turn off display, compile with IO undefined\n"; #endif // Test the primitive CIMValue types with test01 test01(Boolean(true)); test01(Boolean(false)); test01(Char16('Z')); test01(Uint8(77)); test01(Sint8(-77)); test01(Sint16(77)); test01(Uint16(-77)); test01(Sint32(77)); test01(Uint32(-77)); test01(Sint64(77)); test01(Uint64(-77)); test01(Real32(1.5)); test01(Real64(55.5)); test01(Uint64(123456789)); test01(Sint64(-123456789)); test01(String("Hello world")); test01(CIMDateTime("19991224120000.000000+360")); test01(CIMObjectPath( "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\"")); // Create and populate a declaration context: const CIMNamespaceName NAMESPACE = CIMNamespaceName ("/zzz"); SimpleDeclContext* context = new SimpleDeclContext; context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("counter"), false, CIMScope::PROPERTY)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("classcounter"), false, CIMScope::CLASS)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("min"), String(), CIMScope::PROPERTY)); context->addQualifierDecl( NAMESPACE, CIMQualifierDecl(CIMName ("max"), String(), CIMScope::PROPERTY)); context->addQualifierDecl(NAMESPACE, CIMQualifierDecl(CIMName ("Description"), String(), CIMScope::PROPERTY)); CIMClass class1(CIMName ("MyClass")); class1 .addProperty(CIMProperty(CIMName ("count"), Uint32(55)) .addQualifier(CIMQualifier(CIMName ("counter"), true)) .addQualifier(CIMQualifier(CIMName ("min"), String("0"))) .addQualifier(CIMQualifier(CIMName ("max"), String("1")))) .addProperty(CIMProperty(CIMName ("message"), String("Hello")) .addQualifier(CIMQualifier(CIMName ("description"), String("My Message")))) .addProperty(CIMProperty(CIMName ("ratio"), Real32(1.5))); Resolver::resolveClass (class1, context, NAMESPACE); context->addClass(NAMESPACE, class1); // Test a CIMObject that is a CIMClass test01(CIMObject(class1)); // Test a CIMObject that is a CIMInstance CIMInstance instance1(CIMName ("MyClass")); instance1.addQualifier(CIMQualifier(CIMName ("classcounter"), true)); instance1.addProperty(CIMProperty(CIMName ("message"), String("Goodbye"))); Resolver::resolveInstance (instance1, context, NAMESPACE, true); test01(CIMObject(instance1)); testEmbeddedValue<CIMObject>(instance1); testEmbeddedValue<CIMInstance>(instance1); // Test CIMValue arrays Array<Uint8> arr1; arr1.append(11); arr1.append(22); arr1.append(23); test02(arr1); Array<Uint16> arr2; arr2.append(333); arr2.append(444); arr2.append(445); test02(arr2); Array<Uint32> arr3; arr3.append(5555); arr3.append(6666); arr3.append(6667); test02(arr3); Array<Uint64> arr4; arr4.append(123456789); arr4.append(987654321); arr4.append(987654322); test02(arr4); Array<Sint8> arr5; arr5.append(-11); arr5.append(-22); arr5.append(-23); test02(arr5); Array<Sint16> arr6; arr6.append(333); arr6.append(444); arr6.append(555); test02(arr6); Array<Sint32> arr7; arr7.append(555); arr7.append(666); arr7.append(777); test02(arr7); Array<Sint64> arr8; arr8.append(-123456789); arr8.append(-987654321); arr8.append(-987654321); test02(arr8); Array<Boolean> arr9; arr9.append(true); arr9.append(false); arr9.append(false); test02(arr9); Array<Real32> arr10; arr10.append(1.55F); arr10.append(2.66F); arr10.append(3.77F); test02(arr10); Array<Real64> arr11; arr11.append(55.55); arr11.append(66.66); arr11.append(77.77); test02(arr11); Array<Char16> arr12; arr12.append('X'); arr12.append('Y'); arr12.append('Z'); test02(arr12); Array<String> arr13; arr13.append("One"); arr13.append("Two"); arr13.append("Three"); test02(arr13); Array<CIMDateTime> arr14; arr14.append(CIMDateTime ("20020130120000.000000+360")); arr14.append(CIMDateTime ("20020201120000.000000+360")); arr14.append(CIMDateTime ("20020202120000.000000+360")); test02(arr14); Array<CIMObjectPath> arr15; arr15.append(CIMObjectPath( "//host1:77/root/test:Class1.key1=\"key1Value\",key2=\"key2Value\"")); arr15.append(CIMObjectPath( "//host2:88/root/static:Class2.keyA=\"keyAValue\",keyB=" "\"keyBValue\"")); arr15.append(CIMObjectPath( "//host3:99/root/test/static:Class3.keyX=\"keyXValue\"," "keyY=\"keyYValue\"")); test02(arr15); testEmbeddedValueArray<CIMObject>(instance1, NAMESPACE, context); testEmbeddedValueArray<CIMInstance>(instance1, NAMESPACE, context); // Calling remaining Array tests.. CIMDateTime D1("19991224120000.000000+100"); Array<CIMDateTime> arrD1(10,D1); CIMDateTime *D2 = new CIMDateTime("19991224120000.000000+100"); Array<CIMDateTime> arrD2(D2,1); test03(arrD1, arrD2, D2, CIMDateTime("19991224120000.000000+100"), CIMDateTime("29991224120000.000000+100")); delete D2; CIMName cimname1("yourName"); Array<CIMName> arrcimname1(10,cimname1); CIMName *cimname2 = new CIMName("yourName"); Array<CIMName> arrcimname2(cimname2,1); test03(arrcimname1, arrcimname2, cimname2, CIMName("yourName"), CIMName("myName")); delete cimname2; CIMKeyBinding cimbind1(cimname1, "myKey", CIMKeyBinding::STRING); CIMKeyBinding cimbind2(cimname1, "yourKey", CIMKeyBinding::STRING); Array<CIMKeyBinding> arrcimbind1(10,cimbind1); CIMKeyBinding *cimbind3 = new CIMKeyBinding(cimname1, "myKey", CIMKeyBinding::STRING); Array<CIMKeyBinding> arrcimbind2(cimbind3,1); test03(arrcimbind1, arrcimbind2, cimbind3, cimbind1, cimbind2 ); delete cimbind3; CIMNamespaceName cimnamespace1("root/SampleProvider"); Array<CIMNamespaceName> arrcimnamespace1(10,cimnamespace1); CIMNamespaceName *cimnamespace2 = new CIMNamespaceName( "root/SampleProvider"); Array<CIMNamespaceName> arrcimnamespace2(cimnamespace2,1); test03(arrcimnamespace1, arrcimnamespace2, cimnamespace2, CIMNamespaceName("root/SampleProvider"), CIMNamespaceName("root/SampleProvider2")); delete cimnamespace2; Array<Boolean> arrB1(10,true); Boolean *b = new Boolean(true); Array<Boolean> arrB2(b,1); Array<Boolean> arrB3(2); Boolean b1 = true, b2=false; test03(arrB1, arrB2, b, Boolean(true),Boolean(false)); delete b; Array<Real32> arrreal321(10); Real32 creal321(2.5); Array<Real32> arrreal322(10, creal321); Real32 *creal322 = new Real32(2.5); Array<Real32> arrreal323(creal322,1); Array<Real32> arrreal324(arrreal321); test03(arrreal322, arrreal323, creal322,Real32(2.5),Real32(3.5)); delete creal322; Array<Real64> arrreal641(10); Real64 creal641(20000.54321); Array<Real64> arrreal642(10, creal641); Real64 *creal642 = new Real64(20000.54321); Array<Real64> arrreal643(creal642,1); Array<Real64> arrreal644(arrreal641); test03(arrreal642, arrreal643, creal642,Real64(20000.54321), Real64(30000.54321)); delete creal642; Array<Sint16> arrSint161(10); Sint16 cSint161(-2000); Array<Sint16> arrSint162(10, cSint161); Sint16 *cSint162 = new Sint16(-2000); Array<Sint16> arrSint163(cSint162,1); Array<Sint16> arrSint164(arrSint161); test03(arrSint162, arrSint163, cSint162, Sint16(-2000), Sint16(-3000)); delete cSint162; Array<Sint32> arrSint321(10); Sint32 cSint321(-200000000); Array<Sint32> arrSint322(10, cSint321); Sint32 *cSint322 = new Sint32(-200000000); Array<Sint32> arrSint323(cSint322,1); Array<Sint32> arrSint324(arrSint321); test03(arrSint322, arrSint323, cSint322, Sint32(-200000000), Sint32(-300000000)); delete cSint322; Array<Sint64> arrSint641(10); Sint64 cSint641(Sint64(-2000000)*Sint64(10000000) ); Array<Sint64> arrSint642(10, cSint641); Sint64 *cSint642 = new Sint64(Sint64(-2000000)*Sint64(10000000)); Array<Sint64> arrSint643(cSint642,1); Array<Sint64> arrSint644(arrSint641); test03(arrSint642, arrSint643, cSint642,Sint64(-2000000)*Sint64(10000000), Sint64(-3000000)*Sint64(10000000)); delete cSint642; Array<Sint8> arrSint81(10); Sint8 cSint81(-20); Array<Sint8> arrSint82(10, cSint81); Sint8 *cSint82 = new Sint8(-20); Array<Sint8> arrSint83(cSint82,1); Array<Sint8> arrSint84(arrSint81); test03(arrSint82, arrSint83, cSint82, Sint8(-20), Sint8(-22)); delete cSint82; Array<Uint16> arrUint161(10); Uint16 cUint161(200); Array<Uint16> arrUint162(10, cUint161); Uint16 *cUint162 = new Uint16(200); Array<Uint16> arrUint163(cUint162,1); Array<Uint16> arrUint164(arrUint161); test03(arrUint162, arrUint163, cUint162, Uint16(200), Uint16(255)); delete cUint162; Array<Uint32> arrUint321(10); Uint32 cUint321(2000); Array<Uint32> arrUint322(10, cUint321); Uint32 *cUint322 = new Uint32(2000); Array<Uint32> arrUint323(cUint322,1); Array<Uint32> arrUint324(arrUint321); test03(arrUint322, arrUint323, cUint322, Uint32(2000), Uint32(3000)); delete cUint322; Array<Uint64> arrUint641(10); Uint64 cUint641(Uint64(2000000)*Uint64(10000000)); Array<Uint64> arrUint642(10, cUint641); Uint64 *cUint642 = new Uint64(Uint64(2000000)*Uint64(10000000)); Array<Uint64> arrUint643(cUint642,1); Array<Uint64> arrUint644(arrUint641); test03(arrUint642, arrUint643, cUint642,Uint64(2000000)*Uint64(10000000), Uint64(255000)*Uint64(10000000)); delete cUint642; Array<Uint8> arrUint81(10); Uint8 cUint81(200); Array<Uint8> arrUint82(10, cUint81); Uint8 *cUint82 = new Uint8(200); Array<Uint8> arrUint83(cUint82,1); Array<Uint8> arrUint84(arrUint81); test03(arrUint82, arrUint83, cUint82, Uint8(200), Uint8(255)); delete cUint82; Array<Char16> arrChar161(10); Char16 cChar161('Z'); Array<Char16> arrChar162(10, cChar161); Char16 *cChar162 = new Char16('Z'); Array<Char16> arrChar163(cChar162,1); Array<Char16> arrChar164(arrChar161); test03(arrChar162, arrChar163, cChar162, Char16('Z'), Char16('z')); delete cChar162; delete context; cout << argv[0] << " +++++ passed all tests" << endl; return 0; }
int64_t Int64() { return int64_t(Uint64()); }
static int init_global_memory_manager(EmulatorData &ed, Uint32 *watchCounter) { const ndb_mgm_configuration_iterator * p = ed.theConfiguration->getOwnConfigIterator(); if (p == 0) { abort(); } Uint32 numa = 0; ndb_mgm_get_int_parameter(p, CFG_DB_NUMA, &numa); if (numa == 1) { int res = NdbNuma_setInterleaved(); g_eventLogger->info("numa_set_interleave_mask(numa_all_nodes) : %s", res == 0 ? "OK" : "no numa support"); } Uint64 shared_mem = 8*1024*1024; ndb_mgm_get_int64_parameter(p, CFG_DB_SGA, &shared_mem); Uint32 shared_pages = Uint32(shared_mem /= GLOBAL_PAGE_SIZE); Uint32 tupmem = 0; if (ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &tupmem)) { g_eventLogger->alert("Failed to get CFG_TUP_PAGE parameter from " "config, exiting."); return -1; } { /** * IndexMemory */ Uint32 accpages = compute_acc_32kpages(p); tupmem += accpages; // Add to RG_DATAMEM } Uint32 lqhInstances = 1; if (globalData.isNdbMtLqh) { lqhInstances = globalData.ndbMtLqhWorkers; } if (tupmem) { Resource_limit rl; rl.m_min = tupmem; rl.m_max = tupmem; rl.m_resource_id = RG_DATAMEM; ed.m_mem_manager->set_resource_limit(rl); } Uint32 maxopen = 4 * 4; // 4 redo parts, max 4 files per part Uint32 filebuffer = NDB_FILE_BUFFER_SIZE; Uint32 filepages = (filebuffer / GLOBAL_PAGE_SIZE) * maxopen; { /** * RedoBuffer */ Uint32 redomem = 0; ndb_mgm_get_int_parameter(p, CFG_DB_REDO_BUFFER, &redomem); if (redomem) { redomem /= GLOBAL_PAGE_SIZE; Uint32 tmp = redomem & 15; if (tmp != 0) { redomem += (16 - tmp); } filepages += lqhInstances * redomem; // Add to RG_FILE_BUFFERS } } if (filepages) { Resource_limit rl; rl.m_min = filepages; rl.m_max = filepages; rl.m_resource_id = RG_FILE_BUFFERS; ed.m_mem_manager->set_resource_limit(rl); } Uint32 jbpages = compute_jb_pages(&ed); if (jbpages) { Resource_limit rl; rl.m_min = jbpages; rl.m_max = jbpages; rl.m_resource_id = RG_JOBBUFFER; ed.m_mem_manager->set_resource_limit(rl); } Uint32 sbpages = 0; if (globalTransporterRegistry.get_using_default_send_buffer() == false) { Uint64 mem = globalTransporterRegistry.get_total_max_send_buffer(); sbpages = Uint32((mem + GLOBAL_PAGE_SIZE - 1) / GLOBAL_PAGE_SIZE); Resource_limit rl; rl.m_min = sbpages; rl.m_max = sbpages; rl.m_resource_id = RG_TRANSPORTER_BUFFERS; ed.m_mem_manager->set_resource_limit(rl); } Uint32 pgman_pages = 0; { /** * Disk page buffer memory */ Uint64 page_buffer = 64*1024*1024; ndb_mgm_get_int64_parameter(p, CFG_DB_DISK_PAGE_BUFFER_MEMORY,&page_buffer); Uint32 pages = 0; pages += Uint32(page_buffer / GLOBAL_PAGE_SIZE); // in pages pages += LCP_RESTORE_BUFFER * lqhInstances; pgman_pages += pages; pgman_pages += 64; Resource_limit rl; rl.m_min = pgman_pages; rl.m_max = pgman_pages; rl.m_resource_id = RG_DISK_PAGE_BUFFER; // Add to RG_DISK_PAGE_BUFFER ed.m_mem_manager->set_resource_limit(rl); } Uint32 sum = shared_pages + tupmem + filepages + jbpages + sbpages + pgman_pages; if (sum) { Resource_limit rl; rl.m_min = 0; rl.m_max = sum; rl.m_resource_id = 0; ed.m_mem_manager->set_resource_limit(rl); } if (!ed.m_mem_manager->init(watchCounter)) { struct ndb_mgm_param_info dm; struct ndb_mgm_param_info sga; size_t size; size = sizeof(ndb_mgm_param_info); ndb_mgm_get_db_parameter_info(CFG_DB_DATA_MEM, &dm, &size); size = sizeof(ndb_mgm_param_info); ndb_mgm_get_db_parameter_info(CFG_DB_SGA, &sga, &size); g_eventLogger->alert("Malloc (%lld bytes) for %s and %s failed, exiting", Uint64(shared_mem + tupmem) * GLOBAL_PAGE_SIZE, dm.m_name, sga.m_name); return -1; } Uint32 late_alloc = 0; ndb_mgm_get_int_parameter(p, CFG_DB_LATE_ALLOC, &late_alloc); Uint32 memlock = 0; ndb_mgm_get_int_parameter(p, CFG_DB_MEMLOCK, &memlock); if (late_alloc) { /** * Only map these groups that are required for ndb to even "start" */ Uint32 rg[] = { RG_JOBBUFFER, RG_FILE_BUFFERS, RG_TRANSPORTER_BUFFERS, 0 }; ed.m_mem_manager->map(watchCounter, memlock, rg); } else { ed.m_mem_manager->map(watchCounter, memlock); // Map all } return 0; // Success }
Uint64 UNIX_ComputerSystem::getGeneration() const { return Uint64(0); }
void drive_operation() { // Uint64 tests CQLValue a1(Uint64(10)); CQLValue a2(Uint64(15)); CQLValue a3(Uint64(25)); CQLValue a4(Uint64(30)); CQLValue a5(Uint64(150)); PEGASUS_TEST_ASSERT(a1 != a2); PEGASUS_TEST_ASSERT(a5 == a5); PEGASUS_TEST_ASSERT(a1 < a2); PEGASUS_TEST_ASSERT(a2 >= a1); PEGASUS_TEST_ASSERT(a1 <= a2); PEGASUS_TEST_ASSERT(a2 > a1); // Sint64 tests CQLValue b1(Sint64(10)); CQLValue b2(Sint64(15)); CQLValue b3(Sint64(25)); CQLValue b4(Sint64(30)); CQLValue b5(Sint64(150)); PEGASUS_TEST_ASSERT(b1 != b2); PEGASUS_TEST_ASSERT(b5 == b5); PEGASUS_TEST_ASSERT(b1 < b2); PEGASUS_TEST_ASSERT(b2 >= b1); PEGASUS_TEST_ASSERT(b1 <= b2); PEGASUS_TEST_ASSERT(b2 > b1); // Real64 tests CQLValue c1(Real64(10.00)); CQLValue c2(Real64(15.00)); CQLValue c3(Real64(25.00)); CQLValue c4(Real64(30.00)); CQLValue c5(Real64(150.00)); PEGASUS_TEST_ASSERT(c1 != c2); PEGASUS_TEST_ASSERT(c5 == c5); PEGASUS_TEST_ASSERT(c1 < c2); PEGASUS_TEST_ASSERT(c2 >= c1); PEGASUS_TEST_ASSERT(c1 <= c2); PEGASUS_TEST_ASSERT(c2 > c1); // Misc PEGASUS_TEST_ASSERT(a1 == b1); PEGASUS_TEST_ASSERT(a1 == c1); PEGASUS_TEST_ASSERT(b1 == a1); PEGASUS_TEST_ASSERT(b1 == c1); PEGASUS_TEST_ASSERT(c1 == a1); PEGASUS_TEST_ASSERT(c1 == b1); PEGASUS_TEST_ASSERT(a2 != b1); PEGASUS_TEST_ASSERT(a2 != c1); PEGASUS_TEST_ASSERT(b2 != a1); PEGASUS_TEST_ASSERT(b2 != c1); PEGASUS_TEST_ASSERT(c2 != a1); PEGASUS_TEST_ASSERT(c2 != b1); PEGASUS_TEST_ASSERT(a2 >= b1); PEGASUS_TEST_ASSERT(a2 >= c1); PEGASUS_TEST_ASSERT(b2 >= a1); PEGASUS_TEST_ASSERT(b2 >= c1); PEGASUS_TEST_ASSERT(c2 >= a1); PEGASUS_TEST_ASSERT(c2 >= b1); PEGASUS_TEST_ASSERT(a2 <= b3); PEGASUS_TEST_ASSERT(a2 <= c3); PEGASUS_TEST_ASSERT(b2 <= a3); PEGASUS_TEST_ASSERT(b2 <= c3); PEGASUS_TEST_ASSERT(c2 <= a3); PEGASUS_TEST_ASSERT(c2 <= b3); PEGASUS_TEST_ASSERT(a2 > b1); PEGASUS_TEST_ASSERT(a2 > c1); PEGASUS_TEST_ASSERT(b2 > a1); PEGASUS_TEST_ASSERT(b2 > c1); PEGASUS_TEST_ASSERT(c2 > a1); PEGASUS_TEST_ASSERT(c2 > b1); PEGASUS_TEST_ASSERT(a2 < b3); PEGASUS_TEST_ASSERT(a2 < c3); PEGASUS_TEST_ASSERT(b2 < a3); PEGASUS_TEST_ASSERT(b2 < c3); PEGASUS_TEST_ASSERT(c2 < a3); PEGASUS_TEST_ASSERT(c2 < b3); //Overflow testing CQLValue real1(Real64(0.00000001)); CQLValue sint1(Sint64(-1)); CQLValue uint1(Sint64(1)); CQLValue uint2(Uint64(0)); PEGASUS_TEST_ASSERT(uint1 > sint1); PEGASUS_TEST_ASSERT(real1 > sint1); PEGASUS_TEST_ASSERT(uint2 > sint1); PEGASUS_TEST_ASSERT(real1 > uint2); CQLValue real2(Real64(25.00000000000001)); CQLValue real3(Real64(24.99999999999999)); CQLValue sint2(Sint64(25)); CQLValue uint3(Uint64(25)); PEGASUS_TEST_ASSERT(real2 > real3); PEGASUS_TEST_ASSERT(real2 > sint2); PEGASUS_TEST_ASSERT(real2 > uint3); PEGASUS_TEST_ASSERT(real3 < sint2); PEGASUS_TEST_ASSERT(real3 < uint3); // String tests CQLValue d1(String("HELLO")); CQLValue d2(String("HEL")); CQLValue d3(String("LO")); CQLValue d4(String("AHELLO")); CQLValue d5(String("ZHELLO")); PEGASUS_TEST_ASSERT(d1 == d2 + d3); PEGASUS_TEST_ASSERT(d1 != d2 + d4); PEGASUS_TEST_ASSERT(d1 <= d5); PEGASUS_TEST_ASSERT(d1 < d5); PEGASUS_TEST_ASSERT(d1 >= d4); PEGASUS_TEST_ASSERT(d1 > d4); String str1("0x10"); String str2("10"); String str3("10B"); String str4("10.10"); CQLValue e1( str1, CQLValue::Hex); CQLValue e2( str2, CQLValue::Decimal); CQLValue e3( str3, CQLValue::Binary); CQLValue e4( str4, CQLValue::Real); CQLValue e5(Uint64(16)); CQLValue e6(Uint64(10)); CQLValue e7(Uint64(2)); CQLValue e8(Real64(10.10)); PEGASUS_TEST_ASSERT(e1 == e5); PEGASUS_TEST_ASSERT(e2 == e6); PEGASUS_TEST_ASSERT(e3 == e7); PEGASUS_TEST_ASSERT(e4 == e8); Array<Uint64> array1; array1.append(1); array1.append(2); array1.append(3); array1.append(4); array1.append(5); array1.append(6); array1.append(7); array1.append(8); array1.append(9); array1.append(10); Array<Sint64> array2; array2.append(1); array2.append(2); array2.append(3); array2.append(4); array2.append(5); array2.append(6); array2.append(7); array2.append(8); array2.append(9); array2.append(10); array2.append(3); Array<Real64> array3; array3.append(1.00); array3.append(2.00); array3.append(3.00); array3.append(9.00); array3.append(10.00); array3.append(3.00); array3.append(4.00); array3.append(5.00); array3.append(6.00); array3.append(7.00); array3.append(8.00); Array<Uint64> array4; array4.append(1); array4.append(23); array4.append(3); array4.append(4); array4.append(5); array4.append(6); array4.append(7); array4.append(88); array4.append(9); array4.append(10); Array<Sint64> array5; array5.append(-1); array5.append(2); array5.append(3); array5.append(4); array5.append(5); array5.append(-6); array5.append(7); array5.append(8); array5.append(9); array5.append(10); array5.append(-3); Array<Real64> array6; array6.append(1.23); array6.append(2.00); array6.append(3.00); array6.append(9.00); array6.append(10.00); array6.append(3.00); array6.append(4.14); array6.append(5.00); array6.append(6.00); array6.append(7.00); array6.append(8.00); CIMValue cv1(array1); CIMValue cv2(array2); CIMValue cv3(array3); CIMValue cv4(array4); CIMValue cv5(array5); CIMValue cv6(array6); CQLValue vr1(cv1); CQLValue vr2(cv1); CQLValue vr3(cv2); CQLValue vr4(cv3); CQLValue vr5(cv4); CQLValue vr6(cv5); CQLValue vr7(cv6); PEGASUS_TEST_ASSERT(vr1 == vr2); PEGASUS_TEST_ASSERT(vr1 == vr3); PEGASUS_TEST_ASSERT(vr1 == vr4); PEGASUS_TEST_ASSERT(vr4 == vr3); PEGASUS_TEST_ASSERT(vr1 != vr5); PEGASUS_TEST_ASSERT(vr3 != vr6); PEGASUS_TEST_ASSERT(vr4 != vr7); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CIMInstance _i2(_cimName); CIMProperty _p5(CIMName("Description"), CIMValue(String("Dave Rules Everything"))); CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p8(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i2.addProperty(_p5); _i2.addProperty(_p6); _i2.addProperty(_p7); _i2.addProperty(_p8); CQLValue cql1(_i1); CQLValue cql2(_i1); CQLValue cql3(_i2); CQLValue cql4(_i2); //PEGASUS_TEST_ASSERT(cql1 == cql1); return; }
void drive_resolve_specialChars() { const char* env = getenv("PEGASUS_HOME"); String repositoryDir(env); repositoryDir.append("/repository"); //String repositoryDir("c:/pegasus-cvs/pegasus/repository"); CIMNamespaceName _ns("root/cimv2"); CIMRepository *_rep = new CIMRepository(repositoryDir); RepositoryQueryContext _query(_ns, _rep); RepositoryQueryContext _query1(_ns, _rep); try { const CQLIdentifier _Id1(String("CIM_OperatingSystem")); _query.insertClassPath(_Id1); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11))); CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded"))); Array<Uint16> array16; array16.append(Uint16(0)); array16.append(Uint16(1)); array16.append(Uint16(2)); array16.append(Uint16(3)); CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16)); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400")); CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX")); CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded")); CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS")); CQLChainedIdentifier ci6( String("CIM_OperatingSystem.CIM_OperatingSystem::" "OperationalStatus[2]")); CQLValue a1(ci1); CQLValue a2(ci2); CQLValue a3(ci3); CQLValue a5(ci5); CQLValue a6(ci6); a1.resolve(_i1, _query); a2.resolve(_i1, _query); a6.resolve(_i1, _query); try { a3.resolve(_i1, _query); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } try { a5.resolve(_i1, _query); PEGASUS_TEST_ASSERT(0); } catch(...) { PEGASUS_TEST_ASSERT(1); } PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11))); PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36))); PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2))); } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } delete _rep; return; }
void drive_resolve_primitive() { const char* env = getenv("PEGASUS_HOME"); String repositoryDir(env); repositoryDir.append("/repository"); //String repositoryDir("c:/pegasus-cvs/pegasus/repository"); CIMNamespaceName _ns("root/cimv2"); CIMRepository *_rep = new CIMRepository(repositoryDir); RepositoryQueryContext _query(_ns, _rep); RepositoryQueryContext _query1(_ns, _rep); try { const CQLIdentifier _Id1(String("CIM_OperatingSystem")); _query.insertClassPath(_Id1); const CIMName _cimName(String("CIM_OperatingSystem")); CIMInstance _i1(_cimName); CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules"))); CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2))); CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600))); CIMProperty _p4(CIMName("TimeOfLastStateChange"), CIMValue(CIMDateTime(String("20040811105625.000000-360")))); _i1.addProperty(_p1); _i1.addProperty(_p2); _i1.addProperty(_p3); _i1.addProperty(_p4); CQLChainedIdentifier ci1( String("CIM_OperatingSystem.CIM_OperatingSystem::Description")); CQLChainedIdentifier ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState")); CQLChainedIdentifier ci3( String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone")); CQLChainedIdentifier ci4( String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange")); CQLChainedIdentifier ci5(String( "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange")); CQLChainedIdentifier ci7(String("CIM_OperatingSystem")); CQLChainedIdentifier ci9(String( "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName")); CQLChainedIdentifier ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba")); CQLValue a1(ci1); CQLValue a2(ci2); CQLValue a3(ci3); CQLValue a4(ci4); CQLValue a5(ci5); CQLValue a7(ci7); CQLValue a9(ci9); CQLValue a10(ci10); CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem"))); a1.resolve(_i1, _query); a2.resolve(_i1, _query); a3.resolve(_i1, _query); a4.resolve(_i1, _query); a5.resolve(_i1, _query); a7.resolve(_i1, _query); a10.resolve(_i1, _query1); a9.resolve(_i1, _query); PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules"))); PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2))); PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600))); PEGASUS_TEST_ASSERT(a4 == CQLValue( CIMDateTime(String("20040811105625.000000-360")))); PEGASUS_TEST_ASSERT(a5 == CQLValue( CIMDateTime(String("20040811105625.000000-360")))); //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1)); PEGASUS_TEST_ASSERT(a9.isNull()); PEGASUS_TEST_ASSERT(a10.isNull()); } catch(Exception & e) { cout << e.getMessage() << endl; PEGASUS_TEST_ASSERT(0); } delete _rep; return; }
void PG_TestPropertyTypes::initialize(CIMOMHandle& cimom) { // save cimom handle _cimom = cimom; // create default instances CIMInstance instance1("PG_TestPropertyTypes"); instance1.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance1.addProperty(CIMProperty("InstanceId", Uint64(1))); //key instance1.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance1"))); instance1.addProperty(CIMProperty("PropertyUint8", Uint8(120))); instance1.addProperty(CIMProperty("PropertyUint16", Uint16(1600))); instance1.addProperty(CIMProperty("PropertyUint32", Uint32(3200))); instance1.addProperty(CIMProperty("PropertyUint64", Uint64(6400))); instance1.addProperty(CIMProperty("PropertySint8", Sint8(-120))); instance1.addProperty(CIMProperty("PropertySint16", Sint16(-1600))); instance1.addProperty(CIMProperty("PropertySint32", Sint32(-3200))); instance1.addProperty(CIMProperty("PropertySint64", Sint64(-6400))); instance1.addProperty(CIMProperty("PropertyBoolean", Boolean(1))); instance1.addProperty(CIMProperty("PropertyReal32", Real32(1.12345670123))); instance1.addProperty(CIMProperty( "PropertyReal64", Real64(1.12345678906543210123))); instance1.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20010515104354.000000:000"))); // update object path { CIMObjectPath objectPath = instance1.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance1.getProperty( instance1.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance1.getProperty( instance1.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance1.setPath(objectPath); } _instances.append(instance1); CIMInstance instance2("PG_TestPropertyTypes"); instance2.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance2.addProperty(CIMProperty("InstanceId", Uint64(2))); //key instance2.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance2"))); instance2.addProperty(CIMProperty("PropertyUint8", Uint8(122))); instance2.addProperty(CIMProperty("PropertyUint16", Uint16(1602))); instance2.addProperty(CIMProperty("PropertyUint32", Uint32(3202))); instance2.addProperty(CIMProperty("PropertyUint64", Uint64(6402))); instance2.addProperty(CIMProperty("PropertySint8", Sint8(-122))); instance2.addProperty(CIMProperty("PropertySint16", Sint16(-1602))); instance2.addProperty(CIMProperty("PropertySint32", Sint32(-3202))); instance2.addProperty(CIMProperty("PropertySint64", Sint64(-6402))); instance2.addProperty(CIMProperty("PropertyBoolean", Boolean(0))); instance2.addProperty(CIMProperty("PropertyReal32", Real32(2.12345670123))); instance2.addProperty(CIMProperty( "PropertyReal64", Real64(2.12345678906543210123))); instance2.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20010515104354.000000:000"))); _instances.append(instance2); // update object path { CIMObjectPath objectPath = instance2.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance2.getProperty( instance2.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance2.getProperty( instance2.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance2.setPath(objectPath); } // instance3 to check for negative floating point and exponents CIMInstance instance3("PG_TestPropertyTypes"); instance3.addProperty(CIMProperty( "CreationClassName", String("PG_TestPropertyTypes"))); // key instance3.addProperty(CIMProperty("InstanceId", Uint64(3))); //key instance3.addProperty(CIMProperty( "PropertyString", String("PG_TestPropertyTypes_Instance3"))); instance3.addProperty(CIMProperty("PropertyUint8", Uint8(120))); instance3.addProperty(CIMProperty("PropertyUint16", Uint16(1600))); instance3.addProperty(CIMProperty("PropertyUint32", Uint32(3200))); instance3.addProperty(CIMProperty("PropertyUint64", Uint64(6400))); instance3.addProperty(CIMProperty("PropertySint8", Sint8(-120))); instance3.addProperty(CIMProperty("PropertySint16", Sint16(-1600))); instance3.addProperty(CIMProperty("PropertySint32", Sint32(-3200))); instance3.addProperty(CIMProperty("PropertySint64", Sint64(-6400))); instance3.addProperty(CIMProperty("PropertyBoolean", Boolean(0))); instance3.addProperty(CIMProperty( "PropertyReal32", Real32(-1.12345670123))); instance3.addProperty(CIMProperty( "PropertyReal64", Real64(0.000000012345))); instance3.addProperty(CIMProperty( "PropertyDatetime", CIMDateTime("20060301104354.000000:000"))); // update object path { CIMObjectPath objectPath = instance3.getPath(); Array<CIMKeyBinding> keys; { CIMProperty keyProperty = instance3.getProperty( instance3.findProperty("CreationClassName")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } { CIMProperty keyProperty = instance3.getProperty(instance3.findProperty("InstanceId")); keys.append( CIMKeyBinding(keyProperty.getName(), keyProperty.getValue())); } objectPath.setKeyBindings(keys); instance3.setPath(objectPath); } realValueTestInstance = instance3; }
CIMInstance buildCIMInstanceSourceObject(Boolean display) { // Build an instance of a class that will be embedded within // the instance of MyClass CIMInstance instembed(CIMName("EmbedClassClass")); instembed.addProperty(CIMProperty(CIMName("embedBool"), true)); instembed.addProperty(CIMProperty(CIMName("embedInt"), Uint32(5))); instembed.addProperty(CIMProperty(CIMName("embedStr"), String("Test"))); // Build an instance that will be the primary test instance CIMInstance inst(CIMName("MyClass")); inst.addProperty(CIMProperty(CIMName("BoolScal1"), true)); inst.addProperty(CIMProperty(CIMName("BoolScal2"), false)); inst.addProperty(CIMProperty(CIMName("IntScal1"), Uint32(5))); inst.addProperty(CIMProperty(CIMName("IntScal2"), Uint32(25))); inst.addProperty(CIMProperty(CIMName("IntScal3"), Sint32(-25123))); inst.addProperty(CIMProperty(CIMName("IntScal4"), Uint32(0))); inst.addProperty(CIMProperty(CIMName("Int64Scal5"), Uint64(0x6fffff))); inst.addProperty(CIMProperty(CIMName("Int64Scal6"), Uint64(2147483647))); inst.addProperty(CIMProperty(CIMName("Int64Scal7"), Uint64(4067))); inst.addProperty(CIMProperty(CIMName("Int64Scal8"), Uint64(0))); //// TODO add properties max and min integers. // Add real properties inst.addProperty(CIMProperty(CIMName("DoubleScal1"), Real64(20.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal2"), Real64(0.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal3"), Real32(20.9))); inst.addProperty(CIMProperty(CIMName("DoubleScal4"), Real32(0.9))); // add scalar string properties inst.addProperty(CIMProperty(CIMName("strScal1"), String("Test"))); inst.addProperty(CIMProperty(CIMName("strScal2"), String("noTest"))); inst.addProperty(CIMProperty(CIMName("strScal3"), String(""))); // add string property with special characters. inst.addProperty(CIMProperty(CIMName("strScal4"), String("./\\\"\'!@#$%^&*()"))); // DateTime Scalar properties - TODO create test for // additional formats for this field (interval, other offsets. CIMDateTime dt1; dt1.set("19991224120000.000000+360"); inst.addProperty(CIMProperty(CIMName("dateTimeScal1"),dt1)); CIMDateTime dt2; dt2.set("19991224120000.0000**+360"); inst.addProperty(CIMProperty(CIMName("dateTimeScal2"),dt2)); // reference literal properties CIMObjectPath op1 = CIMObjectPath ("//atp:77/root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal1"),op1)); CIMObjectPath op2 = CIMObjectPath ("root/cimv25:" "TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal2"),op2)); CIMObjectPath op3 = CIMObjectPath ("TennisPlayer.first=\"Chris\",last=\"Evert\""); inst.addProperty(CIMProperty(CIMName("referenceScal3"),op3)); CIMObjectPath op4 = CIMObjectPath ("myclassname.p1=1"); inst.addProperty(CIMProperty(CIMName("referenceScal4"),op4)); // KS_TODO create a Reference array property // Embedded instance property inst.addProperty(CIMProperty(CIMName("embeddedInstance1"),instembed)); // Array properties // Boolean Array Array<Boolean> b1; b1.append(true); b1.append(false); b1.append(true); inst.addProperty(CIMProperty(CIMName("BoolArrayProp1"), b1)); Array<Boolean> b2; b2.append(true); b2.append(false); b2.append(true); inst.addProperty(CIMProperty(CIMName("BoolArrayProp2"), b2)); Array<Boolean> b3; b3.append(false); b3.append(false); b3.append(false); inst.addProperty(CIMProperty(CIMName("BoolArrayProp3"), b1)); // Integer Array Array<Sint64> a1; a1.append(4); a1.append(5); a1.append (7); inst.addProperty(CIMProperty(CIMName("IntArrayProp1"), a1)); Array<Sint64> a2; a2.append(7); a2.append(8); a2.append (9); inst.addProperty(CIMProperty(CIMName("IntArrayProp2"), a2)); Array<Sint64> a3; a3.append(7); a3.append(-888); a3.append (-999); inst.addProperty(CIMProperty(CIMName("IntArrayProp3"), a3)); Array<Sint64> a4; a4.append(7); inst.addProperty(CIMProperty(CIMName("IntArrayProp4"), a4)); Array<Sint64> a5;; inst.addProperty(CIMProperty(CIMName("IntArrayProp5"), a5)); // Double Array Array<Real64> r1; r1.append(1011.04); r1.append(123456.8); r1.append(0.1); inst.addProperty(CIMProperty(CIMName("DoubleArrayProp1"), r1)); Array<Real64> r2; r2.append(-1.04); r2.append(-123456.8); r2.append(0.1); inst.addProperty(CIMProperty(CIMName("DoubleArrayProp2"), r2)); // String Array Array<String> s1; s1.append("zero"); s1.append("one"); s1.append("two"); s1.append("three"); inst.addProperty(CIMProperty(CIMName("StrArrayProp1"), s1)); Array<String> s2; s2.append("zero"); s2.append("one"); s2.append("two"); s2.append("three"); inst.addProperty(CIMProperty(CIMName("StrArrayProp2"), s2)); // DateTime Array Array<CIMDateTime> dta1; dta1.append(dt1); dt1.clear();dt1.set("20131224120000.000000+360"); dta1.append(dt1); dt1.clear();dt1.set("20011224120000.000000+360"); dta1.append(dt1); inst.addProperty(CIMProperty(CIMName("dateTimeArray1"),dta1)); if (display) { VCOUT << "Instance to be used in Test" << endl; PrintInstance(cout, inst); } return inst; }
// Test CIMKeyBinding constructor (CIMValue variety) and equal(CIMValue) method void test03() { CIMKeyBinding kb0("test0", Real32(3.14159)); PEGASUS_TEST_ASSERT(kb0.equal(Real32(3.14159))); PEGASUS_TEST_ASSERT(!kb0.equal(Real32(3.141593))); CIMKeyBinding kb1("test1", String("3.14159"), CIMKeyBinding::NUMERIC); PEGASUS_TEST_ASSERT(kb1.equal(Real32(3.14159))); PEGASUS_TEST_ASSERT(!kb1.equal(String("3.14159"))); CIMKeyBinding kb2("test2", Uint32(1000)); PEGASUS_TEST_ASSERT(kb2.equal(Uint32(1000))); PEGASUS_TEST_ASSERT(!kb2.equal(Uint32(1001))); PEGASUS_TEST_ASSERT(kb2.getValue() == "1000"); CIMKeyBinding kb3("test3", Char16('X')); PEGASUS_TEST_ASSERT(kb3.equal(Char16('X'))); PEGASUS_TEST_ASSERT(!kb3.equal(Char16('Y'))); PEGASUS_TEST_ASSERT(kb3.getValue() == "X"); CIMKeyBinding kb4("test4", CIMDateTime("19991224120000.000000+360")); PEGASUS_TEST_ASSERT(kb4.equal(CIMDateTime("19991224120000.000000+360"))); PEGASUS_TEST_ASSERT(!kb4.equal(CIMDateTime("19991225120000.000000+360"))); PEGASUS_TEST_ASSERT(kb4.getValue() == "19991224120000.000000+360"); kb4.setValue("0"); PEGASUS_TEST_ASSERT(!kb4.equal(CIMDateTime("19991224120000.000000+360"))); CIMKeyBinding kb5("test5", String("StringTest")); PEGASUS_TEST_ASSERT(kb5.equal(String("StringTest"))); PEGASUS_TEST_ASSERT(!kb5.equal(String("StringTest1"))); PEGASUS_TEST_ASSERT(kb5.getValue() == "StringTest"); CIMKeyBinding kb6("test6", Boolean(true)); PEGASUS_TEST_ASSERT(kb6.equal(Boolean(true))); PEGASUS_TEST_ASSERT(!kb6.equal(Boolean(false))); PEGASUS_TEST_ASSERT(kb6.getValue() == "TRUE"); kb6.setValue("true1"); PEGASUS_TEST_ASSERT(!kb6.equal(Boolean(true))); CIMKeyBinding kb7("test7", CIMObjectPath("//atp:77/root/cimv25:TennisPlayer." "last=\"Rafter\",first=\"Patrick\"")); String path = "//atp:77/root/cimv25:TennisPlayer." "last=\"Rafter\",first=\"Patrick\""; PEGASUS_TEST_ASSERT(kb7.equal(CIMObjectPath(path))); path = "//atp:77/root/cimv25:TennisPlayer." "FIRST=\"Patrick\",LAST=\"Rafter\""; PEGASUS_TEST_ASSERT(kb7.equal(CIMObjectPath(path))); path = "//atp:77/root/cimv25:TennisPlayer.last=\"Rafter\""; PEGASUS_TEST_ASSERT(!kb7.equal(CIMObjectPath(path))); Boolean exceptionFlag = false; try { CIMKeyBinding kb8("test8", Array<Uint32>()); } catch (TypeMismatchException&) { exceptionFlag = true; } PEGASUS_TEST_ASSERT(exceptionFlag); CIMKeyBinding kb9("test9", String("1000"), CIMKeyBinding::STRING); PEGASUS_TEST_ASSERT(!kb9.equal(Uint32(1000))); CIMKeyBinding kb10("test10", String("100"), CIMKeyBinding::NUMERIC); PEGASUS_TEST_ASSERT(kb10.equal(Uint64(100))); PEGASUS_TEST_ASSERT(kb10.equal(Uint32(100))); PEGASUS_TEST_ASSERT(kb10.equal(Uint16(100))); PEGASUS_TEST_ASSERT(kb10.equal(Uint8(100))); PEGASUS_TEST_ASSERT(kb10.equal(Sint64(100))); PEGASUS_TEST_ASSERT(kb10.equal(Sint32(100))); PEGASUS_TEST_ASSERT(kb10.equal(Sint16(100))); PEGASUS_TEST_ASSERT(kb10.equal(Sint8(100))); PEGASUS_TEST_ASSERT(!kb10.equal(String("100"))); CIMKeyBinding kb11("test11", String("+100"), CIMKeyBinding::NUMERIC); // Unsigned ints may not start with "+" PEGASUS_TEST_ASSERT(!kb11.equal(Uint64(100))); PEGASUS_TEST_ASSERT(!kb11.equal(Uint32(100))); PEGASUS_TEST_ASSERT(!kb11.equal(Uint16(100))); PEGASUS_TEST_ASSERT(!kb11.equal(Uint8(100))); PEGASUS_TEST_ASSERT(kb11.equal(Sint64(100))); PEGASUS_TEST_ASSERT(kb11.equal(Sint32(100))); PEGASUS_TEST_ASSERT(kb11.equal(Sint16(100))); PEGASUS_TEST_ASSERT(kb11.equal(Sint8(100))); PEGASUS_TEST_ASSERT(!kb11.equal(String("100"))); }
Uint64 HFTimer() { timeval t; gettimeofday(&t, 0); return Uint64(t.tv_sec)*1000000 + Uint64(t.tv_usec); }