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

Side by Side Diff: chrome/browser/image_decoder_browsertest.cc

Issue 1137993002: Fix ImageDecoderBrowserTest.StartAndKillProcess flakyness and re-enable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@image-decoder-test
Patch Set: Fix comment... again. Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/image_decoder.h" 5 #include "chrome/browser/image_decoder.h"
6 6
7 #include "chrome/grit/generated_resources.h" 7 #include "chrome/grit/generated_resources.h"
8 #include "chrome/test/base/in_process_browser_test.h" 8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "content/public/browser/browser_child_process_observer.h" 9 #include "content/public/browser/browser_child_process_observer.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::ProcessHandle out_handle; 101 base::ProcessHandle out_handle;
102 if (!::DuplicateHandle(GetCurrentProcess(), handle, 102 if (!::DuplicateHandle(GetCurrentProcess(), handle,
103 GetCurrentProcess(), &out_handle, 103 GetCurrentProcess(), &out_handle,
104 0, FALSE, DUPLICATE_SAME_ACCESS)) { 104 0, FALSE, DUPLICATE_SAME_ACCESS)) {
105 return; 105 return;
106 } 106 }
107 handle = out_handle; 107 handle = out_handle;
108 #endif 108 #endif
109 109
110 // Use a non-zero exit code so it counts as a crash. 110 // Use a non-zero exit code so it counts as a crash.
111 EXPECT_TRUE(base::Process(handle).Terminate(1, true)); 111 // Don't wait for the process after sending the termination signal
112 // (SIGTERM). According to POSIX, doing so causes the resulting zombie to be
113 // removed from the process table. However, Chromium treats an error on
114 // |waitpid| (in this case, ECHILD) as a "normal" termination and doesn't
115 // invoke the process host delegate's |OnProcessCrashed|.
Lei Zhang 2015/05/12 02:23:24 nit: OnProcessCrashes()
Anand Mistry (off Chromium) 2015/05/12 03:12:20 Done. And I double-checked, it is OnProcessCrashed
116 EXPECT_TRUE(base::Process(handle).Terminate(1, false));
112 did_kill_ = true; 117 did_kill_ = true;
113 } 118 }
114 119
115 bool did_kill_; 120 bool did_kill_;
116 const base::string16 utility_process_name_; 121 const base::string16 utility_process_name_;
117 122
118 DISALLOW_COPY_AND_ASSIGN(KillProcessObserver); 123 DISALLOW_COPY_AND_ASSIGN(KillProcessObserver);
119 }; 124 };
120 125
121 } // namespace 126 } // namespace
(...skipping 28 matching lines...) Expand all
150 test_request.reset(); 155 test_request.reset();
151 runner->Run(); 156 runner->Run();
152 } 157 }
153 158
154 // Killing the utility process counts as a crash. Thus the request fails. 159 // Killing the utility process counts as a crash. Thus the request fails.
155 // If ImageDecoder did not handle the crash properly, the request never finishes 160 // If ImageDecoder did not handle the crash properly, the request never finishes
156 // and this test would hang. 161 // and this test would hang.
157 // Note: This test is inherently racy because KillProcessObserver lives on the 162 // Note: This test is inherently racy because KillProcessObserver lives on the
158 // UI thread but ImageDecoder does its work mainly on the IO thread. So the test 163 // UI thread but ImageDecoder does its work mainly on the IO thread. So the test
159 // checks for both possible valid outcomes. 164 // checks for both possible valid outcomes.
160 // BUG(486194): Disabled due to flakyness. 165 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, StartAndKillProcess) {
161 IN_PROC_BROWSER_TEST_F(ImageDecoderBrowserTest, DISABLED_StartAndKillProcess) {
162 KillProcessObserver observer; 166 KillProcessObserver observer;
163 scoped_refptr<content::MessageLoopRunner> runner = 167 scoped_refptr<content::MessageLoopRunner> runner =
164 new content::MessageLoopRunner; 168 new content::MessageLoopRunner;
165 TestImageRequest test_request(runner->QuitClosure()); 169 TestImageRequest test_request(runner->QuitClosure());
166 ImageDecoder::Start(&test_request, GetValidPngString()); 170 ImageDecoder::Start(&test_request, GetValidPngString());
167 runner->Run(); 171 runner->Run();
168 if (!test_request.decode_succeeded()) { 172 if (!test_request.decode_succeeded()) {
169 // The UI thread won the race. Make sure the utility process did get killed. 173 // The UI thread won the race. Make sure the utility process did get killed.
170 EXPECT_TRUE(observer.did_kill()); 174 EXPECT_TRUE(observer.did_kill());
171 } 175 }
172 // Else the IO thread won the race and the image got decoded. Oh well. 176 // Else the IO thread won the race and the image got decoded. Oh well.
173 } 177 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698