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

Unified Diff: client/crashpad_client_win_test.cc

Issue 1464473003: win: Don't duplicate handles in handle restriction list (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: merge && Created 5 years, 1 month 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 | « client/crashpad_client_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/crashpad_client_win_test.cc
diff --git a/client/crashpad_client_win_test.cc b/client/crashpad_client_win_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2215e2a8ff20ce8fea11715aa15c3a512917f1f1
--- /dev/null
+++ b/client/crashpad_client_win_test.cc
@@ -0,0 +1,91 @@
+// Copyright 2015 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "client/crashpad_client.h"
+
+#include "base/files/file_path.h"
+#include "gtest/gtest.h"
+#include "test/paths.h"
+#include "test/scoped_temp_dir.h"
+#include "test/win/win_multiprocess.h"
+
+namespace crashpad {
+namespace test {
+namespace {
+
+void StartAndUseHandler() {
+ ScopedTempDir temp_dir;
+ base::FilePath handler_path = Paths::Executable().DirName().Append(
+ FILE_PATH_LITERAL("crashpad_handler.exe"));
+ CrashpadClient client;
+ ASSERT_TRUE(client.StartHandler(handler_path,
+ temp_dir.path(),
+ "",
+ std::map<std::string, std::string>(),
+ std::vector<std::string>(),
+ false));
+ EXPECT_TRUE(client.UseHandler());
+}
+
+class StartWithInvalidHandles final : public WinMultiprocess {
+ public:
+ StartWithInvalidHandles() : WinMultiprocess() {}
+ ~StartWithInvalidHandles() {}
+
+ private:
+ void WinMultiprocessParent() override {}
+
+ void WinMultiprocessChild() override {
+ HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
+ SetStdHandle(STD_OUTPUT_HANDLE, INVALID_HANDLE_VALUE);
+ SetStdHandle(STD_ERROR_HANDLE, INVALID_HANDLE_VALUE);
+
+ StartAndUseHandler();
+
+ SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
+ SetStdHandle(STD_ERROR_HANDLE, original_stderr);
+ }
+};
+
+TEST(CrashpadClient, StartWithInvalidHandles) {
+ WinMultiprocess::Run<StartWithInvalidHandles>();
+}
+
+class StartWithSameStdoutStderr final : public WinMultiprocess {
+ public:
+ StartWithSameStdoutStderr() : WinMultiprocess() {}
+ ~StartWithSameStdoutStderr() {}
+
+ private:
+ void WinMultiprocessParent() override {}
+
+ void WinMultiprocessChild() override {
+ HANDLE original_stdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ HANDLE original_stderr = GetStdHandle(STD_ERROR_HANDLE);
+ SetStdHandle(STD_OUTPUT_HANDLE, original_stderr);
+
+ StartAndUseHandler();
+
+ SetStdHandle(STD_OUTPUT_HANDLE, original_stdout);
+ }
+};
+
+TEST(CrashpadClient, StartWithSameStdoutStderr) {
+ WinMultiprocess::Run<StartWithSameStdoutStderr>();
+}
+
+} // namespace
+} // namespace test
+} // namespace crashpad
« no previous file with comments | « client/crashpad_client_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698