testSystemInformation.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*============================================================================
  2. KWSys - Kitware System Library
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "kwsysPrivate.h"
  11. #include KWSYS_HEADER(SystemInformation.hxx)
  12. #include KWSYS_HEADER(ios/iostream)
  13. // Work-around CMake dependency scanning limitation. This must
  14. // duplicate the above list of headers.
  15. #if 0
  16. # include "SystemInformation.hxx.in"
  17. # include "kwsys_ios_iostream.h.in"
  18. #endif
  19. #if defined(KWSYS_USE_LONG_LONG)
  20. # if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
  21. # define iostreamLongLong(x) (x)
  22. # else
  23. # define iostreamLongLong(x) ((long)x)
  24. # endif
  25. #elif defined(KWSYS_USE___INT64)
  26. # if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
  27. # define iostreamLongLong(x) (x)
  28. # else
  29. # define iostreamLongLong(x) ((long)x)
  30. # endif
  31. #else
  32. # error "No Long Long"
  33. #endif
  34. #define printMethod(info, m) kwsys_ios::cout << #m << ": " \
  35. << info.m() << "\n"
  36. #define printMethod2(info, m, unit) kwsys_ios::cout << #m << ": " \
  37. << info.m() << " " << unit << "\n"
  38. #define printMethod3(info, m, unit) kwsys_ios::cout << #m << ": " \
  39. << iostreamLongLong(info.m) << " " << unit << "\n"
  40. int testSystemInformation(int, char*[])
  41. {
  42. kwsys_ios::cout << "CTEST_FULL_OUTPUT\n"; // avoid truncation
  43. kwsys::SystemInformation info;
  44. info.RunCPUCheck();
  45. info.RunOSCheck();
  46. info.RunMemoryCheck();
  47. printMethod(info, GetOSName);
  48. printMethod(info, GetOSIsLinux);
  49. printMethod(info, GetOSIsApple);
  50. printMethod(info, GetOSIsWindows);
  51. printMethod(info, GetHostname);
  52. printMethod(info, GetFullyQualifiedDomainName);
  53. printMethod(info, GetOSRelease);
  54. printMethod(info, GetOSVersion);
  55. printMethod(info, GetOSPlatform);
  56. printMethod(info, GetVendorString);
  57. printMethod(info, GetVendorID);
  58. printMethod(info, GetTypeID);
  59. printMethod(info, GetFamilyID);
  60. printMethod(info, GetModelID);
  61. printMethod(info, GetExtendedProcessorName);
  62. printMethod(info, GetSteppingCode);
  63. printMethod(info, GetProcessorSerialNumber);
  64. printMethod2(info, GetProcessorCacheSize, "KB");
  65. printMethod(info, GetLogicalProcessorsPerPhysical);
  66. printMethod2(info, GetProcessorClockFrequency, "MHz");
  67. printMethod(info, Is64Bits);
  68. printMethod(info, GetNumberOfLogicalCPU);
  69. printMethod(info, GetNumberOfPhysicalCPU);
  70. printMethod(info, DoesCPUSupportCPUID);
  71. printMethod(info, GetProcessorAPICID);
  72. printMethod2(info, GetTotalVirtualMemory, "MB");
  73. printMethod2(info, GetAvailableVirtualMemory, "MB");
  74. printMethod2(info, GetTotalPhysicalMemory, "MB");
  75. printMethod2(info, GetAvailablePhysicalMemory, "MB");
  76. printMethod3(info, GetHostMemoryTotal(), "KiB");
  77. printMethod3(info, GetHostMemoryAvailable("KWSHL"), "KiB");
  78. printMethod3(info, GetProcMemoryAvailable("KWSHL","KWSPL"), "KiB");
  79. printMethod3(info, GetHostMemoryUsed(), "KiB");
  80. printMethod3(info, GetProcMemoryUsed(), "KiB");
  81. for (long int i = 0; i <= 31; i++)
  82. {
  83. if (info.DoesCPUSupportFeature(static_cast<long int>(1) << i))
  84. {
  85. kwsys_ios::cout << "CPU feature " << i << "\n";
  86. }
  87. }
  88. //int GetProcessorCacheXSize(long int);
  89. // bool DoesCPUSupportFeature(long int);
  90. return 0;
  91. }