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

Unified Diff: base/win/scoped_handle_unittest.cc

Issue 1779333003: Add test for multithreaded ActiveVerifier behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@handlecreate
Patch Set: change to loadable_module Created 4 years, 9 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 | « base/win/scoped_handle_test_dll.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_handle_unittest.cc
diff --git a/base/win/scoped_handle_unittest.cc b/base/win/scoped_handle_unittest.cc
index 598e3f4150dd69e6479a772b688dea9cc7655545..2d90f9fcf34f693552ffcc62ba31111520d3a393 100644
--- a/base/win/scoped_handle_unittest.cc
+++ b/base/win/scoped_handle_unittest.cc
@@ -5,15 +5,24 @@
#include <windows.h>
#include <winternl.h>
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/scoped_native_library.h"
+#include "base/test/multiprocess_test.h"
+#include "base/test/test_timeouts.h"
#include "base/win/scoped_handle.h"
-#include <utility>
-
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/multiprocess_func_list.h"
namespace base {
namespace win {
+namespace testing {
+extern "C" bool __declspec(dllexport) RunTest();
+} // namespace testing
+
TEST(ScopedHandleTest, ScopedHandle) {
// Any illegal error code will do. We just need to test that it is preserved
// by ScopedHandle to avoid bug 528394.
@@ -90,5 +99,36 @@ TEST(ScopedHandleTest, ActiveVerifierUntrackedHandle) {
ASSERT_TRUE(::CloseHandle(handle));
}
+TEST(ScopedHandleTest, MultiProcess) {
+ // Initializing ICU in the child process causes a scoped handle to be created
+ // before the test gets a chance to test the race condition, so disable ICU
+ // for the child process here.
+ CommandLine command_line(base::GetMultiProcessTestChildBaseCommandLine());
+ command_line.AppendSwitch(switches::kTestDoNotInitializeIcu);
+
+ base::Process test_child_process = base::SpawnMultiProcessTestChild(
+ "ActiveVerifierChildProcess", command_line, LaunchOptions());
+
+ int rv = -1;
+ ASSERT_TRUE(test_child_process.WaitForExitWithTimeout(
+ TestTimeouts::action_timeout(), &rv));
+ EXPECT_EQ(0, rv);
+}
+
+MULTIPROCESS_TEST_MAIN(ActiveVerifierChildProcess) {
+ ScopedNativeLibrary module(FilePath(L"scoped_handle_test_dll.dll"));
+
+ if (!module.is_valid())
+ return 1;
+ auto run_test_function = reinterpret_cast<decltype(&testing::RunTest)>(
+ module.GetFunctionPointer("RunTest"));
+ if (!run_test_function)
+ return 1;
+ if (!run_test_function())
+ return 1;
+
+ return 0;
+}
+
} // namespace win
} // namespace base
« no previous file with comments | « base/win/scoped_handle_test_dll.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698