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

Unified Diff: sandbox/mac/sandbox_mac_compiler_unittest.mm

Issue 2914693002: Add IsSandboxed() function to seatbelt wrapper. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sandbox/mac/seatbelt.h » ('j') | sandbox/mac/seatbelt.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/mac/sandbox_mac_compiler_unittest.mm
diff --git a/sandbox/mac/sandbox_mac_compiler_unittest.mm b/sandbox/mac/sandbox_mac_compiler_unittest.mm
index c04d89f97efea2f77a1336ff6c013ad3a42355f6..d011d0267031d04677934fd9ae9eb9ffec06f2a3 100644
--- a/sandbox/mac/sandbox_mac_compiler_unittest.mm
+++ b/sandbox/mac/sandbox_mac_compiler_unittest.mm
@@ -11,6 +11,7 @@
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
#include "sandbox/mac/sandbox_compiler.h"
+#include "sandbox/mac/seatbelt.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
@@ -162,4 +163,27 @@ TEST_F(SandboxMacCompilerTest, ProfileFunctionalityTestError) {
EXPECT_EQ(exit_code, 0);
}
+MULTIPROCESS_TEST_MAIN(SandboxCheckTestProcess) {
+ CHECK_EQ(0, sandbox_check(getpid(), NULL, SANDBOX_FILTER_NONE));
+ std::string profile =
+ "(version 1)"
+ "(deny default (with no-log))";
+
+ SandboxCompiler compiler(profile);
+ std::string error;
+ CHECK(compiler.CompileAndApplyProfile(&error));
+ CHECK_EQ(1, sandbox_check(getpid(), NULL, SANDBOX_FILTER_NONE));
+
+ return 0;
+}
+
+TEST_F(SandboxMacCompilerTest, SandboxCheckTest) {
+ base::SpawnChildResult spawn_child = SpawnChild("SandboxCheckTestProcess");
+ ASSERT_TRUE(spawn_child.process.IsValid());
+ int exit_code = 42;
+ EXPECT_TRUE(spawn_child.process.WaitForExitWithTimeout(
+ TestTimeouts::action_max_timeout(), &exit_code));
+ EXPECT_EQ(exit_code, 0);
+}
+
} // namespace sandbox
« no previous file with comments | « no previous file | sandbox/mac/seatbelt.h » ('j') | sandbox/mac/seatbelt.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698