Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(869)

Side by Side Diff: base/test/expectations/expectation.cc

Issue 12218098: [Test Expectations] Add GetCurrentPlatform() and GetCurrentConfiguration(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/test/expectations/expectation.h ('k') | base/test/expectations/expectation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/expectations/expectation.h" 5 #include "base/test/expectations/expectation.h"
6 6
7 #include "base/logging.h"
8
9 #if defined(OS_WIN)
10 #include "base/win/windows_version.h"
11 #elif defined(OS_MACOSX) && !defined(OS_IOS)
12 #include "base/mac/mac_util.h"
13 #elif defined(OS_LINUX)
14 #include "base/sys_info.h"
15 #endif
16
7 namespace test_expectations { 17 namespace test_expectations {
8 18
9 bool ResultFromString(const base::StringPiece& result, Result* out_result) { 19 bool ResultFromString(const base::StringPiece& result, Result* out_result) {
10 if (result == "Failure") 20 if (result == "Failure")
11 *out_result = RESULT_FAILURE; 21 *out_result = RESULT_FAILURE;
12 else if (result == "Timeout") 22 else if (result == "Timeout")
13 *out_result = RESULT_TIMEOUT; 23 *out_result = RESULT_TIMEOUT;
14 else if (result == "Crash") 24 else if (result == "Crash")
15 *out_result = RESULT_CRASH; 25 *out_result = RESULT_CRASH;
16 else if (result == "Skip") 26 else if (result == "Skip")
(...skipping 20 matching lines...) Expand all
37 } 47 }
38 } else if (name == "Mac") { 48 } else if (name == "Mac") {
39 if (variant != "" && 49 if (variant != "" &&
40 variant != "10.6" && 50 variant != "10.6" &&
41 variant != "10.7" && 51 variant != "10.7" &&
42 variant != "10.8") { 52 variant != "10.8") {
43 return false; 53 return false;
44 } 54 }
45 } else if (name == "Linux") { 55 } else if (name == "Linux") {
46 if (variant != "" && 56 if (variant != "" &&
47 variant != "x32" && 57 variant != "32" &&
48 variant != "x64") { 58 variant != "64") {
49 return false; 59 return false;
50 } 60 }
51 } else if (name == "ChromeOS") { 61 } else if (name == "ChromeOS") {
52 // TODO(rsesek): Figure out what ChromeOS needs. 62 // TODO(rsesek): Figure out what ChromeOS needs.
53 } else if (name == "iOS") { 63 } else if (name == "iOS") {
54 // TODO(rsesek): Figure out what iOS needs. Probably Device and Simulator. 64 // TODO(rsesek): Figure out what iOS needs. Probably Device and Simulator.
55 } else if (name == "Android") { 65 } else if (name == "Android") {
56 // TODO(rsesek): Figure out what Android needs. 66 // TODO(rsesek): Figure out what Android needs.
57 } else { 67 } else {
58 return false; 68 return false;
59 } 69 }
60 70
61 return true; 71 return true;
62 } 72 }
63 73
64 bool PlatformFromString(const base::StringPiece& modifier, 74 bool PlatformFromString(const base::StringPiece& modifier,
65 Platform* out_platform) { 75 Platform* out_platform) {
66 size_t sep = modifier.find('-'); 76 size_t sep = modifier.find('-');
67 if (sep == std::string::npos) { 77 if (sep == std::string::npos) {
68 out_platform->name = modifier.as_string(); 78 out_platform->name = modifier.as_string();
69 out_platform->variant.clear(); 79 out_platform->variant.clear();
70 } else { 80 } else {
71 out_platform->name = modifier.substr(0, sep).as_string(); 81 out_platform->name = modifier.substr(0, sep).as_string();
72 out_platform->variant = modifier.substr(sep + 1).as_string(); 82 out_platform->variant = modifier.substr(sep + 1).as_string();
73 } 83 }
74 84
75 return IsValidPlatform(out_platform); 85 return IsValidPlatform(out_platform);
76 } 86 }
77 87
88 Platform GetCurrentPlatform() {
89 Platform platform;
90 #if defined(OS_WIN)
91 platform.name = "Win";
92 base::win::Version version = base::win::GetVersion();
93 if (version == base::win::VERSION_XP)
94 platform.variant = "XP";
95 else if (version == base::win::VERSION_VISTA)
96 platform.variant = "Vista";
97 else if (version == base::win::VERSION_WIN7)
98 platform.variant = "7";
99 else if (version == base::win::VERSION_WIN8)
100 platform.variant = "8";
101 #elif defined(OS_IOS)
102 platform.name = "iOS";
103 #elif defined(OS_MACOSX)
104 platform.name = "Mac";
105 if (base::mac::IsOSSnowLeopard())
106 platform.variant = "10.6";
107 else if (base::mac::IsOSLion())
108 platform.variant = "10.7";
109 else if (base::mac::IsOSMountainLion())
110 platform.variant = "10.8";
111 #elif defined(OS_CHROMEOS)
112 platform.name = "ChromeOS";
113 #elif defined(OS_ANDROID)
114 platform.name = "Android";
115 #elif defined(OS_LINUX)
116 platform.name = "Linux";
117 std::string arch = base::SysInfo::OperatingSystemArchitecture();
118 if (arch == "x86")
119 platform.variant = "32";
120 else if (arch == "x86_64")
121 platform.variant = "64";
122 #else
123 NOTREACHED();
124 #endif
125 return platform;
126 }
127
78 bool ConfigurationFromString(const base::StringPiece& modifier, 128 bool ConfigurationFromString(const base::StringPiece& modifier,
79 Configuration* out_configuration) { 129 Configuration* out_configuration) {
80 if (modifier == "Debug") 130 if (modifier == "Debug")
81 *out_configuration = CONFIGURATION_DEBUG; 131 *out_configuration = CONFIGURATION_DEBUG;
82 else if (modifier == "Release") 132 else if (modifier == "Release")
83 *out_configuration = CONFIGURATION_RELEASE; 133 *out_configuration = CONFIGURATION_RELEASE;
84 else 134 else
85 return false; 135 return false;
86 136
87 return true; 137 return true;
88 } 138 }
89 139
140 Configuration GetCurrentConfiguration() {
141 #if NDEBUG
142 return CONFIGURATION_RELEASE;
143 #else
144 return CONFIGURATION_DEBUG;
145 #endif
146 NOTREACHED();
147 return CONFIGURATION_UNSPECIFIED;
148 }
149
90 Expectation::Expectation() 150 Expectation::Expectation()
91 : configuration(CONFIGURATION_UNSPECIFIED), 151 : configuration(CONFIGURATION_UNSPECIFIED),
92 result(RESULT_PASS) { 152 result(RESULT_PASS) {
93 } 153 }
94 154
95 Expectation::~Expectation() {} 155 Expectation::~Expectation() {}
96 156
97 } // namespace test_expectations 157 } // namespace test_expectations
OLDNEW
« no previous file with comments | « base/test/expectations/expectation.h ('k') | base/test/expectations/expectation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698