forked from autotest/autotest-client-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhwclock.py
28 lines (23 loc) · 952 Bytes
/
hwclock.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import re
import logging
from autotest.client import test, utils
from autotest.client.shared import error
class hwclock(test.test):
version = 1
def run_once(self):
"""
Set hwclock back to a date in 1980 and verify if the changes took
effect in the system.
"""
logging.info('Setting hwclock to 2/2/80 03:04:00')
utils.system_output('/sbin/hwclock --set --date "2/2/80 03:04:00"', retain_output=True)
date = utils.system_output('LC_ALL=C /sbin/hwclock')
if not re.match('Sat *Feb *2 *03:04:.. 1980', date):
raise error.TestFail("Failed to set hwclock back to the eighties. "
"Output of hwclock is '%s'" % date)
def cleanup(self):
"""
Restore hardware clock to current system time.
"""
logging.info('Restoring the hardware clock')
utils.system('/sbin/hwclock --systohc --noadjfile --utc')