mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00

Add the OEHasPackage decorator to a variety of tests so they determine automatically if they should run against a given image. To ensure tests can do this we need to move target operations such as scp commands into the tests and out of the class startup/teardown. (From OE-Core rev: 60d6580b85714b8960a964e775d76a7f937f5e5a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
import re
|
|
|
|
from oeqa.runtime.case import OERuntimeTestCase
|
|
from oeqa.core.decorator.depends import OETestDepends
|
|
from oeqa.core.decorator.oeid import OETestID
|
|
from oeqa.runtime.decorator.package import OEHasPackage
|
|
|
|
class DateTest(OERuntimeTestCase):
|
|
|
|
def setUp(self):
|
|
if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
|
|
self.logger.debug('Stopping systemd-timesyncd daemon')
|
|
self.target.run('systemctl stop systemd-timesyncd')
|
|
|
|
def tearDown(self):
|
|
if self.tc.td.get('VIRTUAL-RUNTIME_init_manager') == 'systemd':
|
|
self.logger.debug('Starting systemd-timesyncd daemon')
|
|
self.target.run('systemctl start systemd-timesyncd')
|
|
|
|
@OETestID(211)
|
|
@OETestDepends(['ssh.SSHTest.test_ssh'])
|
|
@OEHasPackage(['coreutils', 'busybox'])
|
|
def test_date(self):
|
|
(status, output) = self.target.run('date +"%Y-%m-%d %T"')
|
|
msg = 'Failed to get initial date, output: %s' % output
|
|
self.assertEqual(status, 0, msg=msg)
|
|
oldDate = output
|
|
|
|
sampleDate = '"2016-08-09 10:00:00"'
|
|
(status, output) = self.target.run("date -s %s" % sampleDate)
|
|
self.assertEqual(status, 0, msg='Date set failed, output: %s' % output)
|
|
|
|
(status, output) = self.target.run("date -R")
|
|
p = re.match('Tue, 09 Aug 2016 10:00:.. \+0000', output)
|
|
msg = 'The date was not set correctly, output: %s' % output
|
|
self.assertTrue(p, msg=msg)
|
|
|
|
(status, output) = self.target.run('date -s "%s"' % oldDate)
|
|
msg = 'Failed to reset date, output: %s' % output
|
|
self.assertEqual(status, 0, msg=msg)
|