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

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

Issue 2217001: fixed test to use htpdate (Closed) Base URL: ssh://git@chromiumos-git/autotest.git
Patch Set: added missing edits back Created 10 years, 6 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
« no previous file with comments | « no previous file | client/site_tests/platform_DaemonsRespawn/test_respawn.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logging, math, re, utils 5 import logging, math, re, utils
6 from autotest_lib.client.bin import site_log_reader, test 6 from autotest_lib.client.bin import site_log_reader, test
7 from autotest_lib.client.common_lib import error 7 from autotest_lib.client.common_lib import error
8 8
9 class platform_AccurateTime(test.test): 9 class platform_AccurateTime(test.test):
10 version = 1 10 version = 1
11 11
12 12
13 def __get_offset(self, string): 13 def __get_offset(self, string):
14 offset = re.search(r'(-?[\d+\.]+)s', string) 14 » if (string.find('No time correction needed') > -1) :
15 if offset is None: 15 return float(0.0)
16 # If string is empty, check the sys logs dumped later. 16 else :
17 raise error.TestError('Unable to find offset in %s' % string) 17 offset = re.search(r'Setting (-?[\d+\.]+) seconds', string)
18 return float(offset.group(1)) 18 if offset is None:
19 19 # If string is empty, check the sys logs dumped later.
20 raise error.TestError('Unable to find offset in %s' % string)
21 return float(offset.group(1))
20 22
21 def run_once(self): 23 def run_once(self):
22 reader = site_log_reader.LogReader() 24 reader = site_log_reader.LogReader()
23 reader.set_start_by_current() 25 reader.set_start_by_current()
24 # Check ntpd is currently running 26 # Check ntpd is currently running
25 if utils.system('pgrep ntpd', ignore_status=True) != 0: 27 if utils.system('pgrep ntpd', ignore_status=True) != 0:
26 raise error.TestError('NTP server was not already running') 28 raise error.TestError('NTP server was not already running')
27 # Stop it since we cannot force ntp requests unless its not running 29 # Stop it since we cannot force ntp requests unless its not running
28 utils.system('initctl stop ntp') 30 utils.system('initctl stop ntp')
29 try: 31 try:
30 # Now grab the current time and get its offset 32 # Now grab the current time and get its offset
31 output = utils.system_output('ntpd -g -u ntp:ntp -q', 33 cmd = '/usr/sbin/htpdate -u ntp:ntp -s -t -w www.google.com';
32 retain_output=True) 34 output = utils.system_output(cmd,retain_output=True)
33 server_offset = self.__get_offset(output) 35 server_offset = self.__get_offset(output)
34 logging.info("server time offset: %f" % server_offset) 36 logging.info("server time offset: %f" % server_offset)
35 37
36 self.write_perf_keyval({'seconds_offset': abs(server_offset)}) 38 self.write_perf_keyval({'seconds_offset': abs(server_offset)})
37 finally: 39 finally:
38 utils.system('initctl start ntp') 40 utils.system('initctl start ntp')
39 logging.debug('sys logs emitted: %s' % reader.get_logs()) 41 logging.debug('sys logs emitted: %s' % reader.get_logs())
OLDNEW
« no previous file with comments | « no previous file | client/site_tests/platform_DaemonsRespawn/test_respawn.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698