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

Side by Side Diff: util/posix/scoped_fcntl_flags_test.cc

Issue 649693002: Add ScopedTaskSuspend and its test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Updates following VM testing 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
OLDNEW
(Empty)
1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "util/posix/scoped_fcntl_flags.h"
16
17 #include <fcntl.h>
18 #include <paths.h>
19
20 #include "base/files/scoped_file.h"
21 #include "base/logging.h"
22 #include "base/posix/eintr_wrapper.h"
23 #include "gtest/gtest.h"
24 #include "util/test/errors.h"
25
26 namespace crashpad {
27 namespace test {
28 namespace {
29
30 // Returns the value of the file descriptor |fd|’s status flags as
31 // fcntl(fd, F_GETFL) does. On error, terminates execution.
32 int FcntlFlags(int fd) {
33 int rv = fcntl(fd, F_GETFL, 0);
34 PCHECK(rv != -1) << "fcntl";
Robert Sesek 2014/10/13 19:09:39 Use EXPECT_ instead so you don't crash the test?
35
36 return rv;
37 }
38
39 TEST(ScopedFcntlFlags, ScopedFcntlFlags) {
40 int fd = HANDLE_EINTR(open(_PATH_DEVNULL, O_RDWR));
41 ASSERT_GE(fd, 0) << ErrnoMessage("open");
42
43 base::ScopedFD fd_owner(fd);
44
45 int flags = FcntlFlags(fd);
46 EXPECT_EQ(O_RDWR, flags);
47
48 {
49 ScopedFcntlFlags fcntl_flags(fd, O_NONBLOCK, 0);
50 EXPECT_EQ(O_RDWR | O_NONBLOCK, FcntlFlags(fd));
51
52 {
53 ScopedFcntlFlags fcntl_flags(fd, 0, O_NONBLOCK);
54 EXPECT_EQ(O_RDWR, FcntlFlags(fd));
55 }
56
57 EXPECT_EQ(O_RDWR | O_NONBLOCK, FcntlFlags(fd));
58 }
59
60 EXPECT_EQ(O_RDWR, flags);
61 }
62
63 } // namespace
64 } // namespace test
65 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698