| 1 |
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ |
| 3 |
#include "kwsysPrivate.h" |
| 4 |
#include KWSYS_HEADER(SystemInformation.hxx) |
| 5 |
|
| 6 |
// Work-around CMake dependency scanning limitation. This must |
| 7 |
// duplicate the above list of headers. |
| 8 |
#if 0 |
| 9 |
# include "SystemInformation.hxx.in" |
| 10 |
#endif |
| 11 |
|
| 12 |
#include <iostream> |
| 13 |
|
| 14 |
#define printMethod(info, m) std::cout << #m << ": " << info.m() << "\n" |
| 15 |
|
| 16 |
#define printMethod2(info, m, unit) \ |
| 17 |
std::cout << #m << ": " << info.m() << " " << unit << "\n" |
| 18 |
|
| 19 |
#define printMethod3(info, m, unit) \ |
| 20 |
std::cout << #m << ": " << info.m << " " << unit << "\n" |
| 21 |
|
| 22 |
int testSystemInformation(int, char*[]) |
| 23 |
{ |
| 24 |
std::cout << "CTEST_FULL_OUTPUT\n"; // avoid truncation |
| 25 |
|
| 26 |
kwsys::SystemInformation info; |
| 27 |
info.RunCPUCheck(); |
| 28 |
info.RunOSCheck(); |
| 29 |
info.RunMemoryCheck(); |
| 30 |
printMethod(info, GetOSName); |
| 31 |
printMethod(info, GetOSIsLinux); |
| 32 |
printMethod(info, GetOSIsApple); |
| 33 |
printMethod(info, GetOSIsWindows); |
| 34 |
printMethod(info, GetHostname); |
| 35 |
printMethod(info, GetFullyQualifiedDomainName); |
| 36 |
printMethod(info, GetOSRelease); |
| 37 |
printMethod(info, GetOSVersion); |
| 38 |
printMethod(info, GetOSPlatform); |
| 39 |
printMethod(info, Is64Bits); |
| 40 |
printMethod(info, GetVendorString); |
| 41 |
printMethod(info, GetVendorID); |
| 42 |
printMethod(info, GetTypeID); |
| 43 |
printMethod(info, GetFamilyID); |
| 44 |
printMethod(info, GetModelID); |
| 45 |
printMethod(info, GetExtendedProcessorName); |
| 46 |
printMethod(info, GetSteppingCode); |
| 47 |
printMethod(info, GetProcessorSerialNumber); |
| 48 |
printMethod2(info, GetProcessorCacheSize, "KB"); |
| 49 |
printMethod(info, GetLogicalProcessorsPerPhysical); |
| 50 |
printMethod2(info, GetProcessorClockFrequency, "MHz"); |
| 51 |
printMethod(info, GetNumberOfLogicalCPU); |
| 52 |
printMethod(info, GetNumberOfPhysicalCPU); |
| 53 |
printMethod(info, DoesCPUSupportCPUID); |
| 54 |
printMethod(info, GetProcessorAPICID); |
| 55 |
printMethod2(info, GetTotalVirtualMemory, "MB"); |
| 56 |
printMethod2(info, GetAvailableVirtualMemory, "MB"); |
| 57 |
printMethod2(info, GetTotalPhysicalMemory, "MB"); |
| 58 |
printMethod2(info, GetAvailablePhysicalMemory, "MB"); |
| 59 |
printMethod3(info, GetHostMemoryTotal(), "KiB"); |
| 60 |
printMethod3(info, GetHostMemoryAvailable("KWSHL"), "KiB"); |
| 61 |
printMethod3(info, GetProcMemoryAvailable("KWSHL", "KWSPL"), "KiB"); |
| 62 |
printMethod3(info, GetHostMemoryUsed(), "KiB"); |
| 63 |
printMethod3(info, GetProcMemoryUsed(), "KiB"); |
| 64 |
printMethod(info, GetLoadAverage); |
| 65 |
|
| 66 |
for (long int i = 0; i <= 31; i++) { |
| 67 |
if (info.DoesCPUSupportFeature(static_cast<long int>(1) << i)) { |
| 68 |
std::cout << "CPU feature " << i << "\n"; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
/* test stack trace |
| 73 |
*/ |
| 74 |
std::cout << "Program Stack:" << std::endl |
| 75 |
<< kwsys::SystemInformation::GetProgramStack(0, 0) << std::endl |
| 76 |
<< std::endl; |
| 77 |
|
| 78 |
/* test segv handler |
| 79 |
info.SetStackTraceOnError(1); |
| 80 |
double *d = (double*)100; |
| 81 |
*d=0; |
| 82 |
*/ |
| 83 |
|
| 84 |
/* test abort handler |
| 85 |
info.SetStackTraceOnError(1); |
| 86 |
abort(); |
| 87 |
*/ |
| 88 |
|
| 89 |
return 0; |
| 90 |
} |