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

Unified Diff: sandbox/mac/sandbox_mac_compiler_unittest.mm

Issue 2914693002: Add IsSandboxed() function to seatbelt wrapper. (Closed)
Patch Set: Improve function documentation 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') | no next file with comments »
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..eea5959ed15b9d2f6e96ac3fdb41a644968e0e67 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(!Seatbelt::IsSandboxed());
+ std::string profile =
+ "(version 1)"
+ "(deny default (with no-log))";
+
+ SandboxCompiler compiler(profile);
+ std::string error;
+ CHECK(compiler.CompileAndApplyProfile(&error));
+ CHECK(Seatbelt::IsSandboxed());
+
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698