1 // Copyright (c) 2011 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.
5 #include "base/file_util.h"
6 #include "base/sys_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/platform_test.h"
10 typedef PlatformTest SysInfoTest
;
12 #if defined(OS_POSIX) && !defined(OS_MACOSX)
13 TEST_F(SysInfoTest
, MaxSharedMemorySize
) {
14 // We aren't actually testing that it's correct, just that it's sane.
15 EXPECT_GT(base::SysInfo::MaxSharedMemorySize(), 0u);
19 TEST_F(SysInfoTest
, NumProcs
) {
20 // We aren't actually testing that it's correct, just that it's sane.
21 EXPECT_GE(base::SysInfo::NumberOfProcessors(), 1);
24 TEST_F(SysInfoTest
, AmountOfMem
) {
25 // We aren't actually testing that it's correct, just that it's sane.
26 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemory(), 0);
27 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemoryMB(), 0);
30 TEST_F(SysInfoTest
, AmountOfFreeDiskSpace
) {
31 // We aren't actually testing that it's correct, just that it's sane.
33 ASSERT_TRUE(file_util::GetTempDir(&tmp_path
));
34 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path
), 0)
38 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
39 TEST_F(SysInfoTest
, OperatingSystemVersionNumbers
) {
40 int32 os_major_version
= -1;
41 int32 os_minor_version
= -1;
42 int32 os_bugfix_version
= -1;
43 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version
,
46 EXPECT_GT(os_major_version
, -1);
47 EXPECT_GT(os_minor_version
, -1);
48 EXPECT_GT(os_bugfix_version
, -1);
52 #if defined(OS_CHROMEOS)
53 TEST_F(SysInfoTest
, GoogleChromeOSVersionNumbers
) {
54 int32 os_major_version
= -1;
55 int32 os_minor_version
= -1;
56 int32 os_bugfix_version
= -1;
57 std::string
lsb_release("FOO=1234123.34.5\n");
58 lsb_release
.append(base::SysInfo::GetLinuxStandardBaseVersionKey());
59 lsb_release
.append("=1.2.3.4\n");
60 base::SysInfo::ParseLsbRelease(lsb_release
,
64 EXPECT_EQ(1, os_major_version
);
65 EXPECT_EQ(2, os_minor_version
);
66 EXPECT_EQ(3, os_bugfix_version
);
69 TEST_F(SysInfoTest
, GoogleChromeOSVersionNumbersFirst
) {
70 int32 os_major_version
= -1;
71 int32 os_minor_version
= -1;
72 int32 os_bugfix_version
= -1;
73 std::string
lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey());
74 lsb_release
.append("=1.2.3.4\n");
75 lsb_release
.append("FOO=1234123.34.5\n");
76 base::SysInfo::ParseLsbRelease(lsb_release
,
80 EXPECT_EQ(1, os_major_version
);
81 EXPECT_EQ(2, os_minor_version
);
82 EXPECT_EQ(3, os_bugfix_version
);
85 TEST_F(SysInfoTest
, GoogleChromeOSNoVersionNumbers
) {
86 int32 os_major_version
= -1;
87 int32 os_minor_version
= -1;
88 int32 os_bugfix_version
= -1;
89 std::string
lsb_release("FOO=1234123.34.5\n");
90 base::SysInfo::ParseLsbRelease(lsb_release
,
94 EXPECT_EQ(-1, os_major_version
);
95 EXPECT_EQ(-1, os_minor_version
);
96 EXPECT_EQ(-1, os_bugfix_version
);