| OLD | NEW |
| 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 logging, os, shutil | 5 import logging, os, shutil |
| 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 | 8 from autotest_lib.client.common_lib import error |
| 9 | 9 |
| 10 class realtimecomm_GTalkunittest(test.test): | 10 class realtimecomm_GTalkunittest(test.test): |
| 11 version = 1 | 11 version = 1 |
| 12 # { test_exe : number_of_testcases } | 12 # { test_exe : number_of_testcases } |
| 13 unittests = { | 13 unittests = { |
| 14 'base_unittest' : '155', | 14 'base_unittest' : '155', |
| 15 'call_unittest' : '2' , | 15 'call_unittest' : '2' , |
| 16 'flute_unittest' : '146', | 16 'flute_unittest' : '146', |
| 17 'flutetesting_unittest' : '3' , | 17 'flutetesting_unittest' : '3' , |
| 18 'media_unittest' : '181', | 18 'media_unittest' : '181', |
| 19 'p2p_unittest' : '228', | 19 'p2p_unittest' : '228', |
| 20 'plugin_unittest' : '10' , | 20 'plugin_unittest' : '10' , |
| 21 'xmllite_unittest' : '49' , | 21 'xmllite_unittest' : '49' , |
| 22 'xmpp_unittest' : '37' , | 22 'xmpp_unittest' : '37' , |
| 23 } | 23 } |
| 24 | 24 |
| 25 def run_once(self): | 25 def run_once(self): |
| 26 # Stop Google Talk Plugin | 26 # Stop Google Talk Plugin |
| 27 utils.run('pkill GoogleTalkPlugin', ignore_status=True) | 27 utils.run('pkill GoogleTalkPlugin', ignore_status=True) |
| 28 | 28 |
| 29 # Setup as appropriate | 29 # Setup as appropriate |
| 30 talk_path = '/home/autotest/talk' | 30 talk_path = os.path.join(self.autodir, 'talk') |
| 31 shutil.rmtree(talk_path, ignore_errors=True) | 31 shutil.rmtree(talk_path, ignore_errors=True) |
| 32 shutil.copytree(os.path.join(self.bindir, 'talk'), talk_path) | 32 shutil.copytree(os.path.join(self.bindir, 'talk'), talk_path) |
| 33 utils.run('chown chronos %s -R' % talk_path) | 33 utils.run('chown chronos %s -R' % talk_path) |
| 34 utils.run('chown chronos \ | 34 utils.run('chown chronos \ |
| 35 /tmp/.google-talk-plugin-theuser.lock.testlock', ignore_status=True) | 35 /tmp/.google-talk-plugin-theuser.lock.testlock', ignore_status=True) |
| 36 | 36 |
| 37 # Run all unittests | 37 # Run all unittests |
| 38 for test_exe in self.unittests: | 38 for test_exe in self.unittests: |
| 39 # TODO(zhurunz): Support ARM once available. | 39 # TODO(zhurunz): Support ARM once available. |
| 40 x86_talk_path = os.path.join(talk_path, 'i686') | 40 x86_talk_path = os.path.join(talk_path, 'i686') |
| 41 # The unittest has to be run in 'talk' folder | 41 # The unittest has to be run in 'talk' folder |
| 42 test_cmd = "cd %s && su chronos -c \'./%s\'" % \ | 42 test_cmd = "cd %s && su chronos -c \'./%s\'" % \ |
| 43 (x86_talk_path, test_exe) | 43 (x86_talk_path, test_exe) |
| 44 self.__run_one_test(test_cmd, self.unittests[test_exe]) | 44 self.__run_one_test(test_cmd, self.unittests[test_exe]) |
| 45 | 45 |
| 46 # Clean up | 46 # Clean up |
| 47 shutil.rmtree(talk_path) | 47 shutil.rmtree(talk_path) |
| 48 | 48 |
| 49 | 49 |
| 50 def __run_one_test(self, test_cmd, number_of_testcases): | 50 def __run_one_test(self, test_cmd, number_of_testcases): |
| 51 logging.info("Running %s" % test_cmd) | 51 logging.info("Running %s" % test_cmd) |
| 52 result = utils.run(test_cmd, ignore_status=True) | 52 result = utils.run(test_cmd, ignore_status=True) |
| 53 if "[ FAILED ]" in result.stdout: | 53 if "[ FAILED ]" in result.stdout: |
| 54 raise error.TestFail(result.stdout) | 54 raise error.TestFail(result.stdout) |
| 55 expected = "[ PASSED ] %s tests." % number_of_testcases | 55 expected = "[ PASSED ] %s tests." % number_of_testcases |
| 56 if not expected in result.stdout: | 56 if not expected in result.stdout: |
| 57 raise error.TestFail(result.stdout) | 57 raise error.TestFail(result.stdout) |
| 58 logging.info("%s passed." % test_cmd) | 58 logging.info("%s passed." % test_cmd) |
| OLD | NEW |