void TestEnumEthernetPortStatisticsInstances(void) { std::wstring errMsg; TestableContext context; StandardTestEnumerateInstances<mi::SCX_EthernetPortStatistics_Class_Provider>( m_keyNamesEPS, context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 2u, context.Size()); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"eth0", context[0].GetKey(L"InstanceID", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 10000u, context[0].GetProperty(L"BytesTransmitted", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 20000u, context[0].GetProperty(L"BytesReceived", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 30000u, context[0].GetProperty(L"BytesTotal", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 100u, context[0].GetProperty(L"PacketsTransmitted", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 200u, context[0].GetProperty(L"PacketsReceived", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 1u, context[0].GetProperty(L"TotalTxErrors", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 2u, context[0].GetProperty(L"TotalRxErrors", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 3u, context[0].GetProperty(L"TotalCollisions", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg))); }
void tearDown(void) { std::wstring errMsg; TestableContext context; TearDownAgent<mi::SCX_OperatingSystem_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); }
void setUp(void) { std::wstring errMsg; TestableContext context; SetUpAgent<mi::SCX_Agent_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); }
void TestEnumerateInstancesKeysOnly() { std::wstring errMsg; TestableContext context; StandardTestEnumerateKeysOnly<mi::SCX_OperatingSystem_Class_Provider>( m_keyNames, context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL(1u, context.Size()); }
void tearDown(void) { std::wstring errMsg; TestableContext context; TearDownAgent<mi::SCX_UnixProcess_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); TearDownAgent<mi::SCX_UnixProcessStatisticalInformation_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); }
void tearDown(void) { std::wstring errMsg; TestableContext context; TearDownAgent<mi::SCX_EthernetPortStatistics_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); TearDownAgent<mi::SCX_IPProtocolEndpoint_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); TearDownAgent<mi::SCX_LANEndpoint_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, false, context.WasRefuseUnloadCalled() ); }
// Since setUp() / tearDown() already load/unload, this tests that a second call to Load() works void VerifyMultipleLoadUnloadMethods() { mi::Module Module; mi::SCX_Agent_Class_Provider agent(&Module); TestableContext context; // Call load, verify result is okay, and verify RefuseUnload() was called agent.Load(context); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); CPPUNIT_ASSERT_EQUAL( true, context.WasRefuseUnloadCalled() ); agent.Unload(context); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); }
void VerifyBasicFunctions() { mi::Module Module; mi::SCX_Agent_Class_Provider agent(&Module); TestableContext context; agent.EnumerateInstances(context, NULL, context.GetPropertySet(), false, NULL); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); const std::vector<TestableInstance>& instances = context.GetInstances(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t> (1), instances.size()); TestableInstance inst(instances[0]); struct TestableInstance::PropertyInfo info; // Verify that the key is correct CPPUNIT_ASSERT_EQUAL( static_cast<MI_Uint32>(1), inst.GetNumberOfKeys() ); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, inst.FindProperty("Name", info) ); CPPUNIT_ASSERT_EQUAL_MESSAGE("Field 'Name' is not a key", true, info.isKey); CPPUNIT_ASSERT_EQUAL_MESSAGE("Field 'Name' is not of type string", MI_STRING, info.type); CPPUNIT_ASSERT_EQUAL_MESSAGE("Field 'Name' has wrong value", std::string("scx"), info.value.string); // Test for presence of a few non-null string properties const char *stringprops[] = { #if !defined(PF_DISTRO_ULINUX) "Description", "VersionString", "Architecture", "OSName", "OSType", "OSVersion", "Hostname", "OSAlias", "UnameArchitecture", 0 #else // !defined(PF_DISTRO_LINUX) // ULINUX: Not "OSVersion" since we may run on an uninstalled machine "Description", "VersionString", "Architecture", "OSName", "OSType", "Hostname", "OSAlias", "UnameArchitecture", 0 #endif // !defined(PF_DISTRO_LINUX) }; // NB: Not "KitVersionString" since we may run on an uninstalled machine. for (int i = 0; stringprops[i]; i++) { std::string msgFragment = std::string("Property ") + stringprops[i]; CPPUNIT_ASSERT_EQUAL_MESSAGE(msgFragment + " not found", MI_RESULT_OK, inst.FindProperty(stringprops[i], info)); CPPUNIT_ASSERT_EQUAL_MESSAGE(msgFragment + " not of type string", MI_STRING, info.type); CPPUNIT_ASSERT_EQUAL_MESSAGE(msgFragment + " was not enumerated", true, info.exists); CPPUNIT_ASSERT_MESSAGE(msgFragment + " is zero in length", strlen(info.value.string) > 0); } // Test that major version is 1 or above. CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, inst.FindProperty("MajorVersion", info) ); CPPUNIT_ASSERT_EQUAL(MI_UINT16, info.type); CPPUNIT_ASSERT(info.value.uint16 >= 1); }
/** Print the same output that an enumeration would. */ void PrintAsEnumeration() { mi::Module Module; mi::SCX_Agent_Class_Provider agent(&Module); TestableContext context; agent.EnumerateInstances(context, NULL, context.GetPropertySet(), false, NULL); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); const std::vector<TestableInstance>& instances = context.GetInstances(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t> (1), instances.size()); TestableInstance inst(instances[0]); inst.Print(); }
void TestEnumLANEndpointInstances(void) { std::wstring errMsg; TestableContext context; StandardTestEnumerateInstances<mi::SCX_LANEndpoint_Class_Provider>( m_keyNamesLANE, context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 2u, context.Size()); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"eth0", context[0].GetKey(L"Name", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_ComputerSystem", context[0].GetKey(L"SystemCreationClassName", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, GetFQHostName(CALL_LOCATION(errMsg)), context[0].GetKey(L"SystemName", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_LANEndpoint", context[0].GetKey(L"CreationClassName", CALL_LOCATION(errMsg))); }
void setUp(void) { m_keyNamesEPS.push_back(L"InstanceID"); m_keyNamesIPPE.push_back(L"Name"); m_keyNamesIPPE.push_back(L"SystemCreationClassName"); m_keyNamesIPPE.push_back(L"SystemName"); m_keyNamesIPPE.push_back(L"CreationClassName"); m_keyNamesLANE.push_back(L"Name"); m_keyNamesLANE.push_back(L"SystemCreationClassName"); m_keyNamesLANE.push_back(L"SystemName"); m_keyNamesLANE.push_back(L"CreationClassName"); std::wstring errMsg; TestableContext context; SetUpAgent<mi::SCX_EthernetPortStatistics_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); SetUpAgent<mi::SCX_IPProtocolEndpoint_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); SetUpAgent<mi::SCX_LANEndpoint_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); vector< SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> > originalInstances; const unsigned allProperties = static_cast<unsigned> (-1); const unsigned noOptionalProperties = 0; originalInstances.push_back( SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance>( new NetworkInterfaceInstance(NetworkInterfaceInfo( L"eth0", allProperties, // L"0a123C4Defa6", L"192.168.0.34", L"255.255.255.0", L"192.168.0.255", 10000, 20000, 100, 200, 1, 2, 3, true, true, SCXCoreLib::SCXHandle<NetworkInterfaceDependencies>(0))))); originalInstances.push_back(SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance>( new NetworkInterfaceInstance(NetworkInterfaceInfo( L"eth1", noOptionalProperties, // L"001122334455", L"192.168.1.35", L"255.255.255.0", L"192.168.1.255", 20000, 40000, 200, 400, 2, 4, 6, false, false, SCXCoreLib::SCXHandle<NetworkInterfaceDependencies>(0))))); SCXHandle<InjectedNetworkProviderDependencies> deps(new InjectedNetworkProviderDependencies()); deps->SetInstances(originalInstances); SCXCore::g_NetworkProvider.UpdateDependencies(deps); }
void TestEnumerateKeysOnly() { mi::Module Module; mi::SCX_Agent_Class_Provider agent(&Module); TestableContext context; agent.EnumerateInstances(context, NULL, context.GetPropertySet(), true, NULL); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); const std::vector<TestableInstance>& instances = context.GetInstances(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t> (1), instances.size()); TestableInstance inst(instances[0]); // We know the key is correct from VerifyBasicFunctions() // Just validate that we didn't enumerate properties we didn't need CPPUNIT_ASSERT_EQUAL( static_cast<MI_Uint32>(1), inst.GetNumberOfKeys() ); CPPUNIT_ASSERT_EQUAL( static_cast<MI_Uint32>(1), inst.GetNumberOfProperties() ); }
void TestEnumIPProtocolEndpointInstances(void) { std::wstring errMsg; TestableContext context; StandardTestEnumerateInstances<mi::SCX_IPProtocolEndpoint_Class_Provider>( m_keyNamesIPPE, context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 2u, context.Size()); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"eth0", context[0].GetKey(L"Name", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_ComputerSystem", context[0].GetKey(L"SystemCreationClassName", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, GetFQHostName(CALL_LOCATION(errMsg)), context[0].GetKey(L"SystemName", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_IPProtocolEndpoint", context[0].GetKey(L"CreationClassName", CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"192.168.0.34", context[0].GetProperty(L"IPv4Address", CALL_LOCATION(errMsg)).GetValue_MIString(CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"255.255.255.0", context[0].GetProperty(L"SubnetMask", CALL_LOCATION(errMsg)).GetValue_MIString(CALL_LOCATION(errMsg))); }
void TestEnumerateInstances() { wstring errMsg; TestableContext context; vector<wstring> m_keyNames; m_keyNames.push_back(L"InstanceID"); char containerName[64]; strcpy(containerName, NewGuid().c_str()); containers.push_back(string(containerName)); char command[128]; sprintf(command, "docker run --name=%s centos sleep 60 &", containerName); system(command); sleep(5); // Enumerate provider StandardTestEnumerateInstances<mi::Container_ContainerStatistics_Class_Provider>(m_keyNames, context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT(context.Size()); // Only check that the values are present and within the valid range because it is not possible to create a controlled environment for (unsigned i = 0; i < context.Size(); ++i) { wstring instanceId = context[i].GetProperty(L"InstanceID", CALL_LOCATION(errMsg)).GetValue_MIString(CALL_LOCATION(errMsg)); CPPUNIT_ASSERT(instanceId.length()); CPPUNIT_ASSERT(context[i].GetProperty(L"NetRXBytes", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); CPPUNIT_ASSERT(context[i].GetProperty(L"NetTXBytes", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); CPPUNIT_ASSERT(context[i].GetProperty(L"MemUsedMB", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); CPPUNIT_ASSERT(context[i].GetProperty(L"CPUTotal", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); unsigned short cpuUse = context[i].GetProperty(L"CPUTotalPct", CALL_LOCATION(errMsg)).GetValue_MIUint16(CALL_LOCATION(errMsg)); CPPUNIT_ASSERT(cpuUse <= 100); CPPUNIT_ASSERT(context[i].GetProperty(L"DiskBytesRead", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); CPPUNIT_ASSERT(context[i].GetProperty(L"DiskBytesWritten", CALL_LOCATION(errMsg)).GetValue_MIUint64(CALL_LOCATION(errMsg)) >= 0); } }
void setUp(void) { std::wstring errMsg; TestableContext context; SetUpAgent<mi::SCX_UnixProcess_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); SetUpAgent<mi::SCX_UnixProcessStatisticalInformation_Class_Provider>(context, CALL_LOCATION(errMsg)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, true, context.WasRefuseUnloadCalled() ); m_keyNamesUP.push_back(L"CSCreationClassName"); m_keyNamesUP.push_back(L"CSName"); m_keyNamesUP.push_back(L"OSCreationClassName"); m_keyNamesUP.push_back(L"OSName"); m_keyNamesUP.push_back(L"CreationClassName"); m_keyNamesUP.push_back(L"Handle"); m_keyNamesUPS.push_back(L"Name"); m_keyNamesUPS.push_back(L"CSCreationClassName"); m_keyNamesUPS.push_back(L"CSName"); m_keyNamesUPS.push_back(L"OSCreationClassName"); m_keyNamesUPS.push_back(L"OSName"); m_keyNamesUPS.push_back(L"Handle"); m_keyNamesUPS.push_back(L"ProcessCreationClassName"); }
void TestLowestLogLevel() { mi::Module Module; mi::SCX_Agent_Class_Provider agent(&Module); TestableContext context; agent.EnumerateInstances(context, NULL, context.GetPropertySet(), false, NULL); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); const std::vector<TestableInstance>& instances = context.GetInstances(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t> (1), instances.size()); TestableInstance inst(instances[0]); struct TestableInstance::PropertyInfo info; CPPUNIT_ASSERT_EQUAL(MI_RESULT_OK, inst.FindProperty("MinActiveLogSeverityThreshold", info)); std::string lowestLogThreshold = info.value.string; CPPUNIT_ASSERT_EQUAL(std::string("INFO"), lowestLogThreshold); // Since this is the default. // Set a lower logging threshold, then fetch again and verify we pick it up SCXCoreLib::SCXLogHandle logH = SCXLogHandleFactory::GetLogHandle(L"scx.test"); logH.SetSeverityThreshold(SCXCoreLib::eTrace); context.Reset(); agent.EnumerateInstances(context, NULL, context.GetPropertySet(), false, NULL); CPPUNIT_ASSERT_EQUAL( MI_RESULT_OK, context.GetResult() ); const std::vector<TestableInstance>& instances2 = context.GetInstances(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t> (1), instances2.size()); TestableInstance inst2(instances2[0]); CPPUNIT_ASSERT_EQUAL(MI_RESULT_OK, inst2.FindProperty("MinActiveLogSeverityThreshold", info)); lowestLogThreshold = info.value.string; CPPUNIT_ASSERT_EQUAL(std::string("TRACE"), lowestLogThreshold); }
void ValidateInstance(const TestableContext &context, std::wstring errMsg) { CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, 1u, context.Size()); const TestableInstance &instance = context[0]; CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, SCXCore::GetActualDistributionName(CALL_LOCATION(errMsg)), instance.GetKeyValue(0, CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_ComputerSystem", instance.GetKeyValue(1, CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, GetFQHostName(CALL_LOCATION(errMsg)), instance.GetKeyValue(2, CALL_LOCATION(errMsg))); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, L"SCX_OperatingSystem", instance.GetKeyValue(3, CALL_LOCATION(errMsg))); #if defined(linux) std::wstring tmpExpectedProperties[] = {L"Caption", L"Description", L"Name", L"EnabledState", L"RequestedState", L"EnabledDefault", L"CSCreationClassName", L"CSName", L"CreationClassName", L"OSType", L"OtherTypeDescription", L"Version", L"LastBootUpTime", L"LocalDateTime", L"CurrentTimeZone", L"NumberOfLicensedUsers", L"NumberOfUsers", L"NumberOfProcesses", L"MaxNumberOfProcesses", L"TotalSwapSpaceSize", L"TotalVirtualMemorySize", L"FreeVirtualMemory", L"FreePhysicalMemory", L"TotalVisibleMemorySize", L"SizeStoredInPagingFiles", L"FreeSpaceInPagingFiles", L"MaxProcessMemorySize", L"MaxProcessesPerUser", L"OperatingSystemCapability", L"SystemUpTime" }; #elif defined(aix) std::wstring tmpExpectedProperties[] = {L"Caption", L"Description", L"Name", L"EnabledState", L"RequestedState", L"EnabledDefault", L"CSCreationClassName", L"CSName", L"CreationClassName", L"OSType", L"OtherTypeDescription", L"Version", L"LastBootUpTime", L"LocalDateTime", L"CurrentTimeZone", L"NumberOfLicensedUsers", L"NumberOfUsers", L"NumberOfProcesses", L"TotalSwapSpaceSize", L"TotalVirtualMemorySize", L"FreeVirtualMemory", L"FreePhysicalMemory", L"TotalVisibleMemorySize", L"SizeStoredInPagingFiles", L"FreeSpaceInPagingFiles", L"OperatingSystemCapability", L"MaxProcessMemorySize", L"MaxProcessesPerUser", L"SystemUpTime" }; #elif defined(hpux) std::wstring tmpExpectedProperties[] = {L"Caption", L"Description", L"Name", L"EnabledState", L"RequestedState", L"EnabledDefault", L"CSCreationClassName", L"CSName", L"CreationClassName", L"OSType", L"OtherTypeDescription", L"Version", L"LastBootUpTime", L"LocalDateTime", L"CurrentTimeZone", L"NumberOfLicensedUsers", L"NumberOfUsers", L"NumberOfProcesses", L"MaxNumberOfProcesses", L"TotalSwapSpaceSize", L"TotalVirtualMemorySize", L"FreeVirtualMemory", L"FreePhysicalMemory", L"TotalVisibleMemorySize", L"SizeStoredInPagingFiles", L"FreeSpaceInPagingFiles", L"MaxProcessMemorySize", L"MaxProcessesPerUser", L"OperatingSystemCapability", L"SystemUpTime" }; #elif defined(sun) std::wstring tmpExpectedProperties[] = {L"Caption", L"Description", L"Name", L"EnabledState", L"RequestedState", L"EnabledDefault", L"CSCreationClassName", L"CSName", L"CreationClassName", L"OSType", L"OtherTypeDescription", L"Version", L"LastBootUpTime", L"LocalDateTime", L"CurrentTimeZone", L"NumberOfLicensedUsers", L"NumberOfUsers", L"NumberOfProcesses", L"TotalSwapSpaceSize", L"TotalVirtualMemorySize", L"FreeVirtualMemory", L"FreePhysicalMemory", L"TotalVisibleMemorySize", L"SizeStoredInPagingFiles", L"FreeSpaceInPagingFiles", L"MaxProcessMemorySize", L"MaxProcessesPerUser", L"OperatingSystemCapability", L"SystemUpTime" }; #else #error Platform not supported #endif const size_t numprops = sizeof(tmpExpectedProperties) / sizeof(tmpExpectedProperties[0]); std::set<std::wstring> expectedProperties(tmpExpectedProperties, tmpExpectedProperties + numprops); for (MI_Uint32 i = 0; i < instance.GetNumberOfProperties(); ++i) { TestableInstance::PropertyInfo info; CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE, MI_RESULT_OK, instance.FindProperty(i, info)); CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE + "Property mismatch: " + SCXCoreLib::StrToMultibyte(info.name), 1u, expectedProperties.count(info.name)); } // Be sure that all of the properties in our set exist in the property list for (std::set<std::wstring>::const_iterator iter = expectedProperties.begin(); iter != expectedProperties.end(); ++iter) { #if defined(PF_DISTRO_ULINUX) // Universal system OS provider looks at installed path to run GetLinuxOS.sh. // If the kit isn't installed, "Version" is not set. For this reason we skip the "Version" property. if (L"Version" == *iter) { continue; } #endif // defined(PF_DISTRO_ULINUX) TestableInstance::PropertyInfo info; CPPUNIT_ASSERT_EQUAL_MESSAGE(ERROR_MESSAGE + "Missing property: " + SCXCoreLib::StrToMultibyte(*iter), MI_RESULT_OK, instance.FindProperty((*iter).c_str(), info)); } std::wstring strCaption = instance.GetProperty(L"Caption", CALL_LOCATION(errMsg)). GetValue_MIString(CALL_LOCATION(errMsg)); scxulong uiCountProcesses = instance.GetProperty(L"NumberOfProcesses", CALL_LOCATION(errMsg)). GetValue_MIUint32(CALL_LOCATION(errMsg)); scxulong ulTotalSwap = instance.GetProperty(L"TotalSwapSpaceSize", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulTotalVM = instance.GetProperty(L"TotalVirtualMemorySize", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulFreeVM = instance.GetProperty(L"FreeVirtualMemory", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulFreeMem = instance.GetProperty(L"FreePhysicalMemory", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulTotalMem = instance.GetProperty(L"TotalVisibleMemorySize", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulTotalPage = instance.GetProperty(L"SizeStoredInPagingFiles", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); scxulong ulFreePage = instance.GetProperty(L"FreeSpaceInPagingFiles", CALL_LOCATION(errMsg)). GetValue_MIUint64(CALL_LOCATION(errMsg)); std::wstring strOSCapability = instance.GetProperty(L"OperatingSystemCapability", CALL_LOCATION(errMsg)). GetValue_MIString(CALL_LOCATION(errMsg)); // On ULINUX, we may be running on an installed machine #if !defined(PF_DISTRO_ULINUX) CPPUNIT_ASSERT(6 <= strCaption.length()); #endif CPPUNIT_ASSERT(uiCountProcesses > 0); // Travis CI systems don't appear to have a pagefile. Lots of RAM, but // no pagefile. Test assumed a multi-user system with a pagefile, so // ease up on that if we're running on a Travis CI system. if ( ! s_fTravis ) { CPPUNIT_ASSERT(256000 <= ulTotalSwap); CPPUNIT_ASSERT(512000 <= ulTotalVM); CPPUNIT_ASSERT(ulFreeVM <= ulTotalVM); CPPUNIT_ASSERT(256000 <= ulTotalPage); CPPUNIT_ASSERT(ulFreePage <= ulTotalPage); } CPPUNIT_ASSERT(ulFreeMem <= ulTotalMem); CPPUNIT_ASSERT(128000 <= ulTotalMem); CPPUNIT_ASSERT(strOSCapability == L"32 bit" || strOSCapability == L"64 bit"); }