diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 21:44:21 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-14 21:44:21 +0000 |
commit | 6d384546d45002b752440cb9c5ef58efa4a6b00d (patch) | |
tree | 97d1a34e4a9cf6d6b3dc7ef9e6ba5ebf83d5c9e2 /base/process_util_unittest.cc | |
parent | 99986a8c5dbf28422fad02ecab1c503f323347d3 (diff) | |
download | chromium_src-6d384546d45002b752440cb9c5ef58efa4a6b00d.zip chromium_src-6d384546d45002b752440cb9c5ef58efa4a6b00d.tar.gz chromium_src-6d384546d45002b752440cb9c5ef58efa4a6b00d.tar.bz2 |
Add unit tests for base::GetSystemMemoryInfo
BUG=176044
TEST=base_unittests ProcessUtilTest
Review URL: https://codereview.chromium.org/12257013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_unittest.cc')
-rw-r--r-- | base/process_util_unittest.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index fe392e2..8fbad3c 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -380,6 +380,40 @@ TEST_F(ProcessUtilTest, SetProcessBackgroundedSelf) { EXPECT_EQ(old_priority, new_priority); } +#if defined(OS_LINUX) || defined(OS_ANDROID) +TEST_F(ProcessUtilTest, GetSystemMemoryInfo) { + base::SystemMemoryInfoKB info; + EXPECT_TRUE(base::GetSystemMemoryInfo(&info)); + + // Ensure each field received a value. + EXPECT_GT(info.total, 0); + EXPECT_GT(info.free, 0); + EXPECT_GT(info.buffers, 0); + EXPECT_GT(info.cached, 0); + EXPECT_GT(info.active_anon, 0); + EXPECT_GT(info.inactive_anon, 0); + EXPECT_GT(info.active_file, 0); + EXPECT_GT(info.inactive_file, 0); + + // All the values should be less than the total amount of memory. + EXPECT_LT(info.free, info.total); + EXPECT_LT(info.buffers, info.total); + EXPECT_LT(info.cached, info.total); + EXPECT_LT(info.active_anon, info.total); + EXPECT_LT(info.inactive_anon, info.total); + EXPECT_LT(info.active_file, info.total); + EXPECT_LT(info.inactive_file, info.total); + +#if defined(OS_CHROMEOS) + // Chrome OS exposes shmem. + EXPECT_GT(info.shmem, 0); + EXPECT_LT(info.shmem, info.total); + // Chrome unit tests are not run on actual Chrome OS hardware, so gem_objects + // and gem_size cannot be tested here. +#endif +} +#endif // defined(OS_LINUX) || defined(OS_ANDROID) + // TODO(estade): if possible, port these 2 tests. #if defined(OS_WIN) TEST_F(ProcessUtilTest, EnableLFH) { |