blob: de300bf55f6139a82fd8e74bf327d49dca4d5f02 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -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
4import unittest
5from oeqa.oetest import oeRuntimeTest, skipModule
6from oeqa.utils.decorators import *
7
8def setUpModule():
9 if not oeRuntimeTest.hasPackage("logrotate"):
10 skipModule("No logrotate package in image")
11
12
13class LogrotateTest(oeRuntimeTest):
14
15 @skipUnlessPassed("test_ssh")
16 def test_1_logrotate_setup(self):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050017 (status, output) = self.target.run('mkdir $HOME/logrotate_dir')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018 self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050019 (status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
21
22 @testcase(289)
23 @skipUnlessPassed("test_1_logrotate_setup")
24 def test_2_logrotate(self):
25 (status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
26 self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027 output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')[1]
28 self.assertTrue(int(output)>=3, msg = "new logfile could not be created. List of files within log directory: %s" %(self.target.run('ls -la $HOME/logrotate_dir')[1]))