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

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

Issue 10834075: Linux sandbox unit test: log BPF support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, make sure to check for STATUS_AVAILABLE. Created 8 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <ostream>
6
5 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 7 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
6 #include "sandbox/linux/seccomp-bpf/verifier.h" 8 #include "sandbox/linux/seccomp-bpf/verifier.h"
7 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
8 10
9 using namespace playground2; 11 using namespace playground2;
10 12
11 namespace { 13 namespace {
12 14
13 const int kExpectedReturnValue = 42; 15 const int kExpectedReturnValue = 42;
14 16
15 TEST(SandboxBpf, CallSupports) { 17 TEST(SandboxBpf, CallSupports) {
16 // We check that we don't crash, but it's ok if the kernel doesn't 18 // We check that we don't crash, but it's ok if the kernel doesn't
17 // support it. 19 // support it.
18 Sandbox::supportsSeccompSandbox(-1); 20 bool seccomp_bpf_supported =
21 Sandbox::supportsSeccompSandbox(-1) == Sandbox::STATUS_AVAILABLE;
22 // We want to log whether or not seccomp BPF is actually supported
23 // since actual test coverage depends on it.
24 RecordProperty("SeccompBPFSupported",
25 seccomp_bpf_supported ? "true." : "false.");
26 std::cout << "Seccomp BPF supported: "
27 << (seccomp_bpf_supported ? "true." : "false.")
28 << "\n";
19 } 29 }
20 30
21 TEST(SandboxBpf, CallSupportsTwice) { 31 TEST(SandboxBpf, CallSupportsTwice) {
22 Sandbox::supportsSeccompSandbox(-1); 32 Sandbox::supportsSeccompSandbox(-1);
23 Sandbox::supportsSeccompSandbox(-1); 33 Sandbox::supportsSeccompSandbox(-1);
24 } 34 }
25 35
26 __attribute__((noreturn)) void DoCrash() { 36 __attribute__((noreturn)) void DoCrash() {
27 // Cause a #PF. This only works if we assume that we have the default 37 // Cause a #PF. This only works if we assume that we have the default
28 // SIGSEGV handler. 38 // SIGSEGV handler.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 261 }
252 } 262 }
253 ExitGroup(kExpectedReturnValue); 263 ExitGroup(kExpectedReturnValue);
254 } 264 }
255 265
256 TEST(SandboxBpf, SyntheticPolicy) { 266 TEST(SandboxBpf, SyntheticPolicy) {
257 TryPolicyInProcess(SyntheticPolicy, SyntheticProcess); 267 TryPolicyInProcess(SyntheticPolicy, SyntheticProcess);
258 } 268 }
259 269
260 } // namespace 270 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698