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

Side by Side Diff: chrome/common/service_process_util_unittest.cc

Issue 7736002: Make the mac service process handling code clean itself up properly as far as launchd is concerned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add launchd test Created 9 years, 4 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 | « chrome/common/service_process_util_posix.cc ('k') | chrome/common/service_process_util_win.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/service_process_util.h" 5 #include "chrome/common/service_process_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h"
9 #include "base/file_path.h"
10 #include "base/process_util.h"
8 11
9 #if !defined(OS_MACOSX) 12 #if !defined(OS_MACOSX)
10 #include "base/at_exit.h" 13 #include "base/at_exit.h"
11 #include "base/command_line.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/process_util.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "base/test/multiprocess_test.h" 16 #include "base/test/multiprocess_test.h"
16 #include "base/test/test_timeouts.h" 17 #include "base/test/test_timeouts.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/chrome_version_info.h" 21 #include "chrome/common/chrome_version_info.h"
21 #include "testing/multiprocess_func_list.h" 22 #include "testing/multiprocess_func_list.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/win/win_util.h" 25 #include "base/win/win_util.h"
25 #endif 26 #endif
26 27
27 #if defined(OS_POSIX) && !defined(OS_MACOSX) 28 #if defined(OS_POSIX)
28 #include "chrome/common/auto_start_linux.h" 29 #include "chrome/common/auto_start_linux.h"
29 #include <glib.h> 30 #include <glib.h>
30 #endif 31 #endif
31 32
32 #if defined(TOUCH_UI) 33 #if defined(TOUCH_UI)
33 // This test fails http://crbug.com/84854, and is very flaky on CrOS and 34 // This test fails http://crbug.com/84854, and is very flaky on CrOS and
34 // somewhat flaky on other Linux. 35 // somewhat flaky on other Linux.
35 #define MAYBE_ForceShutdown FAILS_ForceShutdown 36 #define MAYBE_ForceShutdown FAILS_ForceShutdown
36 #else 37 #else
37 #if defined(OS_LINUX) 38 #if defined(OS_LINUX)
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 void TrashFunc(const FilePath& src) { 491 void TrashFunc(const FilePath& src) {
491 FSRef path_ref; 492 FSRef path_ref;
492 FSRef new_path_ref; 493 FSRef new_path_ref;
493 EXPECT_TRUE(base::mac::FSRefFromPath(src.value(), &path_ref)); 494 EXPECT_TRUE(base::mac::FSRefFromPath(src.value(), &path_ref));
494 OSStatus status = FSMoveObjectToTrashSync(&path_ref, 495 OSStatus status = FSMoveObjectToTrashSync(&path_ref,
495 &new_path_ref, 496 &new_path_ref,
496 kFSFileOperationDefaultOptions); 497 kFSFileOperationDefaultOptions);
497 EXPECT_EQ(status, noErr) << "FSMoveObjectToTrashSync " << status; 498 EXPECT_EQ(status, noErr) << "FSMoveObjectToTrashSync " << status;
498 } 499 }
499 500
501 TEST_F(ServiceProcessStateFileManipulationTest, VerifyLaunchD) {
502 // There have been problems where launchd has gotten into a bad state, usually
503 // because something had deleted all the files in /tmp. launchd depends on
504 // a Unix Domain Socket that it creates at /tmp/launchd*/sock.
505 // The symptom of this problem is that the service process connect fails
506 // on Mac and "launch_msg(): Socket is not connected" appears.
507 // This test is designed to make sure that launchd is working.
508 // http://crbug/75518
509
510 CommandLine cl(FilePath("/bin/launchctl"));
511 cl.AppendArg("list");
512 cl.AppendArg("com.apple.launchctl.Aqua");
513
514 std::string output;
515 int exit_code = -1;
516 ASSERT_TRUE(base::GetAppOutputWithExitCode(cl, &output, &exit_code)
517 && exit_code == 0)
518 << " exit_code:" << exit_code << " " << output;
519 }
520
500 TEST_F(ServiceProcessStateFileManipulationTest, DeleteFile) { 521 TEST_F(ServiceProcessStateFileManipulationTest, DeleteFile) {
501 GetIOMessageLoopProxy()->PostTask( 522 GetIOMessageLoopProxy()->PostTask(
502 FROM_HERE, 523 FROM_HERE,
503 NewRunnableFunction(&DeleteFunc, executable_path())); 524 NewRunnableFunction(&DeleteFunc, executable_path()));
504 Run(); 525 Run();
505 ASSERT_TRUE(mock_launchd()->remove_called()); 526 ASSERT_TRUE(mock_launchd()->remove_called());
506 ASSERT_TRUE(mock_launchd()->delete_called()); 527 ASSERT_TRUE(mock_launchd()->delete_called());
507 } 528 }
508 529
509 TEST_F(ServiceProcessStateFileManipulationTest, DeleteBundle) { 530 TEST_F(ServiceProcessStateFileManipulationTest, DeleteBundle) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 ScopedAttributesRestorer restorer(bundle_path(), 0777); 574 ScopedAttributesRestorer restorer(bundle_path(), 0777);
554 GetIOMessageLoopProxy()->PostTask( 575 GetIOMessageLoopProxy()->PostTask(
555 FROM_HERE, 576 FROM_HERE,
556 NewRunnableFunction(&ChangeAttr, bundle_path(), 0222)); 577 NewRunnableFunction(&ChangeAttr, bundle_path(), 0222));
557 Run(); 578 Run();
558 ASSERT_TRUE(mock_launchd()->remove_called()); 579 ASSERT_TRUE(mock_launchd()->remove_called());
559 ASSERT_TRUE(mock_launchd()->delete_called()); 580 ASSERT_TRUE(mock_launchd()->delete_called());
560 } 581 }
561 582
562 #endif // !OS_MACOSX 583 #endif // !OS_MACOSX
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_posix.cc ('k') | chrome/common/service_process_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698