mirror of
https://git.yoctoproject.org/poky
synced 2026-02-11 11:13:04 +01:00
Delete logrotate dir to avoid errors when test are executed more than 1 time on the same target. (From OE-Core rev: 02c98c848163a6837692fe74a91754701a44a6c0) Signed-off-by: Jose Perez Carranza <jose.perez.carranza@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
31 lines
1.5 KiB
Python
31 lines
1.5 KiB
Python
# This test should cover https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=289 testcase
|
|
# Note that the image under test must have logrotate installed
|
|
|
|
import unittest
|
|
from oeqa.oetest import oeRuntimeTest, skipModule
|
|
from oeqa.utils.decorators import *
|
|
|
|
def setUpModule():
|
|
if not oeRuntimeTest.hasPackage("logrotate"):
|
|
skipModule("No logrotate package in image")
|
|
|
|
|
|
class LogrotateTest(oeRuntimeTest):
|
|
|
|
@testcase(1544)
|
|
@skipUnlessPassed("test_ssh")
|
|
def test_1_logrotate_setup(self):
|
|
(status, output) = self.target.run('mkdir $HOME/logrotate_dir')
|
|
self.assertEqual(status, 0, msg = "Could not create logrotate_dir. Output: %s" % output)
|
|
(status, output) = self.target.run("sed -i \"s#wtmp {#wtmp {\\n olddir $HOME/logrotate_dir#\" /etc/logrotate.conf")
|
|
self.assertEqual(status, 0, msg = "Could not write to logrotate.conf file. Status and output: %s and %s)" % (status, output))
|
|
|
|
@testcase(1542)
|
|
@skipUnlessPassed("test_1_logrotate_setup")
|
|
def test_2_logrotate(self):
|
|
(status, output) = self.target.run('logrotate -f /etc/logrotate.conf')
|
|
self.assertEqual(status, 0, msg = "logrotate service could not be reloaded. Status and output: %s and %s" % (status, output))
|
|
output = self.target.run('ls -la $HOME/logrotate_dir/ | wc -l')[1]
|
|
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]))
|
|
self.target.run('rm -rf $HOME/logrotate_dir')
|