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

Unified Diff: chrome/test/functional/chromoting/mock_pref_pane_enable

Issue 10821015: Initial checkin of the me2me pyauto automation: (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 5 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: chrome/test/functional/chromoting/mock_pref_pane_enable
===================================================================
--- chrome/test/functional/chromoting/mock_pref_pane_enable (revision 0)
+++ chrome/test/functional/chromoting/mock_pref_pane_enable (revision 0)
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+suid-python <<END
+
+import Foundation
+import os
+import subprocess
+import tempfile
+import time
+
+SERVICE_NAME = "org.chromium.chromoting"
garykac 2012/07/31 00:25:11 This is pretty much exactly the same as mock_pref_
yihongg1 2012/08/03 00:40:06 Done.
+
+def is_job_running():
+ process = subprocess.Popen(["launchctl", "list"], stdout=subprocess.PIPE)
+ is_running = False
+ for line in process.stdout:
+ # Format is:
+ # 12345 - my.job (if my.job is running, number is job's PID)
+ # - 0 my.other.job (if my.other.job is not running)
+ print "*** %s ***" % line
+ fields = line.strip().split('\t')
+ print "*** field 2=%s, field 0=%s ***" % (fields[2], fields[0])
+ if fields[2] == SERVICE_NAME and fields[0] != "-":
+ is_running = True
+ break
+ process.wait()
+ return is_running
+
+print "*** Started mock pref pane ***"
+print "*** EUID=%d, UID=%d ***" % (os.geteuid(), os.getuid())
+
+config_file = os.path.join(tempfile.gettempdir(),
+ "%s.json" % SERVICE_NAME)
+
+print "*** config_file=%s" % config_file
+
+tool_script = "/Library/PrivilegedHelperTools/%s.me2me.sh" % SERVICE_NAME
+
+real_user_id = os.getuid()
+
+# Elevate privileges, otherwise tool_script executes with EUID != 0.
+os.setuid(0)
+subprocess.call([tool_script, "--enable"], stdin=open(config_file))
+
+# Drop privileges, in order to start the launchd job as the logged-in user.
+os.setuid(real_user_id)
+subprocess.call(["launchctl", "start", SERVICE_NAME])
+
+# Starting a launchd job is an asynchronous operation that typically takes
+# a couple of seconds, so poll until the job has started.
+is_running = False
+for i in range(1, 10):
+ if is_job_running():
+ is_running = True
+ break
+ time.sleep(2)
+
+print "*** is_runnning = %d" % is_running
+
+notification_center = Foundation.NSDistributedNotificationCenter.defaultCenter()
+notification_center.postNotificationName_object_userInfo_(
+ SERVICE_NAME + ".update_succeeded", None, None)
+
+time.sleep(10)
+
+END

Powered by Google App Engine
This is Rietveld 408576698