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

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

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_changepin
===================================================================
--- chrome/test/functional/chromoting/mock_pref_pane_changepin (revision 0)
+++ chrome/test/functional/chromoting/mock_pref_pane_changepin (revision 0)
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+suid-python <<END
+
+import Foundation
+import os
+import subprocess
+import tempfile
+import time
+import signal
+
+SERVICE_NAME = "org.chromium.chromoting"
+
+def get_job_pid():
+ process = subprocess.Popen(["launchctl", "list"], stdout=subprocess.PIPE)
+ pid = None
+ 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] != "-":
+ pid = fields[0]
+ break
+ process.wait()
+ return pid
+
+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, "--save-config"], stdin=open(config_file))
+
+# Drop privileges, in order to start the launchd job as the logged-in user.
+os.setuid(real_user_id)
+os.kill(int(get_job_pid()), signal.SIGHUP)
+
+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