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

Side by Side Diff: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc

Issue 938223004: Linux sandbox: better APIs with /proc/ arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix invalid proc_fd_ usage. Created 5 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
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.cc ('k') | sandbox/linux/services/credentials.h » ('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 Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <iostream> 10 #include <iostream>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 65
66 TEST(SandboxBPF, ProcTaskFdDescriptorGetsClosed) { 66 TEST(SandboxBPF, ProcTaskFdDescriptorGetsClosed) {
67 int pipe_fds[2]; 67 int pipe_fds[2];
68 ASSERT_EQ(0, pipe(pipe_fds)); 68 ASSERT_EQ(0, pipe(pipe_fds));
69 base::ScopedFD read_end(pipe_fds[0]); 69 base::ScopedFD read_end(pipe_fds[0]);
70 base::ScopedFD write_end(pipe_fds[1]); 70 base::ScopedFD write_end(pipe_fds[1]);
71 71
72 { 72 {
73 SandboxBPF sandbox(nullptr); 73 SandboxBPF sandbox(nullptr);
74 sandbox.SetProcTaskFd(write_end.Pass()); 74 sandbox.SetProcFd(write_end.Pass());
75 } 75 }
76 76
77 ASSERT_EQ(0, fcntl(read_end.get(), F_SETFL, O_NONBLOCK)); 77 ASSERT_EQ(0, fcntl(read_end.get(), F_SETFL, O_NONBLOCK));
78 char c; 78 char c;
79 // Check that the sandbox closed the write_end (read will EOF instead of 79 // Check that the sandbox closed the write_end (read will EOF instead of
80 // returning EWOULDBLOCK). 80 // returning EWOULDBLOCK).
81 ASSERT_EQ(0, read(read_end.get(), &c, 1)); 81 ASSERT_EQ(0, read(read_end.get(), &c, 1));
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 } // sandbox 85 } // sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/sandbox_bpf.cc ('k') | sandbox/linux/services/credentials.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698