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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/bin/bash
2
3 suid-python <<END
4
5 import Foundation
6 import os
7 import subprocess
8 import tempfile
9 import time
10
11 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.
12
13 def is_job_running():
14 process = subprocess.Popen(["launchctl", "list"], stdout=subprocess.PIPE)
15 is_running = False
16 for line in process.stdout:
17 # Format is:
18 # 12345 - my.job (if my.job is running, number is job's PID)
19 # - 0 my.other.job (if my.other.job is not running)
20 print "*** %s ***" % line
21 fields = line.strip().split('\t')
22 print "*** field 2=%s, field 0=%s ***" % (fields[2], fields[0])
23 if fields[2] == SERVICE_NAME and fields[0] != "-":
24 is_running = True
25 break
26 process.wait()
27 return is_running
28
29 print "*** Started mock pref pane ***"
30 print "*** EUID=%d, UID=%d ***" % (os.geteuid(), os.getuid())
31
32 config_file = os.path.join(tempfile.gettempdir(),
33 "%s.json" % SERVICE_NAME)
34
35 print "*** config_file=%s" % config_file
36
37 tool_script = "/Library/PrivilegedHelperTools/%s.me2me.sh" % SERVICE_NAME
38
39 real_user_id = os.getuid()
40
41 # Elevate privileges, otherwise tool_script executes with EUID != 0.
42 os.setuid(0)
43 subprocess.call([tool_script, "--enable"], stdin=open(config_file))
44
45 # Drop privileges, in order to start the launchd job as the logged-in user.
46 os.setuid(real_user_id)
47 subprocess.call(["launchctl", "start", SERVICE_NAME])
48
49 # Starting a launchd job is an asynchronous operation that typically takes
50 # a couple of seconds, so poll until the job has started.
51 is_running = False
52 for i in range(1, 10):
53 if is_job_running():
54 is_running = True
55 break
56 time.sleep(2)
57
58 print "*** is_runnning = %d" % is_running
59
60 notification_center = Foundation.NSDistributedNotificationCenter.defaultCenter()
61 notification_center.postNotificationName_object_userInfo_(
62 SERVICE_NAME + ".update_succeeded", None, None)
63
64 time.sleep(10)
65
66 END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698