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

Unified Diff: infra/libs/service_utils/test/_daemon_nix_test.py

Issue 1365583002: Have service_manager start a cloudtail attached to each service it starts. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Just use the default project ID Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: infra/libs/service_utils/test/_daemon_nix_test.py
diff --git a/infra/libs/service_utils/test/_daemon_nix_test.py b/infra/libs/service_utils/test/_daemon_nix_test.py
index 40a0db4b96060b59bb6ead8d07e59e40ea625f85..1a4254ed21031073d7d1645544435da52197ba06 100644
--- a/infra/libs/service_utils/test/_daemon_nix_test.py
+++ b/infra/libs/service_utils/test/_daemon_nix_test.py
@@ -179,6 +179,13 @@ class TestBecomeDaemon(unittest.TestCase):
self.assertEqual([((i,),) for i in reversed(range(2048)) if i != 42],
mock_close.call_args_list)
+ def testClosesFdsKeepingAll(self, _mock_exit, _mock_chdir, _mock_dup2,
+ _mock_open, mock_close, _mock_setsid,
+ _mock_fork):
+ daemon.become_daemon(keep_fds=True)
+
+ self.assertEqual(0, mock_close.call_count)
+
def testClosesInvalidFds(self, _mock_exit, _mock_chdir, _mock_dup2,
_mock_open, mock_close, _mock_setsid, _mock_fork):
mock_close.side_effect = EnvironmentError(errno.EIO, '')
@@ -201,6 +208,19 @@ class TestBecomeDaemon(unittest.TestCase):
((handle, 2),),
], mock_dup2.call_args_list)
+ def testOpensDevNullWithExceptions(self, _mock_exit, _mock_chdir, mock_dup2,
+ mock_open, _mock_close, _mock_setsid,
+ _mock_fork):
+ handle = object()
+ mock_open.return_value = handle
+
+ daemon.become_daemon(keep_fds={1})
+
+ self.assertEqual([
+ ((handle, 0),),
+ ((handle, 2),),
+ ], mock_dup2.call_args_list)
+
def testChangesToRoot(self, _mock_exit, mock_chdir, _mock_dup2, _mock_open,
_mock_close, _mock_setsid, _mock_fork):
daemon.become_daemon()

Powered by Google App Engine
This is Rietveld 408576698