summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/cases/logrotate.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime/cases/logrotate.py')
-rw-r--r--meta/lib/oeqa/runtime/cases/logrotate.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
new file mode 100644
index 0000000000..992fef2989
--- /dev/null
+++ b/meta/lib/oeqa/runtime/cases/logrotate.py
@@ -0,0 +1,42 @@
1# 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#"'
24 ' /etc/logrotate.conf')
25 status, output = self.target.run(cmd)
26 msg = ('Could not write to logrotate.conf file. Status and output: '
27 ' %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)