| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 "base/win_util.h" | 5 #include "base/win_util.h" |
| 6 #include "sandbox/src/sandbox.h" | 6 #include "sandbox/src/sandbox.h" |
| 7 #include "sandbox/src/sandbox_factory.h" | 7 #include "sandbox/src/sandbox_factory.h" |
| 8 #include "sandbox/src/sandbox_utils.h" | 8 #include "sandbox/src/sandbox_utils.h" |
| 9 #include "sandbox/src/target_services.h" | 9 #include "sandbox/src/target_services.h" |
| 10 #include "sandbox/tests/common/controller.h" | 10 #include "sandbox/tests/common/controller.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 return SBOX_TEST_SUCCEEDED; | 144 return SBOX_TEST_SUCCEEDED; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Tests that we can call CreateProcess. | 147 // Tests that we can call CreateProcess. |
| 148 SBOX_TESTS_COMMAND int PolicyTargetTest_process(int argc, wchar_t **argv) { | 148 SBOX_TESTS_COMMAND int PolicyTargetTest_process(int argc, wchar_t **argv) { |
| 149 // Use default values to create a new process. | 149 // Use default values to create a new process. |
| 150 STARTUPINFO startup_info = {0}; | 150 STARTUPINFO startup_info = {0}; |
| 151 startup_info.cb = sizeof(startup_info); | 151 startup_info.cb = sizeof(startup_info); |
| 152 PROCESS_INFORMATION process_info; | 152 PROCESS_INFORMATION process_info; |
| 153 ::CreateProcess(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, NULL, NULL, | 153 if (!::CreateProcessW(L"foo.exe", L"foo.exe", NULL, NULL, FALSE, 0, |
| 154 &startup_info, &process_info); | 154 NULL, NULL, &startup_info, &process_info)) |
| 155 | 155 return SBOX_TEST_SUCCEEDED; |
| 156 return SBOX_TEST_SUCCEEDED; | 156 return SBOX_TEST_FAILED; |
| 157 } | 157 } |
| 158 | 158 |
| 159 TEST(PolicyTargetTest, SetInformationThread) { | 159 TEST(PolicyTargetTest, SetInformationThread) { |
| 160 TestRunner runner; | 160 TestRunner runner; |
| 161 if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { | 161 if (win_util::GetWinVersion() >= win_util::WINVERSION_XP) { |
| 162 runner.SetTestState(BEFORE_REVERT); | 162 runner.SetTestState(BEFORE_REVERT); |
| 163 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); | 163 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token")); |
| 164 } | 164 } |
| 165 | 165 |
| 166 runner.SetTestState(AFTER_REVERT); | 166 runner.SetTestState(AFTER_REVERT); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 187 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) | 187 if (win_util::GetWinVersion() < win_util::WINVERSION_XP) |
| 188 return; | 188 return; |
| 189 | 189 |
| 190 runner.SetTestState(BEFORE_REVERT); | 190 runner.SetTestState(BEFORE_REVERT); |
| 191 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token3")); | 191 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_token3")); |
| 192 | 192 |
| 193 runner.SetTestState(AFTER_REVERT); | 193 runner.SetTestState(AFTER_REVERT); |
| 194 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token3")); | 194 EXPECT_EQ(ERROR_NO_TOKEN, runner.RunTest(L"PolicyTargetTest_token3")); |
| 195 } | 195 } |
| 196 | 196 |
| 197 #if !defined(_WIN64) | |
| 198 // Bug 27218: We don't have dispatch for some x64 syscalls. | |
| 199 TEST(PolicyTargetTest, OpenThread) { | 197 TEST(PolicyTargetTest, OpenThread) { |
| 200 TestRunner runner; | 198 TestRunner runner; |
| 201 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread")) << | 199 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread")) << |
| 202 "Opens the current thread"; | 200 "Opens the current thread"; |
| 203 | 201 |
| 204 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread2")) << | 202 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_thread2")) << |
| 205 "Creates a new thread and opens it"; | 203 "Creates a new thread and opens it"; |
| 206 } | 204 } |
| 207 | 205 |
| 208 TEST(PolicyTargetTest, OpenProcess) { | 206 TEST(PolicyTargetTest, OpenProcess) { |
| 209 TestRunner runner; | 207 TestRunner runner; |
| 210 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_process")) << | 208 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"PolicyTargetTest_process")) << |
| 211 "Opens a process"; | 209 "Opens a process"; |
| 212 } | 210 } |
| 213 | 211 |
| 212 #if !defined(_WIN64) |
| 213 |
| 214 // Launches the app in the sandbox and ask it to wait in an | 214 // Launches the app in the sandbox and ask it to wait in an |
| 215 // infinite loop. Waits for 2 seconds and then check if the | 215 // infinite loop. Waits for 2 seconds and then check if the |
| 216 // desktop associated with the app thread is not the same as the | 216 // desktop associated with the app thread is not the same as the |
| 217 // current desktop. | 217 // current desktop. |
| 218 TEST(PolicyTargetTest, DesktopPolicy) { | 218 TEST(PolicyTargetTest, DesktopPolicy) { |
| 219 BrokerServices* broker = GetBroker(); | 219 BrokerServices* broker = GetBroker(); |
| 220 | 220 |
| 221 // Precreate the desktop. | 221 // Precreate the desktop. |
| 222 TargetPolicy* temp_policy = broker->CreatePolicy(); | 222 TargetPolicy* temp_policy = broker->CreatePolicy(); |
| 223 temp_policy->CreateAlternateDesktop(false); | 223 temp_policy->CreateAlternateDesktop(false); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 EXPECT_TRUE(::CloseHandle(target.hThread)); | 334 EXPECT_TRUE(::CloseHandle(target.hThread)); |
| 335 | 335 |
| 336 // Close the desktop handle. | 336 // Close the desktop handle. |
| 337 temp_policy = broker->CreatePolicy(); | 337 temp_policy = broker->CreatePolicy(); |
| 338 temp_policy->DestroyAlternateDesktop(); | 338 temp_policy->DestroyAlternateDesktop(); |
| 339 temp_policy->Release(); | 339 temp_policy->Release(); |
| 340 } | 340 } |
| 341 #endif // _WIN64 | 341 #endif // _WIN64 |
| 342 | 342 |
| 343 } // namespace sandbox | 343 } // namespace sandbox |
| OLD | NEW |