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

Side by Side Diff: util/mac/mac_util_test.mm

Issue 640383002: In tests, use ASSERT_NO_FATAL_FAILURE() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « minidump/minidump_system_info_writer_test.cc ('k') | util/mac/mach_o_image_reader_test.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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 23 matching lines...) Expand all
34 #undef catch 34 #undef catch
35 #endif 35 #endif
36 36
37 namespace crashpad { 37 namespace crashpad {
38 namespace test { 38 namespace test {
39 namespace { 39 namespace {
40 40
41 // Runs /usr/bin/sw_vers with a single argument, |argument|, and places the 41 // Runs /usr/bin/sw_vers with a single argument, |argument|, and places the
42 // command’s standard output into |output| after stripping the trailing newline. 42 // command’s standard output into |output| after stripping the trailing newline.
43 // Fatal gtest assertions report tool failures, which the caller should check 43 // Fatal gtest assertions report tool failures, which the caller should check
44 // for with testing::Test::HasFatalFailure(). 44 // for with ASSERT_NO_FATAL_FAILURE() or testing::Test::HasFatalFailure().
45 void SwVers(NSString* argument, std::string* output) { 45 void SwVers(NSString* argument, std::string* output) {
46 @autoreleasepool { 46 @autoreleasepool {
47 base::scoped_nsobject<NSPipe> pipe([[NSPipe alloc] init]); 47 base::scoped_nsobject<NSPipe> pipe([[NSPipe alloc] init]);
48 base::scoped_nsobject<NSTask> task([[NSTask alloc] init]); 48 base::scoped_nsobject<NSTask> task([[NSTask alloc] init]);
49 [task setStandardOutput:pipe]; 49 [task setStandardOutput:pipe];
50 [task setLaunchPath:@"/usr/bin/sw_vers"]; 50 [task setLaunchPath:@"/usr/bin/sw_vers"];
51 [task setArguments:@[ argument ]]; 51 [task setArguments:@[ argument ]];
52 52
53 @try { 53 @try {
54 [task launch]; 54 [task launch];
(...skipping 28 matching lines...) Expand all
83 83
84 std::string version; 84 std::string version;
85 if (bugfix) { 85 if (bugfix) {
86 version = base::StringPrintf("%d.%d.%d", major, minor, bugfix); 86 version = base::StringPrintf("%d.%d.%d", major, minor, bugfix);
87 } else { 87 } else {
88 // 10.x.0 releases report their version string as simply 10.x. 88 // 10.x.0 releases report their version string as simply 10.x.
89 version = base::StringPrintf("%d.%d", major, minor); 89 version = base::StringPrintf("%d.%d", major, minor);
90 } 90 }
91 91
92 std::string expected_product_version; 92 std::string expected_product_version;
93 SwVers(@"-productVersion", &expected_product_version); 93 ASSERT_NO_FATAL_FAILURE(
94 if (Test::HasFatalFailure()) { 94 SwVers(@"-productVersion", &expected_product_version));
95 return;
96 }
97 95
98 EXPECT_EQ(expected_product_version, version); 96 EXPECT_EQ(expected_product_version, version);
99 97
100 std::string expected_build_version; 98 std::string expected_build_version;
101 SwVers(@"-buildVersion", &expected_build_version); 99 ASSERT_NO_FATAL_FAILURE(SwVers(@"-buildVersion", &expected_build_version));
102 if (Test::HasFatalFailure()) {
103 return;
104 }
105 100
106 EXPECT_EQ(expected_build_version, build); 101 EXPECT_EQ(expected_build_version, build);
107 102
108 std::string expected_product_name; 103 std::string expected_product_name;
109 SwVers(@"-productName", &expected_product_name); 104 ASSERT_NO_FATAL_FAILURE(SwVers(@"-productName", &expected_product_name));
110 if (Test::HasFatalFailure()) {
111 return;
112 }
113 105
114 // Look for a space after the product name in the complete version string. 106 // Look for a space after the product name in the complete version string.
115 expected_product_name += ' '; 107 expected_product_name += ' ';
116 EXPECT_EQ(0u, version_string.find(expected_product_name)); 108 EXPECT_EQ(0u, version_string.find(expected_product_name));
117 } 109 }
118 110
119 TEST(MacUtil, MacOSXMinorVersion) { 111 TEST(MacUtil, MacOSXMinorVersion) {
120 // Make sure that MacOSXMinorVersion() and MacOSXVersion() agree. The two have 112 // Make sure that MacOSXMinorVersion() and MacOSXVersion() agree. The two have
121 // their own distinct implementations, and the latter was checked against 113 // their own distinct implementations, and the latter was checked against
122 // sw_vers above. 114 // sw_vers above.
(...skipping 19 matching lines...) Expand all
142 std::string board; 134 std::string board;
143 MacModelAndBoard(&model, &board); 135 MacModelAndBoard(&model, &board);
144 136
145 EXPECT_FALSE(model.empty()); 137 EXPECT_FALSE(model.empty());
146 EXPECT_FALSE(board.empty()); 138 EXPECT_FALSE(board.empty());
147 } 139 }
148 140
149 } // namespace 141 } // namespace
150 } // namespace test 142 } // namespace test
151 } // namespace crashpad 143 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_system_info_writer_test.cc ('k') | util/mac/mach_o_image_reader_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698