| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |