summaryrefslogtreecommitdiffstats
path: root/sandbox/src/unload_dll_test.cc
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-18 01:45:09 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-18 01:45:09 +0000
commit126720dd09a08ae7391568fe19f403a050be0627 (patch)
treebc4f78ded1e1582c291057302473308821288105 /sandbox/src/unload_dll_test.cc
parente9e77e410bfb75a82ef7cdeb4027afea1c90daea (diff)
downloadchromium_src-126720dd09a08ae7391568fe19f403a050be0627.zip
chromium_src-126720dd09a08ae7391568fe19f403a050be0627.tar.gz
chromium_src-126720dd09a08ae7391568fe19f403a050be0627.tar.bz2
back out my sbox change
TBR=nsylvain Review URL: http://codereview.chromium.org/3132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2353 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox/src/unload_dll_test.cc')
-rw-r--r--sandbox/src/unload_dll_test.cc90
1 files changed, 0 insertions, 90 deletions
diff --git a/sandbox/src/unload_dll_test.cc b/sandbox/src/unload_dll_test.cc
deleted file mode 100644
index 19097fd..0000000
--- a/sandbox/src/unload_dll_test.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright (c) 2008 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 "base/scoped_handle.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "sandbox/src/sandbox.h"
-#include "sandbox/src/sandbox_factory.h"
-#include "sandbox/src/target_services.h"
-#include "sandbox/tests/common/controller.h"
-
-namespace sandbox {
-
-// Loads and or unloads a DLL passed in the second parameter of argv.
-// The first parameter of argv is 'L' = load, 'U' = unload or 'B' for both.
-SBOX_TESTS_COMMAND int UseOneDLL(int argc, wchar_t **argv) {
- if (argc != 2)
- return SBOX_TEST_FAILED_TO_RUN_TEST;
- int rv = SBOX_TEST_FAILED_TO_RUN_TEST;
-
- wchar_t option = (argv[0])[0];
- if ((option == L'L') || (option == L'B')) {
- HMODULE module1 = ::LoadLibraryW(argv[1]);
- rv = (module1 == NULL) ? SBOX_TEST_FAILED : SBOX_TEST_SUCCEEDED;
- }
-
- if ((option == L'U') || (option == L'B')) {
- HMODULE module2 = ::GetModuleHandleW(argv[1]);
- rv = FreeLibrary(module2) ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED;
- }
- return rv;
-}
-
-// Opens an event passed as the first parameter of argv.
-SBOX_TESTS_COMMAND int SimpleOpenEvent(int argc, wchar_t **argv) {
- if (argc != 1)
- return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
-
- ScopedHandle event_open(::OpenEvent(SYNCHRONIZE, FALSE, argv[0]));
- return event_open.Get() ? SBOX_TEST_SUCCEEDED : SBOX_TEST_FAILED;
-}
-
-TEST(UnloadDllTest, BaselineAvicapDll) {
- TestRunner runner;
- runner.SetTestState(BEFORE_REVERT);
- runner.SetTimeout(2000);
- // Add a sync rule, because that ensures that the interception agent has
- // more than one item in its internal table.
- EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC,
- TargetPolicy::EVENTS_ALLOW_ANY, L"t0001"));
- EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"UseOneDLL L avicap32.dll"));
- EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"UseOneDLL B avicap32.dll"));
-}
-
-TEST(UnloadDllTest, UnloadAviCapDllNoPatching) {
- TestRunner runner;
- runner.SetTestState(BEFORE_REVERT);
- runner.SetTimeout(2000);
- sandbox::TargetPolicy* policy = runner.GetPolicy();
- policy->AddDllToUnload(L"avicap32.dll");
- EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"UseOneDLL L avicap32.dll"));
- EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"UseOneDLL B avicap32.dll"));
-}
-
-TEST(UnloadDllTest, UnloadAviCapDllWithPatching) {
- TestRunner runner;
- runner.SetTimeout(2000);
- runner.SetTestState(BEFORE_REVERT);
- sandbox::TargetPolicy* policy = runner.GetPolicy();
- policy->AddDllToUnload(L"avicap32.dll");
-
- ScopedHandle handle1(::CreateEvent(NULL, FALSE, FALSE, L"tst0001"));
-
- // Add a couple of rules that ensures that the interception agent add EAT
- // patching on the client which makes sure that the unload dll record does
- // not interact badly with them.
- EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_REGISTRY,
- TargetPolicy::REG_ALLOW_ANY,
- L"HKEY_LOCAL_MACHINE\\Software\\Microsoft"));
- EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_SYNC,
- TargetPolicy::EVENTS_ALLOW_ANY, L"tst0001"));
-
- EXPECT_EQ(SBOX_TEST_FAILED, runner.RunTest(L"UseOneDLL L avicap32.dll"));
-
- runner.SetTestState(AFTER_REVERT);
- EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"SimpleOpenEvent tst0001"));
-}
-
-} // namespace sandbox
-