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

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

Issue 10878033: Simplified unit testing of sandboxing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing parameter that suppresses benign error messages Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/seccomp-bpf/die.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
6
7 using playground2::Die;
8 using playground2::Sandbox;
9
10 namespace sandbox {
11
12 void BpfTests::TestWrapper(void *void_arg) {
13 TestArgs *arg = reinterpret_cast<TestArgs *>(void_arg);
14 Die::EnableSimpleExit();
15 if (Sandbox::supportsSeccompSandbox(-1) ==
16 Sandbox::STATUS_AVAILABLE) {
17 // Ensure the the sandbox is actually available at this time
18 int proc_fd;
19 BPF_ASSERT((proc_fd = open("/proc", O_RDONLY|O_DIRECTORY)) >= 0);
20 BPF_ASSERT(Sandbox::supportsSeccompSandbox(proc_fd) ==
21 Sandbox::STATUS_AVAILABLE);
22
23 // Initialize and then start the sandbox with our custom policy
24 Sandbox::setProcFd(proc_fd);
25 Sandbox::setSandboxPolicy(arg->policy(), NULL);
26 Sandbox::startSandbox();
27 arg->test()();
28 } else {
29 // TODO(markus): (crbug.com/141545) Call the compiler and verify the
30 // policy. That's the least we can do, if we don't have kernel support.
31 Sandbox::setSandboxPolicy(arg->policy(), NULL);
32 }
33 }
34
35 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf/bpf_tests.h ('k') | sandbox/linux/seccomp-bpf/die.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698