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

Side by Side Diff: base/process_util_unittest.cc

Issue 27038: Fix more GCC 4.3 warnings. (Closed)
Patch Set: Created 11 years, 10 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #define _CRT_SECURE_NO_WARNINGS 5 #define _CRT_SECURE_NO_WARNINGS
6 6
7 #include "base/multiprocess_test.h" 7 #include "base/multiprocess_test.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 174 }
175 175
176 // InitLogging always opens a file at startup. 176 // InitLogging always opens a file at startup.
177 int expected_num_open_fds = 1; 177 int expected_num_open_fds = 1;
178 #if defined(OS_LINUX) 178 #if defined(OS_LINUX)
179 // On Linux, '/etc/localtime' is opened before the test's main() enters. 179 // On Linux, '/etc/localtime' is opened before the test's main() enters.
180 expected_num_open_fds += 1; 180 expected_num_open_fds += 1;
181 #endif // defined(OS_LINUX) 181 #endif // defined(OS_LINUX)
182 num_open_files -= expected_num_open_fds; 182 num_open_files -= expected_num_open_fds;
183 183
184 write(write_pipe, &num_open_files, sizeof(num_open_files)); 184 int written = write(write_pipe, &num_open_files, sizeof(num_open_files));
agl 2009/02/22 01:25:35 ssize_t, not int
185 DCHECK(written == sizeof(num_open_files));
agl 2009/02/22 01:25:35 DCHECK_EQ
185 close(write_pipe); 186 close(write_pipe);
186 187
187 return 0; 188 return 0;
188 } 189 }
189 190
190 TEST_F(ProcessUtilTest, FDRemapping) { 191 TEST_F(ProcessUtilTest, FDRemapping) {
191 // Open some files to check they don't get leaked to the child process. 192 // Open some files to check they don't get leaked to the child process.
192 int fds[2]; 193 int fds[2];
193 pipe(fds); 194 if (pipe(fds) < 0)
195 NOTREACHED();
194 int pipe_read_fd = fds[0]; 196 int pipe_read_fd = fds[0];
195 int pipe_write_fd = fds[1]; 197 int pipe_write_fd = fds[1];
196 198
197 // open some dummy fds to make sure they don't propogate over to the 199 // open some dummy fds to make sure they don't propogate over to the
198 // child process. 200 // child process.
199 int dev_null = open("/dev/null", O_RDONLY); 201 int dev_null = open("/dev/null", O_RDONLY);
200 int sockets[2]; 202 int sockets[2];
201 socketpair(AF_UNIX, SOCK_STREAM, 0, sockets); 203 socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
202 204
203 file_handle_mapping_vector fd_mapping_vec; 205 file_handle_mapping_vector fd_mapping_vec;
(...skipping 17 matching lines...) Expand all
221 base::CloseProcessHandle(handle); 223 base::CloseProcessHandle(handle);
222 close(fds[0]); 224 close(fds[0]);
223 close(sockets[0]); 225 close(sockets[0]);
224 close(sockets[1]); 226 close(sockets[1]);
225 close(dev_null); 227 close(dev_null);
226 } 228 }
227 229
228 #endif // defined(OS_POSIX) 230 #endif // defined(OS_POSIX)
229 231
230 } // namespace base 232 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698