~ubuntu-branches/debian/experimental/kopete/experimental

« back to all changes in this revision

Viewing changes to protocols/jabber/googletalk/libjingle/talk/base/systeminfo_unittest.cc

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2015-02-24 11:32:57 UTC
  • mfrom: (1.1.41 vivid)
  • Revision ID: package-import@ubuntu.com-20150224113257-gnupg4v7lzz18ij0
Tags: 4:14.12.2-1
* New upstream release (14.12.2).
* Bump Standards-Version to 3.9.6, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libjingle
3
 
 * Copyright 2009, Google Inc.
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions are met:
7
 
 *
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.
15
 
 *
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.
26
 
 */
27
 
 
28
 
#include "talk/base/gunit.h"
29
 
#include "talk/base/stringutils.h"
30
 
#include "talk/base/systeminfo.h"
31
 
 
32
 
#ifdef CPU_X86
33
 
 
34
 
// CPUID-based tests only work on X86
35
 
 
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());
41
 
}
42
 
 
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(),
48
 
                                      "GenuineIntel") ||
49
 
              talk_base::string_match(info.GetCpuVendor().c_str(),
50
 
                                      "AuthenticAMD"));
51
 
}
52
 
 
53
 
#endif // CPU_X86
54
 
 
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());
60
 
}
61
 
 
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);
67
 
}
68
 
 
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);
74
 
}
75
 
 
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);
81
 
}
82
 
 
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);
88
 
}
89
 
 
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());
96
 
}
97
 
 
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());
104
 
}
105
 
 
106
 
#ifdef CPU_X86
107
 
 
108
 
// CPU family/model/steeping is only available on X86
109
 
 
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);
115
 
}
116
 
 
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);
122
 
}
123
 
 
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);
129
 
}
130
 
 
131
 
#endif // CPU_X86
132
 
 
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());
142
 
}
143
 
#endif