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

Side by Side Diff: client/site_tests/realtimecomm_GTalkPlayground/realtimecomm_GTalkPlayground.py

Issue 1338004: Add audioonly playground test. Move common things to dep. (Closed)
Patch Set: More improvement from codereview. Created 10 years, 9 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
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS 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 import os, re, shutil, sys, time 5 import os, re, shutil, sys, time
6 6
7 from autotest_lib.client.bin import test, utils 7 from autotest_lib.client.bin import test, utils
8 from autotest_lib.client.common_lib import error, site_ui 8 from autotest_lib.client.common_lib import error, site_ui
9 9
10 WARMUP_TIME = 60 10 WARMUP_TIME = 60
11 SLEEP_DURATION = 260 11 SLEEP_DURATION = 260
12 12
13 class realtimecomm_GTalkPlayground(test.test): 13 class realtimecomm_GTalkPlayground(test.test):
14 version = 1 14 version = 1
15 playground = '/home/chronos/playground' 15 playground = '/home/chronos/playground'
16 dep = 'realtimecomm_playground' 16 dep = 'realtimecomm_playground'
17 17
18 def setup(self): 18 def setup(self):
19 self.job.setup_dep(['realtimecomm_playground']) 19 self.job.setup_dep([self.dep])
20
21 def run_cleanup(self, testdone=False):
22 utils.run('pkill chrome', ignore_status=True)
23 time.sleep(10)
24 utils.run('pkill GoogleTalkPlugin', ignore_status=True)
25 time.sleep(10)
26 utils.run('rm -f /tmp/tmp.log', ignore_status=True)
27 if testdone:
28 utils.run('rm -rf %s' % self.playground)
29 # Delete previous browser state if any
30 shutil.rmtree('/home/chronos/.config/chromium', ignore_errors=True)
31 shutil.rmtree('/home/chronos/.config/google-chrome', ignore_errors=True)
32
33
34 def run_setup(self):
35 if os.path.exists(self.playground):
36 shutil.rmtree(self.playground)
37 shutil.copytree(os.path.join(self.dep_dir, 'src'), self.playground)
38 utils.run('chown chronos %s -R' % self.playground)
39 src_opt = os.path.join(self.bindir, 'options')
40 des_path= '/home/chronos/.Google/'
41 opt_path= os.path.join(des_path, 'Google Talk Plugin')
42 des_opt = os.path.join(opt_path, 'options')
43 utils.run('mkdir -p \'%s\'' % opt_path)
44 utils.run('cp -f %s \'%s\'' % (src_opt, des_opt))
45 utils.run('chown chronos \'%s\' -R' % des_path)
46 utils.run('chmod o+r+w \'%s\'' % des_opt)
47 20
48 21
49 def run_verification(self): 22 def run_verification(self):
50 # TODO(zhurun): Add more checking and perf data collection. 23 # TODO(zhurun): Add more checking and perf data collection.
51 if not os.path.exists('/tmp/tmp.log'): 24 if not os.path.exists('/tmp/tmp.log'):
52 raise error.TestFail('GTalk log file not exist!') 25 raise error.TestFail('GTalk log file not exist!')
53 try: 26 content = utils.read_file('/tmp/tmp.log')
54 log = open(r'/tmp/tmp.log') 27 if not "Found V4L2 capture" in content:
55 try: 28 raise error.TestFail('V4L2 not found!')
56 content = log.read() 29 if not "video state, recv=1 send=1" in content:
57 if not "Found V4L2 capture" in content: 30 raise error.TestFail('Error in Video send/recv!')
58 raise error.TestFail('V4L2 not found!') 31 if not "voice state, recv=1 send=1" in content:
59 if not "video state, recv=1 send=1" in content: 32 raise error.TestFail('Error in Audio send/recv!')
60 raise error.TestFail('Error in Video send/recv!') 33 if not "Decoded framerate" in content:
61 if not "voice state, recv=1 send=1" in content: 34 raise error.TestFail('Error in Video upstream!')
62 raise error.TestFail('Error in Audio send/recv!') 35 if not "Rendered framerate" in content:
63 if not "Decoded framerate" in content: 36 raise error.TestFail('Error in Video downstream!')
64 raise error.TestFail('Error in Video upstream!') 37 # Get framerate
65 if not "Rendered framerate" in content: 38 self.get_framerate(content)
66 raise error.TestFail('Error in Video downstream!')
67 # Get framerate
68 self.get_framerate(content)
69 finally:
70 log.close()
71 except IOError:
72 raise error.TestFail('Error in reading GTalk log file!')
73 39
74 40
75 def get_framerate(self, log): 41 def get_framerate(self, log):
76 d = {} 42 d = {}
77 # We get a framerate report every 10 seconds for both streams. 43 # We get a framerate report every 10 seconds for both streams.
78 # We run for 5 mins, and should get around (5 * 60/10) * 2 = 60 44 # We run for 5 mins, and should get around (5 * 60/10) * 2 = 60
79 # framerate reports for 2 streams. 45 # framerate reports for 2 streams.
80 # Ignore the first and last framerate since they are not accurate. 46 # Ignore the first and last framerate since they are not accurate.
81 l = re.findall(r"Rendered framerate \((.*)\): (\d+\.?\d*) fps", log) 47 l = re.findall(r"Rendered framerate \((.*)\): (\d+\.?\d*) fps", log)
82 if len(l) < 57: 48 if len(l) < 57:
(...skipping 15 matching lines...) Expand all
98 if (min(fps[0], fps[1]) < 5.0): 64 if (min(fps[0], fps[1]) < 5.0):
99 raise error.TestFail('Error in Video framerate.') 65 raise error.TestFail('Error in Video framerate.')
100 66
101 67
102 def run_once(self): 68 def run_once(self):
103 self.dep_dir = os.path.join(self.autodir, 'deps', self.dep) 69 self.dep_dir = os.path.join(self.autodir, 'deps', self.dep)
104 sys.path.append(self.dep_dir) 70 sys.path.append(self.dep_dir)
105 import pgutil 71 import pgutil
106 72
107 self.performance_results = {} 73 self.performance_results = {}
108 self.run_cleanup() 74 pgutil.cleanup_playground(self.playground)
109 self.run_setup() 75 pgutil.setup_playground(os.path.join(self.dep_dir, 'src'),
76 self.playground, os.path.join(self.bindir, 'options'))
110 77
111 # Launch Playground 78 # Launch Playground
112 path = os.path.join(self.playground, 79 path = os.path.join(self.playground,
113 'buzz/javascript/media/examples') 80 'buzz/javascript/media/examples')
114 page = 'videoplayground.html' 81 page = 'videoplayground.html'
115 para = 'callType=v' 82 para = 'callType=v'
116 playground_url = "%s/%s?%s" % (path, page, para) 83 playground_url = "%s/%s?%s" % (path, page, para)
117 # Here we somehow have to use utils.run 84 # Here we somehow have to use utils.run
118 # Other approaches like utils.system and site_ui.ChromeSession 85 # Other approaches like utils.system and site_ui.ChromeSession
119 # cause problem in video. 86 # cause problem in video.
120 # http://code.google.com/p/chromium-os/issues/detail?id=1764 87 # http://code.google.com/p/chromium-os/issues/detail?id=1764
121 utils.run('su chronos -c \'DISPLAY=:0 \ 88 utils.run('su chronos -c \'DISPLAY=:0 \
122 XAUTHORITY=/home/chronos/.Xauthority \ 89 XAUTHORITY=/home/chronos/.Xauthority \
123 /opt/google/chrome/chrome \ 90 /opt/google/chrome/chrome \
124 --no-first-run %s\' &' % playground_url) 91 --no-first-run %s\' &' % playground_url)
125 92
126 # Collect ctime,stime for GoogleTalkPlugin 93 # Collect ctime,stime for GoogleTalkPlugin
127 time.sleep(WARMUP_TIME) 94 time.sleep(WARMUP_TIME)
128 gtalk_s = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin')) 95 gtalk_s = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin'))
129 chrome_s = pgutil.get_utime_stime(pgutil.get_pids('chrome/chrome')) 96 chrome_s = pgutil.get_utime_stime(pgutil.get_pids('chrome/chrome'))
97 pulse_s = pgutil.get_utime_stime(pgutil.get_pids('pulseaudio'))
130 time.sleep(SLEEP_DURATION) 98 time.sleep(SLEEP_DURATION)
131 gtalk_e = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin')) 99 gtalk_e = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin'))
132 chrome_e = pgutil.get_utime_stime(pgutil.get_pids('chrome/chrome')) 100 chrome_e = pgutil.get_utime_stime(pgutil.get_pids('chrome/chrome'))
101 pulse_e = pgutil.get_utime_stime(pgutil.get_pids('pulseaudio'))
133 102
134 self.performance_results['ctime_gtalk'] = \ 103 self.performance_results['ctime_gtalk'] = \
135 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[0] - gtalk_s[0]) 104 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[0] - gtalk_s[0])
136 self.performance_results['stime_gtalk'] = \ 105 self.performance_results['stime_gtalk'] = \
137 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[1] - gtalk_s[1]) 106 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[1] - gtalk_s[1])
138 self.performance_results['ctime_chrome'] = \ 107 self.performance_results['ctime_chrome'] = \
139 pgutil.get_cpu_usage(SLEEP_DURATION, chrome_e[0] - chrome_s[0]) 108 pgutil.get_cpu_usage(SLEEP_DURATION, chrome_e[0] - chrome_s[0])
140 self.performance_results['stime_chrome'] = \ 109 self.performance_results['stime_chrome'] = \
141 pgutil.get_cpu_usage(SLEEP_DURATION, chrome_e[1] - chrome_s[1]) 110 pgutil.get_cpu_usage(SLEEP_DURATION, chrome_e[1] - chrome_s[1])
111 self.performance_results['ctime_pulse'] = \
112 pgutil.get_cpu_usage(SLEEP_DURATION, pulse_e[0] - pulse_s[0])
113 self.performance_results['stime_pulse'] = \
114 pgutil.get_cpu_usage(SLEEP_DURATION, pulse_e[1] - pulse_s[1])
142 115
143 # Verify log 116 # Verify log
144 try: 117 try:
145 self.run_verification() 118 self.run_verification()
146 finally: 119 finally:
147 self.run_cleanup(True) 120 pgutil.cleanup_playground(self.playground, True)
148 121
149 # Report perf 122 # Report perf
150 self.write_perf_keyval(self.performance_results) 123 self.write_perf_keyval(self.performance_results)
151 124
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698