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

Side by Side Diff: third_party/crashpad/crashpad/util/file/file_io_test.cc

Issue 2773813002: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 (Closed)
Patch Set: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/file/file_io.h" 15 #include "util/file/file_io.h"
16 16
17 #include <stdio.h>
18
19 #include <limits>
20 #include <type_traits>
21
17 #include "base/atomicops.h" 22 #include "base/atomicops.h"
18 #include "base/files/file_path.h" 23 #include "base/files/file_path.h"
19 #include "base/macros.h" 24 #include "base/macros.h"
25 #include "gmock/gmock.h"
20 #include "gtest/gtest.h" 26 #include "gtest/gtest.h"
21 #include "test/errors.h" 27 #include "test/errors.h"
22 #include "test/file.h" 28 #include "test/file.h"
23 #include "test/scoped_temp_dir.h" 29 #include "test/scoped_temp_dir.h"
24 #include "util/misc/implicit_cast.h" 30 #include "util/misc/implicit_cast.h"
25 #include "util/thread/thread.h" 31 #include "util/thread/thread.h"
26 32
27 namespace crashpad { 33 namespace crashpad {
28 namespace test { 34 namespace test {
29 namespace { 35 namespace {
30 36
37 using testing::_;
38 using testing::InSequence;
39 using testing::Return;
40
41 class MockReadExactly : public internal::ReadExactlyInternal {
42 public:
43 MockReadExactly() : ReadExactlyInternal() {}
44 ~MockReadExactly() {}
45
46 // Since it’s more convenient for the test to use uintptr_t than void*,
47 // ReadExactlyInt() and ReadInt() adapt the types.
48
49 bool ReadExactlyInt(uintptr_t data, size_t size, bool can_log) {
50 return ReadExactly(reinterpret_cast<void*>(data), size, can_log);
51 }
52
53 MOCK_METHOD3(ReadInt, FileOperationResult(uintptr_t, size_t, bool));
54
55 // ReadExactlyInternal:
56 FileOperationResult Read(void* data, size_t size, bool can_log) {
57 return ReadInt(reinterpret_cast<uintptr_t>(data), size, can_log);
58 }
59
60 private:
61 DISALLOW_COPY_AND_ASSIGN(MockReadExactly);
62 };
63
64 TEST(FileIO, ReadExactly_Zero) {
65 MockReadExactly read_exactly;
66 InSequence in_sequence;
67 EXPECT_CALL(read_exactly, ReadInt(_, _, false)).Times(0);
68 EXPECT_TRUE(read_exactly.ReadExactlyInt(100, 0, false));
69 }
70
71 TEST(FileIO, ReadExactly_SingleSmallSuccess) {
72 MockReadExactly read_exactly;
73 InSequence in_sequence;
74 EXPECT_CALL(read_exactly, ReadInt(1000, 1, false)).WillOnce(Return(1));
75 EXPECT_TRUE(read_exactly.ReadExactlyInt(1000, 1, false));
76 }
77
78 TEST(FileIO, ReadExactly_SingleSmallSuccessCanLog) {
79 MockReadExactly read_exactly;
80 InSequence in_sequence;
81 EXPECT_CALL(read_exactly, ReadInt(1000, 1, true)).WillOnce(Return(1));
82 EXPECT_TRUE(read_exactly.ReadExactlyInt(1000, 1, true));
83 }
84
85 TEST(FileIO, ReadExactly_SingleSmallFailure) {
86 MockReadExactly read_exactly;
87 InSequence in_sequence;
88 EXPECT_CALL(read_exactly, ReadInt(1000, 1, false)).WillOnce(Return(-1));
89 EXPECT_FALSE(read_exactly.ReadExactlyInt(1000, 1, false));
90 }
91
92 TEST(FileIO, ReadExactly_SingleSmallFailureCanLog) {
93 MockReadExactly read_exactly;
94 InSequence in_sequence;
95 EXPECT_CALL(read_exactly, ReadInt(1000, 1, true)).WillOnce(Return(-1));
96 EXPECT_FALSE(read_exactly.ReadExactlyInt(1000, 1, true));
97 }
98
99 TEST(FileIO, ReadExactly_DoubleSmallSuccess) {
100 MockReadExactly read_exactly;
101 InSequence in_sequence;
102 EXPECT_CALL(read_exactly, ReadInt(0x1000, 2, false)).WillOnce(Return(1));
103 EXPECT_CALL(read_exactly, ReadInt(0x1001, 1, false)).WillOnce(Return(1));
104 EXPECT_TRUE(read_exactly.ReadExactlyInt(0x1000, 2, false));
105 }
106
107 TEST(FileIO, ReadExactly_DoubleSmallShort) {
108 MockReadExactly read_exactly;
109 InSequence in_sequence;
110 EXPECT_CALL(read_exactly, ReadInt(0x20000, 2, false)).WillOnce(Return(1));
111 EXPECT_CALL(read_exactly, ReadInt(0x20001, 1, false)).WillOnce(Return(0));
112 EXPECT_FALSE(read_exactly.ReadExactlyInt(0x20000, 2, false));
113 }
114
115 TEST(FileIO, ReadExactly_DoubleSmallShortCanLog) {
116 MockReadExactly read_exactly;
117 InSequence in_sequence;
118 EXPECT_CALL(read_exactly, ReadInt(0x20000, 2, true)).WillOnce(Return(1));
119 EXPECT_CALL(read_exactly, ReadInt(0x20001, 1, true)).WillOnce(Return(0));
120 EXPECT_FALSE(read_exactly.ReadExactlyInt(0x20000, 2, true));
121 }
122
123 TEST(FileIO, ReadExactly_Medium) {
124 MockReadExactly read_exactly;
125 InSequence in_sequence;
126 EXPECT_CALL(read_exactly, ReadInt(0x80000000, 0x20000000, false))
127 .WillOnce(Return(0x10000000));
128 EXPECT_CALL(read_exactly, ReadInt(0x90000000, 0x10000000, false))
129 .WillOnce(Return(0x8000000));
130 EXPECT_CALL(read_exactly, ReadInt(0x98000000, 0x8000000, false))
131 .WillOnce(Return(0x4000000));
132 EXPECT_CALL(read_exactly, ReadInt(0x9c000000, 0x4000000, false))
133 .WillOnce(Return(0x2000000));
134 EXPECT_CALL(read_exactly, ReadInt(0x9e000000, 0x2000000, false))
135 .WillOnce(Return(0x1000000));
136 EXPECT_CALL(read_exactly, ReadInt(0x9f000000, 0x1000000, false))
137 .WillOnce(Return(0x800000));
138 EXPECT_CALL(read_exactly, ReadInt(0x9f800000, 0x800000, false))
139 .WillOnce(Return(0x400000));
140 EXPECT_CALL(read_exactly, ReadInt(0x9fc00000, 0x400000, false))
141 .WillOnce(Return(0x200000));
142 EXPECT_CALL(read_exactly, ReadInt(0x9fe00000, 0x200000, false))
143 .WillOnce(Return(0x100000));
144 EXPECT_CALL(read_exactly, ReadInt(0x9ff00000, 0x100000, false))
145 .WillOnce(Return(0x80000));
146 EXPECT_CALL(read_exactly, ReadInt(0x9ff80000, 0x80000, false))
147 .WillOnce(Return(0x40000));
148 EXPECT_CALL(read_exactly, ReadInt(0x9ffc0000, 0x40000, false))
149 .WillOnce(Return(0x20000));
150 EXPECT_CALL(read_exactly, ReadInt(0x9ffe0000, 0x20000, false))
151 .WillOnce(Return(0x10000));
152 EXPECT_CALL(read_exactly, ReadInt(0x9fff0000, 0x10000, false))
153 .WillOnce(Return(0x8000));
154 EXPECT_CALL(read_exactly, ReadInt(0x9fff8000, 0x8000, false))
155 .WillOnce(Return(0x4000));
156 EXPECT_CALL(read_exactly, ReadInt(0x9fffc000, 0x4000, false))
157 .WillOnce(Return(0x2000));
158 EXPECT_CALL(read_exactly, ReadInt(0x9fffe000, 0x2000, false))
159 .WillOnce(Return(0x1000));
160 EXPECT_CALL(read_exactly, ReadInt(0x9ffff000, 0x1000, false))
161 .WillOnce(Return(0x800));
162 EXPECT_CALL(read_exactly, ReadInt(0x9ffff800, 0x800, false))
163 .WillOnce(Return(0x400));
164 EXPECT_CALL(read_exactly, ReadInt(0x9ffffc00, 0x400, false))
165 .WillOnce(Return(0x200));
166 EXPECT_CALL(read_exactly, ReadInt(0x9ffffe00, 0x200, false))
167 .WillOnce(Return(0x100));
168 EXPECT_CALL(read_exactly, ReadInt(0x9fffff00, 0x100, false))
169 .WillOnce(Return(0x80));
170 EXPECT_CALL(read_exactly, ReadInt(0x9fffff80, 0x80, false))
171 .WillOnce(Return(0x40));
172 EXPECT_CALL(read_exactly, ReadInt(0x9fffffc0, 0x40, false))
173 .WillOnce(Return(0x20));
174 EXPECT_CALL(read_exactly, ReadInt(0x9fffffe0, 0x20, false))
175 .WillOnce(Return(0x10));
176 EXPECT_CALL(read_exactly, ReadInt(0x9ffffff0, 0x10, false))
177 .WillOnce(Return(0x8));
178 EXPECT_CALL(read_exactly, ReadInt(0x9ffffff8, 0x8, false))
179 .WillOnce(Return(0x4));
180 EXPECT_CALL(read_exactly, ReadInt(0x9ffffffc, 0x4, false))
181 .WillOnce(Return(0x2));
182 EXPECT_CALL(read_exactly, ReadInt(0x9ffffffe, 0x2, false))
183 .WillOnce(Return(0x1));
184 EXPECT_CALL(read_exactly, ReadInt(0x9fffffff, 0x1, false))
185 .WillOnce(Return(0x1));
186 EXPECT_TRUE(read_exactly.ReadExactlyInt(0x80000000, 0x20000000, false));
187 }
188
189 TEST(FileIO, ReadExactly_LargeSuccess) {
190 MockReadExactly read_exactly;
191 InSequence in_sequence;
192 constexpr size_t max = std::numeric_limits<uint32_t>::max();
193 constexpr size_t increment = std::numeric_limits<int32_t>::max();
194 EXPECT_CALL(read_exactly, ReadInt(0, max, false)).WillOnce(Return(increment));
195 EXPECT_CALL(read_exactly, ReadInt(increment, max - increment, false))
196 .WillOnce(Return(increment));
197 EXPECT_CALL(read_exactly, ReadInt(2 * increment, 1, false))
198 .WillOnce(Return(1));
199 EXPECT_TRUE(read_exactly.ReadExactlyInt(0, max, false));
200 }
201
202 TEST(FileIO, ReadExactly_LargeShort) {
203 MockReadExactly read_exactly;
204 InSequence in_sequence;
205 EXPECT_CALL(read_exactly, ReadInt(0, 0xffffffff, false))
206 .WillOnce(Return(0x7fffffff));
207 EXPECT_CALL(read_exactly, ReadInt(0x7fffffff, 0x80000000, false))
208 .WillOnce(Return(0x10000000));
209 EXPECT_CALL(read_exactly, ReadInt(0x8fffffff, 0x70000000, false))
210 .WillOnce(Return(0));
211 EXPECT_FALSE(read_exactly.ReadExactlyInt(0, 0xffffffff, false));
212 }
213
214 TEST(FileIO, ReadExactly_LargeFailure) {
215 MockReadExactly read_exactly;
216 InSequence in_sequence;
217 EXPECT_CALL(read_exactly, ReadInt(0, 0xffffffff, false))
218 .WillOnce(Return(0x7fffffff));
219 EXPECT_CALL(read_exactly, ReadInt(0x7fffffff, 0x80000000, false))
220 .WillOnce(Return(-1));
221 EXPECT_FALSE(read_exactly.ReadExactlyInt(0, 0xffffffff, false));
222 }
223
224 TEST(FileIO, ReadExactly_TripleMax) {
225 MockReadExactly read_exactly;
226 InSequence in_sequence;
227 constexpr size_t max = std::numeric_limits<size_t>::max();
228 constexpr size_t increment =
229 std::numeric_limits<std::make_signed<size_t>::type>::max();
230 EXPECT_CALL(read_exactly, ReadInt(0, max, false)).WillOnce(Return(increment));
231 EXPECT_CALL(read_exactly, ReadInt(increment, max - increment, false))
232 .WillOnce(Return(increment));
233 EXPECT_CALL(read_exactly, ReadInt(2 * increment, 1, false))
234 .WillOnce(Return(1));
235 EXPECT_TRUE(read_exactly.ReadExactlyInt(0, max, false));
236 }
237
238 class MockWriteAll : public internal::WriteAllInternal {
239 public:
240 MockWriteAll() : WriteAllInternal() {}
241 ~MockWriteAll() {}
242
243 // Since it’s more convenient for the test to use uintptr_t than const void*,
244 // WriteAllInt() and WriteInt() adapt the types.
245
246 bool WriteAllInt(uintptr_t data, size_t size) {
247 return WriteAll(reinterpret_cast<const void*>(data), size);
248 }
249
250 MOCK_METHOD2(WriteInt, FileOperationResult(uintptr_t, size_t));
251
252 // WriteAllInternal:
253 FileOperationResult Write(const void* data, size_t size) {
254 return WriteInt(reinterpret_cast<uintptr_t>(data), size);
255 }
256
257 private:
258 DISALLOW_COPY_AND_ASSIGN(MockWriteAll);
259 };
260
261 TEST(FileIO, WriteAll_Zero) {
262 MockWriteAll write_all;
263 InSequence in_sequence;
264 EXPECT_CALL(write_all, WriteInt(_, _)).Times(0);
265 EXPECT_TRUE(write_all.WriteAllInt(100, 0));
266 }
267
268 TEST(FileIO, WriteAll_SingleSmallSuccess) {
269 MockWriteAll write_all;
270 InSequence in_sequence;
271 EXPECT_CALL(write_all, WriteInt(1000, 1)).WillOnce(Return(1));
272 EXPECT_TRUE(write_all.WriteAllInt(1000, 1));
273 }
274
275 TEST(FileIO, WriteAll_SingleSmallFailure) {
276 MockWriteAll write_all;
277 InSequence in_sequence;
278 EXPECT_CALL(write_all, WriteInt(1000, 1)).WillOnce(Return(-1));
279 EXPECT_FALSE(write_all.WriteAllInt(1000, 1));
280 }
281
282 TEST(FileIO, WriteAll_DoubleSmall) {
283 MockWriteAll write_all;
284 InSequence in_sequence;
285 EXPECT_CALL(write_all, WriteInt(0x1000, 2)).WillOnce(Return(1));
286 EXPECT_CALL(write_all, WriteInt(0x1001, 1)).WillOnce(Return(1));
287 EXPECT_TRUE(write_all.WriteAllInt(0x1000, 2));
288 }
289
290 TEST(FileIO, WriteAll_Medium) {
291 MockWriteAll write_all;
292 InSequence in_sequence;
293 EXPECT_CALL(write_all, WriteInt(0x80000000, 0x20000000))
294 .WillOnce(Return(0x10000000));
295 EXPECT_CALL(write_all, WriteInt(0x90000000, 0x10000000))
296 .WillOnce(Return(0x8000000));
297 EXPECT_CALL(write_all, WriteInt(0x98000000, 0x8000000))
298 .WillOnce(Return(0x4000000));
299 EXPECT_CALL(write_all, WriteInt(0x9c000000, 0x4000000))
300 .WillOnce(Return(0x2000000));
301 EXPECT_CALL(write_all, WriteInt(0x9e000000, 0x2000000))
302 .WillOnce(Return(0x1000000));
303 EXPECT_CALL(write_all, WriteInt(0x9f000000, 0x1000000))
304 .WillOnce(Return(0x800000));
305 EXPECT_CALL(write_all, WriteInt(0x9f800000, 0x800000))
306 .WillOnce(Return(0x400000));
307 EXPECT_CALL(write_all, WriteInt(0x9fc00000, 0x400000))
308 .WillOnce(Return(0x200000));
309 EXPECT_CALL(write_all, WriteInt(0x9fe00000, 0x200000))
310 .WillOnce(Return(0x100000));
311 EXPECT_CALL(write_all, WriteInt(0x9ff00000, 0x100000))
312 .WillOnce(Return(0x80000));
313 EXPECT_CALL(write_all, WriteInt(0x9ff80000, 0x80000))
314 .WillOnce(Return(0x40000));
315 EXPECT_CALL(write_all, WriteInt(0x9ffc0000, 0x40000))
316 .WillOnce(Return(0x20000));
317 EXPECT_CALL(write_all, WriteInt(0x9ffe0000, 0x20000))
318 .WillOnce(Return(0x10000));
319 EXPECT_CALL(write_all, WriteInt(0x9fff0000, 0x10000))
320 .WillOnce(Return(0x8000));
321 EXPECT_CALL(write_all, WriteInt(0x9fff8000, 0x8000)).WillOnce(Return(0x4000));
322 EXPECT_CALL(write_all, WriteInt(0x9fffc000, 0x4000)).WillOnce(Return(0x2000));
323 EXPECT_CALL(write_all, WriteInt(0x9fffe000, 0x2000)).WillOnce(Return(0x1000));
324 EXPECT_CALL(write_all, WriteInt(0x9ffff000, 0x1000)).WillOnce(Return(0x800));
325 EXPECT_CALL(write_all, WriteInt(0x9ffff800, 0x800)).WillOnce(Return(0x400));
326 EXPECT_CALL(write_all, WriteInt(0x9ffffc00, 0x400)).WillOnce(Return(0x200));
327 EXPECT_CALL(write_all, WriteInt(0x9ffffe00, 0x200)).WillOnce(Return(0x100));
328 EXPECT_CALL(write_all, WriteInt(0x9fffff00, 0x100)).WillOnce(Return(0x80));
329 EXPECT_CALL(write_all, WriteInt(0x9fffff80, 0x80)).WillOnce(Return(0x40));
330 EXPECT_CALL(write_all, WriteInt(0x9fffffc0, 0x40)).WillOnce(Return(0x20));
331 EXPECT_CALL(write_all, WriteInt(0x9fffffe0, 0x20)).WillOnce(Return(0x10));
332 EXPECT_CALL(write_all, WriteInt(0x9ffffff0, 0x10)).WillOnce(Return(0x8));
333 EXPECT_CALL(write_all, WriteInt(0x9ffffff8, 0x8)).WillOnce(Return(0x4));
334 EXPECT_CALL(write_all, WriteInt(0x9ffffffc, 0x4)).WillOnce(Return(0x2));
335 EXPECT_CALL(write_all, WriteInt(0x9ffffffe, 0x2)).WillOnce(Return(0x1));
336 EXPECT_CALL(write_all, WriteInt(0x9fffffff, 0x1)).WillOnce(Return(0x1));
337 EXPECT_TRUE(write_all.WriteAllInt(0x80000000, 0x20000000));
338 }
339
340 TEST(FileIO, WriteAll_LargeSuccess) {
341 MockWriteAll write_all;
342 InSequence in_sequence;
343 constexpr size_t max = std::numeric_limits<uint32_t>::max();
344 constexpr size_t increment = std::numeric_limits<int32_t>::max();
345 EXPECT_CALL(write_all, WriteInt(0, max)).WillOnce(Return(increment));
346 EXPECT_CALL(write_all, WriteInt(increment, max - increment))
347 .WillOnce(Return(increment));
348 EXPECT_CALL(write_all, WriteInt(2 * increment, 1)).WillOnce(Return(1));
349 EXPECT_TRUE(write_all.WriteAllInt(0, max));
350 }
351
352 TEST(FileIO, WriteAll_LargeFailure) {
353 MockWriteAll write_all;
354 InSequence in_sequence;
355 EXPECT_CALL(write_all, WriteInt(0, 0xffffffff)).WillOnce(Return(0x7fffffff));
356 EXPECT_CALL(write_all, WriteInt(0x7fffffff, 0x80000000)).WillOnce(Return(-1));
357 EXPECT_FALSE(write_all.WriteAllInt(0, 0xffffffff));
358 }
359
360 TEST(FileIO, WriteAll_TripleMax) {
361 MockWriteAll write_all;
362 InSequence in_sequence;
363 constexpr size_t max = std::numeric_limits<size_t>::max();
364 constexpr size_t increment =
365 std::numeric_limits<std::make_signed<size_t>::type>::max();
366 EXPECT_CALL(write_all, WriteInt(0, max)).WillOnce(Return(increment));
367 EXPECT_CALL(write_all, WriteInt(increment, max - increment))
368 .WillOnce(Return(increment));
369 EXPECT_CALL(write_all, WriteInt(2 * increment, 1)).WillOnce(Return(1));
370 EXPECT_TRUE(write_all.WriteAllInt(0, max));
371 }
372
31 void TestOpenFileForWrite(FileHandle (*opener)(const base::FilePath&, 373 void TestOpenFileForWrite(FileHandle (*opener)(const base::FilePath&,
32 FileWriteMode, 374 FileWriteMode,
33 FilePermissions)) { 375 FilePermissions)) {
34 ScopedTempDir temp_dir; 376 ScopedTempDir temp_dir;
35 base::FilePath file_path_1 = 377 base::FilePath file_path_1 =
36 temp_dir.path().Append(FILE_PATH_LITERAL("file_1")); 378 temp_dir.path().Append(FILE_PATH_LITERAL("file_1"));
37 ASSERT_FALSE(FileExists(file_path_1)); 379 ASSERT_FALSE(FileExists(file_path_1));
38 380
39 ScopedFileHandle file_handle(opener(file_path_1, 381 ScopedFileHandle file_handle(opener(file_path_1,
40 FileWriteMode::kReuseOrFail, 382 FileWriteMode::kReuseOrFail,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 file_path, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly)); 659 file_path, FileWriteMode::kCreateOrFail, FilePermissions::kOwnerOnly));
318 ASSERT_NE(kInvalidFileHandle, file_handle.get()); 660 ASSERT_NE(kInvalidFileHandle, file_handle.get());
319 EXPECT_EQ(0, LoggingFileSizeByHandle(file_handle.get())); 661 EXPECT_EQ(0, LoggingFileSizeByHandle(file_handle.get()));
320 662
321 const char data[] = "zippyzap"; 663 const char data[] = "zippyzap";
322 ASSERT_TRUE(LoggingWriteFile(file_handle.get(), &data, sizeof(data))); 664 ASSERT_TRUE(LoggingWriteFile(file_handle.get(), &data, sizeof(data)));
323 665
324 EXPECT_EQ(9, LoggingFileSizeByHandle(file_handle.get())); 666 EXPECT_EQ(9, LoggingFileSizeByHandle(file_handle.get()));
325 } 667 }
326 668
669 FileHandle FileHandleForFILE(FILE* file) {
670 int fd = fileno(file);
671 #if defined(OS_POSIX)
672 return fd;
673 #elif defined(OS_WIN)
674 return reinterpret_cast<HANDLE>(_get_osfhandle(fd));
675 #else
676 #error Port
677 #endif
678 }
679
680 TEST(FileIO, StdioFileHandle) {
681 EXPECT_EQ(FileHandleForFILE(stdin),
682 StdioFileHandle(StdioStream::kStandardInput));
683 EXPECT_EQ(FileHandleForFILE(stdout),
684 StdioFileHandle(StdioStream::kStandardOutput));
685 EXPECT_EQ(FileHandleForFILE(stderr),
686 StdioFileHandle(StdioStream::kStandardError));
687 }
688
327 } // namespace 689 } // namespace
328 } // namespace test 690 } // namespace test
329 } // namespace crashpad 691 } // namespace crashpad
OLDNEW
« no previous file with comments | « third_party/crashpad/crashpad/util/file/file_io_posix.cc ('k') | third_party/crashpad/crashpad/util/file/file_io_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698