blob: db6e695eef04a66cfac623530d23d78be19593fb [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=289 testcase
2# Note that the image under test must have logrotate installed
3
4from oeqa.runtime.case import OERuntimeTestCase
5from oeqa.core.decorator.depends import OETestDepends
6from oeqa.core.decorator.oeid import OETestID
7from oeqa.runtime.decorator.package import OEHasPackage
8
9class LogrotateTest(OERuntimeTestCase):
10
11 @classmethod
12 def tearDownClass(cls):
13 cls.tc.target.run('rm -rf $HOME/logrotate_dir')
14
15 @OETestID(1544)
16 @OETestDepends(['ssh.SSHTest.test_ssh'])
17 @OEHasPackage(['logrotate'])
18 def test_1_logrotate_setup(self):
19 status, output = self.target.run('mkdir $HOME/logrotate_dir')
20 msg = 'Could not create logrotate_dir. Output: %s' % output
21 self.assertEqual(status, 0, msg = msg)
22
23 cmd = ('sed -i "s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#"'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024 ' /etc/logrotate.d/wtmp')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 status, output = self.target.run(cmd)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026 msg = ('Could not write to logrotate.d/wtmp file. Status and output: '
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027 ' %s and %s' % (status, output))
28 self.assertEqual(status, 0, msg = msg)
29
30 @OETestID(1542)
31 @OETestDepends(['logrotate.LogrotateTest.test_1_logrotate_setup'])
32 def test_2_logrotate(self):
33 status, output = self.target.run('logrotate -f /etc/logrotate.conf')
34 msg = ('logrotate service could not be reloaded. Status and output: '
35 '%s and %s' % (status, output))
36 self.assertEqual(status, 0, msg = msg)
37
38 _, output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')
39 msg = ('new logfile could not be created. List of files within log '
40 'directory: %s' % (
41 self.target.run('ls -la $HOME/logrotate_dir')[1]))
42 self.assertTrue(int(output)>=3, msg = msg)