blob: 3e6d2a825bdd260103e92c09ac3b07ab61033407 [file] [log] [blame]
mblighfa15d4e2010-03-24 21:50:59 +00001from autotest_lib.client.bin import test, utils
2from autotest_lib.client.common_lib import error
lmr28f02982010-03-31 16:33:57 +00003import re, os, logging
mblighfa15d4e2010-03-24 21:50:59 +00004
5class hwclock(test.test):
6 version = 1
7
lmr28f02982010-03-31 16:33:57 +00008 def run_once(self):
9 """
10 Set hwclock back to a date in 1980 and verify if the changes took
11 effect in the system.
12 """
13 logging.info('Setting hwclock to 2/2/80 03:04:00')
mblighfa15d4e2010-03-24 21:50:59 +000014 utils.system('/sbin/hwclock --set --date "2/2/80 03:04:00"')
lmr28f02982010-03-31 16:33:57 +000015 date = utils.system_output('LC_ALL=C /sbin/hwclock')
mblighfa15d4e2010-03-24 21:50:59 +000016 if not re.match('Sat *Feb *2 *03:04:.. 1980', date):
lmr28f02982010-03-31 16:33:57 +000017 raise error.TestFail("Failed to set hwclock back to the eighties. "
18 "Output of hwclock is '%s'" % date)
mblighfa15d4e2010-03-24 21:50:59 +000019
20
21 def cleanup(self):
lmr28f02982010-03-31 16:33:57 +000022 """
23 Restore hardware clock to current system time.
24 """
25 logging.info('Restoring the hardware clock')
mblighfa15d4e2010-03-24 21:50:59 +000026 utils.system('/sbin/hwclock --systohc --noadjfile --utc')