Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
| 4 | import unittest |
| 5 | from oeqa.oetest import oeRuntimeTest, skipModule |
| 6 | from oeqa.utils.decorators import * |
| 7 | |
| 8 | def setUpModule(): |
| 9 | if not oeRuntimeTest.hasPackage("logrotate"): |
| 10 | skipModule("No logrotate package in image") |
| 11 | |
| 12 | |
| 13 | class LogrotateTest(oeRuntimeTest): |
| 14 | |
| 15 | @skipUnlessPassed("test_ssh") |
| 16 | def test_1_logrotate_setup(self): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 17 | (status, output) = self.target.run('mkdir $HOME/logrotate_dir') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 19 | (status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 27 | 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])) |