sys_utils_unittest.cc 724 B

123456789101112131415161718192021222324
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <stddef.h>
  5. #include <unistd.h>
  6. #include "base/system/sys_info.h"
  7. #include "testing/gtest/include/gtest/gtest.h"
  8. namespace base {
  9. namespace android {
  10. TEST(SysUtils, AmountOfPhysicalMemory) {
  11. // Check that the RAM size reported by sysconf() matches the one
  12. // computed by base::SysInfo::AmountOfPhysicalMemory().
  13. size_t sys_ram_size =
  14. static_cast<size_t>(sysconf(_SC_PHYS_PAGES) * PAGE_SIZE);
  15. EXPECT_EQ(sys_ram_size,
  16. static_cast<size_t>(SysInfo::AmountOfPhysicalMemory()));
  17. }
  18. } // namespace android
  19. } // namespace base