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

Side by Side Diff: chrome/browser/chromeos/process_proxy/process_output_watcher_unittest.cc

Issue 10033015: Fix ProcessOutputWatcherTest.OutputWatcher under ASAN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove extra line Created 8 years, 8 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 | Annotate | Revision Log
« 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // TODO(tbarzic): We don't support stderr anymore, so this can be simplified. 118 // TODO(tbarzic): We don't support stderr anymore, so this can be simplified.
119 std::vector<TestCase> test_cases; 119 std::vector<TestCase> test_cases;
120 test_cases.push_back(TestCase("testing output\n", PROCESS_OUTPUT_TYPE_OUT)); 120 test_cases.push_back(TestCase("testing output\n", PROCESS_OUTPUT_TYPE_OUT));
121 test_cases.push_back(TestCase("testing error\n", PROCESS_OUTPUT_TYPE_OUT)); 121 test_cases.push_back(TestCase("testing error\n", PROCESS_OUTPUT_TYPE_OUT));
122 test_cases.push_back(TestCase("testing error1\n", PROCESS_OUTPUT_TYPE_OUT)); 122 test_cases.push_back(TestCase("testing error1\n", PROCESS_OUTPUT_TYPE_OUT));
123 test_cases.push_back(TestCase("testing output1\n", PROCESS_OUTPUT_TYPE_OUT)); 123 test_cases.push_back(TestCase("testing output1\n", PROCESS_OUTPUT_TYPE_OUT));
124 test_cases.push_back(TestCase("testing output2\n", PROCESS_OUTPUT_TYPE_OUT)); 124 test_cases.push_back(TestCase("testing output2\n", PROCESS_OUTPUT_TYPE_OUT));
125 test_cases.push_back(TestCase("testing output3\n", PROCESS_OUTPUT_TYPE_OUT)); 125 test_cases.push_back(TestCase("testing output3\n", PROCESS_OUTPUT_TYPE_OUT));
126 test_cases.push_back(TestCase(VeryLongString(), PROCESS_OUTPUT_TYPE_OUT)); 126 test_cases.push_back(TestCase(VeryLongString(), PROCESS_OUTPUT_TYPE_OUT));
127 test_cases.push_back(TestCase("testing error2\n", PROCESS_OUTPUT_TYPE_OUT)); 127 test_cases.push_back(TestCase("testing error2\n", PROCESS_OUTPUT_TYPE_OUT));
128 test_cases.push_back(TestCase("line with \0 in it\n", 128
129 arraysize("line with \0 in it \n"), 129 char line_with_null_char[] = "line with \0 in it\n";
130 test_cases.push_back(TestCase(line_with_null_char,
131 arraysize(line_with_null_char) - 1,
oshima 2012/04/10 00:58:12 Maybe I'm dumb, but sorry I didn't understand why
tonibarzic 2012/04/10 01:16:59 I don't necessary need -1, but it's more in line w
130 PROCESS_OUTPUT_TYPE_OUT)); 132 PROCESS_OUTPUT_TYPE_OUT));
131 133
132 output_watch_thread.message_loop()->PostTask(FROM_HERE, 134 output_watch_thread.message_loop()->PostTask(FROM_HERE,
133 base::Bind(&ProcessOutputWatcherTest::StartWatch, base::Unretained(this), 135 base::Bind(&ProcessOutputWatcherTest::StartWatch, base::Unretained(this),
134 pt_pipe[0], stop_pipe[0], test_cases)); 136 pt_pipe[0], stop_pipe[0], test_cases));
135 137
136 for (size_t i = 0; i < test_cases.size(); i++) { 138 for (size_t i = 0; i < test_cases.size(); i++) {
137 // Let's make inputs not NULL terminated. 139 // Let's make inputs not NULL terminated.
138 const std::string& test_str = test_cases[i].str; 140 const std::string& test_str = test_cases[i].str;
139 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str()); 141 ssize_t test_size = test_str.length() * sizeof(*test_str.c_str());
140 EXPECT_EQ(test_size, 142 EXPECT_EQ(test_size,
141 file_util::WriteFileDescriptor(pt_pipe[1], test_str.c_str(), 143 file_util::WriteFileDescriptor(pt_pipe[1], test_str.c_str(),
142 test_size)); 144 test_size));
143 } 145 }
144 146
145 all_data_received_->Wait(); 147 all_data_received_->Wait();
146 148
147 // Send stop signal. It is not important which string we send. 149 // Send stop signal. It is not important which string we send.
148 EXPECT_EQ(1, file_util::WriteFileDescriptor(stop_pipe[1], "q", 1)); 150 EXPECT_EQ(1, file_util::WriteFileDescriptor(stop_pipe[1], "q", 1));
149 151
150 EXPECT_NE(-1, HANDLE_EINTR(close(stop_pipe[1]))); 152 EXPECT_NE(-1, HANDLE_EINTR(close(stop_pipe[1])));
151 EXPECT_NE(-1, HANDLE_EINTR(close(pt_pipe[1]))); 153 EXPECT_NE(-1, HANDLE_EINTR(close(pt_pipe[1])));
152 154
153 output_watch_thread.Stop(); 155 output_watch_thread.Stop();
154 }; 156 };
155 157
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