3
* Copyright 2009, Google Inc.
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
8
* 1. Redistributions of source code must retain the above copyright notice,
9
* this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright notice,
11
* this list of conditions and the following disclaimer in the documentation
12
* and/or other materials provided with the distribution.
13
* 3. The name of the author may not be used to endorse or promote products
14
* derived from this software without specific prior written permission.
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#include "talk/base/gunit.h"
29
#include "talk/base/stringutils.h"
30
#include "talk/base/systeminfo.h"
34
// CPUID-based tests only work on X86
36
// Tests CPUID instruction for Vendor identification.
37
TEST(SystemInfoTest, CpuVendorNonEmpty) {
38
talk_base::SystemInfo info;
39
LOG(LS_INFO) << "CpuVendor: " << info.GetCpuVendor();
40
EXPECT_FALSE(info.GetCpuVendor().empty());
43
// Tests Vendor identification is Intel or AMD.
44
// See Also http://en.wikipedia.org/wiki/CPUID
45
TEST(SystemInfoTest, CpuVendorIntelAMD) {
46
talk_base::SystemInfo info;
47
EXPECT_TRUE(talk_base::string_match(info.GetCpuVendor().c_str(),
49
talk_base::string_match(info.GetCpuVendor().c_str(),
55
// Tests MachineModel is set.
56
TEST(SystemInfoTest, MachineModelNonEmpty) {
57
talk_base::SystemInfo info;
58
LOG(LS_INFO) << "MachineModel: " << info.GetMachineModel();
59
EXPECT_FALSE(info.GetMachineModel().empty());
62
// Tests maximum cpu clockrate.
63
TEST(SystemInfoTest, CpuMaxCpuSpeed) {
64
talk_base::SystemInfo info;
65
LOG(LS_INFO) << "MaxCpuSpeed: " << info.GetMaxCpuSpeed();
66
EXPECT_GT(info.GetMaxCpuSpeed(), 0);
69
// Tests current cpu clockrate.
70
TEST(SystemInfoTest, CpuCurCpuSpeed) {
71
talk_base::SystemInfo info;
72
LOG(LS_INFO) << "MaxCurSpeed: " << info.GetCurCpuSpeed();
73
EXPECT_GT(info.GetCurCpuSpeed(), 0);
76
// Tests physical memory size.
77
TEST(SystemInfoTest, MemorySize) {
78
talk_base::SystemInfo info;
79
LOG(LS_INFO) << "MemorySize: " << info.GetMemorySize();
80
EXPECT_GT(info.GetMemorySize(), -1);
83
// Tests number of logical cpus available to the system.
84
TEST(SystemInfoTest, MaxCpus) {
85
talk_base::SystemInfo info;
86
LOG(LS_INFO) << "MaxCpus: " << info.GetMaxCpus();
87
EXPECT_GT(info.GetMaxCpus(), 0);
90
// Tests number of physical cpus available to the system.
91
TEST(SystemInfoTest, MaxPhysicalCpus) {
92
talk_base::SystemInfo info;
93
LOG(LS_INFO) << "MaxPhysicalCpus: " << info.GetMaxPhysicalCpus();
94
EXPECT_GT(info.GetMaxPhysicalCpus(), 0);
95
EXPECT_LE(info.GetMaxPhysicalCpus(), info.GetMaxCpus());
98
// Tests number of logical cpus available to the process.
99
TEST(SystemInfoTest, CurCpus) {
100
talk_base::SystemInfo info;
101
LOG(LS_INFO) << "CurCpus: " << info.GetCurCpus();
102
EXPECT_GT(info.GetCurCpus(), 0);
103
EXPECT_LE(info.GetCurCpus(), info.GetMaxCpus());
108
// CPU family/model/steeping is only available on X86
110
// Tests Intel CPU Family identification.
111
TEST(SystemInfoTest, CpuFamilyNonZero) {
112
talk_base::SystemInfo info;
113
LOG(LS_INFO) << "CpuFamily: " << info.GetCpuFamily();
114
EXPECT_GT(info.GetCpuFamily(), 0);
117
// Tests Intel CPU Model identification.
118
TEST(SystemInfoTest, CpuModelNonZero) {
119
talk_base::SystemInfo info;
120
LOG(LS_INFO) << "CpuModel: " << info.GetCpuModel();
121
EXPECT_GT(info.GetCpuModel(), 0);
124
// Tests Intel CPU Stepping identification.
125
TEST(SystemInfoTest, CpuSteppingNonZero) {
126
talk_base::SystemInfo info;
127
LOG(LS_INFO) << "CpuStepping: " << info.GetCpuStepping();
128
EXPECT_GT(info.GetCpuStepping(), 0);
133
#if WIN32 && !defined(EXCLUDE_D3D9)
134
TEST(SystemInfoTest, GpuInfo) {
135
talk_base::SystemInfo info;
136
talk_base::SystemInfo::GpuInfo gi;
137
EXPECT_TRUE(info.GetGpuInfo(&gi));
138
LOG(LS_INFO) << "GpuDriver: " << gi.driver;
139
EXPECT_FALSE(gi.driver.empty());
140
LOG(LS_INFO) << "GpuDriverVersion: " << gi.driver_version;
141
EXPECT_FALSE(gi.driver_version.empty());