OLD | NEW |
(Empty) | |
| 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 |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os, re, shutil, sys, time |
| 6 |
| 7 from autotest_lib.client.bin import test, utils |
| 8 from autotest_lib.client.common_lib import error, site_ui |
| 9 |
| 10 WARMUP_TIME = 30 |
| 11 SLEEP_DURATION = 90 |
| 12 |
| 13 class realtimecomm_GTalkAudioPlayground(test.test): |
| 14 version = 1 |
| 15 playground = '/home/chronos/playground' |
| 16 dep = 'realtimecomm_playground' |
| 17 |
| 18 def setup(self): |
| 19 self.job.setup_dep([self.dep]) |
| 20 |
| 21 |
| 22 def run_verification(self): |
| 23 if not os.path.exists('/tmp/tmp.log'): |
| 24 raise error.TestFail('GTalk log file not exist!') |
| 25 content = utils.read_file('/tmp/tmp.log') |
| 26 if not "voice state, recv=1 send=1" in content: |
| 27 raise error.TestFail('Error in Audio send/recv!') |
| 28 |
| 29 |
| 30 def run_once(self): |
| 31 self.dep_dir = os.path.join(self.autodir, 'deps', self.dep) |
| 32 sys.path.append(self.dep_dir) |
| 33 import pgutil |
| 34 |
| 35 self.performance_results = {} |
| 36 pgutil.cleanup_playground(self.playground) |
| 37 pgutil.setup_playground(os.path.join(self.dep_dir, 'src'), |
| 38 self.playground, os.path.join(self.bindir, 'options')) |
| 39 |
| 40 # Launch Playground |
| 41 path = os.path.join(self.playground, |
| 42 'buzz/javascript/media/examples') |
| 43 page = 'videoplayground.html' |
| 44 para = 'callType=a' |
| 45 playground_url = "%s/%s?%s" % (path, page, para) |
| 46 # Here we somehow have to use utils.run |
| 47 # Other approaches like utils.system and site_ui.ChromeSession |
| 48 # cause problem in video. |
| 49 # http://code.google.com/p/chromium-os/issues/detail?id=1764 |
| 50 utils.run('su chronos -c \'DISPLAY=:0 \ |
| 51 XAUTHORITY=/home/chronos/.Xauthority \ |
| 52 /opt/google/chrome/chrome \ |
| 53 --no-first-run %s\' &' % playground_url) |
| 54 |
| 55 # Collect ctime,stime for GoogleTalkPlugin |
| 56 time.sleep(WARMUP_TIME) |
| 57 gtalk_s = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin')) |
| 58 pulse_s = pgutil.get_utime_stime(pgutil.get_pids('pulseaudio')) |
| 59 time.sleep(SLEEP_DURATION) |
| 60 gtalk_e = pgutil.get_utime_stime(pgutil.get_pids('GoogleTalkPlugin')) |
| 61 pulse_e = pgutil.get_utime_stime(pgutil.get_pids('pulseaudio')) |
| 62 |
| 63 self.performance_results['ctime_gtalk'] = \ |
| 64 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[0] - gtalk_s[0]) |
| 65 self.performance_results['stime_gtalk'] = \ |
| 66 pgutil.get_cpu_usage(SLEEP_DURATION, gtalk_e[1] - gtalk_s[1]) |
| 67 self.performance_results['ctime_pulse'] = \ |
| 68 pgutil.get_cpu_usage(SLEEP_DURATION, pulse_e[0] - pulse_s[0]) |
| 69 self.performance_results['stime_pulse'] = \ |
| 70 pgutil.get_cpu_usage(SLEEP_DURATION, pulse_e[1] - pulse_s[1]) |
| 71 |
| 72 # Verify log |
| 73 try: |
| 74 self.run_verification() |
| 75 finally: |
| 76 pgutil.cleanup_playground(self.playground, True) |
| 77 |
| 78 # Report perf |
| 79 self.write_perf_keyval(self.performance_results) |
| 80 |
OLD | NEW |