Commit 7d47e639 authored by jbauman's avatar jbauman Committed by Commit bot

Add unittest that sandbox::PolicyBase outlives child process.

BUG=663019
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.win:win10_chromium_x64_rel_ng

Review-Url: https://codereview.chromium.org/2513163002
Cr-Commit-Position: refs/heads/master@{#434778}
parent 87906662
......@@ -214,6 +214,15 @@ TEST(PolicyTargetTest, OpenProcess) {
"Opens a process";
}
TEST(PolicyTargetTest, PolicyBaseNoJobLifetime) {
TestRunner runner(JOB_NONE, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN);
runner.SetReleasePolicyInRun(true);
// TargetPolicy and its SharedMemIPCServer should continue to exist until
// the child process dies.
EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread"))
<< "Opens the current thread";
}
// Launches the app in the sandbox and ask it to wait in an
// infinite loop. Waits for 2 seconds and then check if the
// desktop associated with the app thread is not the same as the
......
......@@ -242,6 +242,10 @@ int TestRunner::InternalRunTest(const wchar_t* command) {
result = broker_->SpawnTarget(prog_name, arguments.c_str(), policy_,
&warning_result, &last_error, &target);
}
if (release_policy_in_run_) {
policy_->Release();
policy_ = nullptr;
}
if (SBOX_ALL_OK != result)
return SBOX_TEST_FAILED_TO_RUN_TEST;
......
......@@ -116,6 +116,10 @@ class TestRunner {
// destroyed.
void SetKillOnDestruction(bool value) { kill_on_destruction_ = value; }
// Sets whether the TargetPolicy should be released after the child process
// is launched while the test is running.
void SetReleasePolicyInRun(bool value) { release_policy_in_run_ = value; }
// Returns the pointers to the policy object. It can be used to modify
// the policy manually.
TargetPolicy* GetPolicy();
......@@ -147,6 +151,7 @@ class TestRunner {
bool no_sandbox_;
bool disable_csrss_;
bool kill_on_destruction_;
bool release_policy_in_run_ = false;
base::win::ScopedHandle target_process_;
DWORD target_process_id_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment