Home | History | Annotate | Download | only in hwclock
      1 from autotest_lib.client.bin import test, utils
      2 from autotest_lib.client.common_lib import error
      3 import re, os, logging
      4 
      5 class hwclock(test.test):
      6     version = 1
      7 
      8     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')
     14         utils.system('/sbin/hwclock --set --date "2/2/80 03:04:00"')
     15         date = utils.system_output('LC_ALL=C /sbin/hwclock')
     16         if not re.match('Sat *Feb *2 *03:04:.. 1980', date):
     17             raise error.TestFail("Failed to set hwclock back to the eighties. "
     18                                  "Output of hwclock is '%s'" % date)
     19 
     20 
     21     def cleanup(self):
     22         """
     23         Restore hardware clock to current system time.
     24         """
     25         logging.info('Restoring the hardware clock')
     26         utils.system('/sbin/hwclock --systohc --noadjfile --utc')
     27