testSystemInformation.cxx 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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::SystemInformation info;
  43. info.RunCPUCheck();
  44. info.RunOSCheck();
  45. info.RunMemoryCheck();
  46. printMethod(info, GetOSName);
  47. printMethod(info, GetOSIsLinux);
  48. printMethod(info, GetOSIsApple);
  49. printMethod(info, GetOSIsWindows);
  50. printMethod(info, GetHostname);
  51. printMethod(info, GetFullyQualifiedDomainName);
  52. printMethod(info, GetOSRelease);
  53. printMethod(info, GetOSVersion);
  54. printMethod(info, GetOSPlatform);
  55. printMethod(info, GetVendorString);
  56. printMethod(info, GetVendorID);
  57. printMethod(info, GetTypeID);
  58. printMethod(info, GetFamilyID);
  59. printMethod(info, GetModelID);
  60. printMethod(info, GetExtendedProcessorName);
  61. printMethod(info, GetProcessorSerialNumber);
  62. printMethod2(info, GetProcessorCacheSize, "KB");
  63. printMethod(info, GetLogicalProcessorsPerPhysical);
  64. printMethod2(info, GetProcessorClockFrequency, "MHz");
  65. printMethod(info, Is64Bits);
  66. printMethod(info, GetNumberOfLogicalCPU);
  67. printMethod(info, GetNumberOfPhysicalCPU);
  68. printMethod(info, DoesCPUSupportCPUID);
  69. printMethod(info, GetProcessorAPICID);
  70. printMethod2(info, GetTotalVirtualMemory, "MB");
  71. printMethod2(info, GetAvailableVirtualMemory, "MB");
  72. printMethod2(info, GetTotalPhysicalMemory, "MB");
  73. printMethod2(info, GetAvailablePhysicalMemory, "MB");
  74. printMethod3(info, GetHostMemoryTotal(), "KiB");
  75. printMethod3(info, GetHostMemoryAvailable("KWSHL"), "KiB");
  76. printMethod3(info, GetProcMemoryAvailable("KWSHL","KWSPL"), "KiB");
  77. printMethod3(info, GetHostMemoryUsed(), "KiB");
  78. printMethod3(info, GetProcMemoryUsed(), "KiB");
  79. //int GetProcessorCacheXSize(long int);
  80. // bool DoesCPUSupportFeature(long int);
  81. return 0;
  82. }