summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authorjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 06:36:02 +0000
committerjln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 06:36:02 +0000
commitfafece1c7120bac8504f1702803121d53d29184b (patch)
treedc255f6accb9b728e2f7b0687d984da5c8d54469 /sandbox
parent88bfd25b311285e09b13a9c19c27eb6359a41c71 (diff)
downloadchromium_src-fafece1c7120bac8504f1702803121d53d29184b.zip
chromium_src-fafece1c7120bac8504f1702803121d53d29184b.tar.gz
chromium_src-fafece1c7120bac8504f1702803121d53d29184b.tar.bz2
Seccomp BPF: initial structure for unittests
- On Linux, support a new sandbox_linux_unittests target - Add a new seccomp_bpf_unittests target as a dependency of the global sandbox_linux_unittests target. - Integrate globally as a chromium_builder_tests dependency BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10635006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc11
-rw-r--r--sandbox/linux/tests/unit_tests.cc9
-rw-r--r--sandbox/sandbox_linux.gypi53
3 files changed, 62 insertions, 11 deletions
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
new file mode 100644
index 0000000..ead6c4e
--- /dev/null
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
+#include "sandbox/linux/seccomp-bpf/verifier.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(SandboxBpf, CallSupports) {
+ playground2::Sandbox::supportsSeccompSandbox(-1);
+}
diff --git a/sandbox/linux/tests/unit_tests.cc b/sandbox/linux/tests/unit_tests.cc
new file mode 100644
index 0000000..999d4a6
--- /dev/null
+++ b/sandbox/linux/tests/unit_tests.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+int main(int argc, char *argv[]) {
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/sandbox/sandbox_linux.gypi b/sandbox/sandbox_linux.gypi
index e03c5b5..fb313a6 100644
--- a/sandbox/sandbox_linux.gypi
+++ b/sandbox/sandbox_linux.gypi
@@ -4,6 +4,10 @@
{
'targets': [
+ # We have two principal targets: sandbox and sandbox_linux_unittests
+ # All other targets are listed as dependencies.
+ # FIXME(jln): for historial reasons, sandbox_linux is the setuid sandbox
+ # and is its own target.
{
'target_name': 'sandbox',
'type': 'none',
@@ -16,26 +20,53 @@
'../seccompsandbox/seccomp.gyp:seccomp_sandbox',
],
}],
- # This does not include Android.
+ # Similarly, compile seccomp BPF when we support it
[ 'OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
'type': 'static_library',
- # Compile seccomp mode 2 code on Linux
- 'sources': [
- 'linux/seccomp-bpf/sandbox_bpf.cc',
- 'linux/seccomp-bpf/sandbox_bpf.h',
- 'linux/seccomp-bpf/verifier.cc',
- 'linux/seccomp-bpf/verifier.h',
- ],
'dependencies': [
- '../base/base.gyp:base',
+ 'seccomp_bpf',
],
- 'include_dirs': [
- '..',
+ }],
+ ],
+ },
+ {
+ 'target_name': 'sandbox_linux_unittests',
+ 'type': 'executable',
+ 'dependencies': [
+ 'sandbox',
+ '../testing/gtest.gyp:gtest',
+ ],
+ 'sources': [
+ 'linux/tests/unit_tests.cc',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'conditions': [
+ [ 'OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
+ 'sources': [
+ 'linux/seccomp-bpf/sandbox_bpf_unittest.cc'
],
}],
],
},
{
+ 'target_name': 'seccomp_bpf',
+ 'type': 'static_library',
+ 'sources': [
+ 'linux/seccomp-bpf/sandbox_bpf.cc',
+ 'linux/seccomp-bpf/sandbox_bpf.h',
+ 'linux/seccomp-bpf/verifier.cc',
+ 'linux/seccomp-bpf/verifier.h',
+ ],
+ 'dependencies': [
+ '../base/base.gyp:base',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ },
+ {
# The setuid sandbox, for Linux
'target_name': 'chrome_sandbox',
'type': 'executable',