testSystemInformation.cxx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #define printMethod(inof, m) kwsys_ios::cout << #m << ": " \
  20. << info.m() << "\n"
  21. #define printMethod2(inof, m, unit) kwsys_ios::cout << #m << ": " \
  22. << info.m() << " " << unit << "\n"
  23. int testSystemInformation(int, char*[])
  24. {
  25. kwsys::SystemInformation info;
  26. info.RunCPUCheck();
  27. info.RunOSCheck();
  28. info.RunMemoryCheck();
  29. printMethod(info, GetOSName);
  30. printMethod(info, GetHostname);
  31. printMethod(info, GetOSRelease);
  32. printMethod(info, GetOSVersion);
  33. printMethod(info, GetOSPlatform);
  34. printMethod(info, GetVendorString);
  35. printMethod(info, GetVendorID);
  36. printMethod(info, GetTypeID);
  37. printMethod(info, GetFamilyID);
  38. printMethod(info, GetModelID);
  39. printMethod(info, GetExtendedProcessorName);
  40. printMethod(info, GetProcessorSerialNumber);
  41. printMethod2(info, GetProcessorCacheSize, "KB");
  42. printMethod(info, GetLogicalProcessorsPerPhysical);
  43. printMethod2(info, GetProcessorClockFrequency, "MHz");
  44. printMethod(info, Is64Bits);
  45. printMethod(info, GetNumberOfLogicalCPU);
  46. printMethod(info, GetNumberOfPhysicalCPU);
  47. printMethod(info, DoesCPUSupportCPUID);
  48. printMethod(info, GetProcessorAPICID);
  49. printMethod2(info, GetTotalVirtualMemory, "MB");
  50. printMethod2(info, GetAvailableVirtualMemory, "MB");
  51. printMethod2(info, GetTotalPhysicalMemory, "MB");
  52. printMethod2(info, GetAvailablePhysicalMemory, "MB");
  53. //int GetProcessorCacheXSize(long int);
  54. // bool DoesCPUSupportFeature(long int);
  55. return 0;
  56. }