diff options
| author | Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> | 2025-10-09 15:15:57 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-27 17:20:42 +0000 |
| commit | 0faccb809f6be8ddbaf350ef0d973243ae926ec4 (patch) | |
| tree | 7217d3f481a46508bd70fe9bb9ffad842261a276 /meta | |
| parent | 87fd09a18114ca41f3a14d4022e048643756d105 (diff) | |
| download | poky-0faccb809f6be8ddbaf350ef0d973243ae926ec4.tar.gz | |
oeqa: runtime: logrotate: Remove setup and tear down methods
Setup and tear down methods are executed even when the tests are disabled.
This lead to SSH being used to run commands on the target, and as it
might fail when no SSH server is present, we had to use
ignore_ssh_fails=True here.
Instead, run cleanup tasks in tests themselves and remove the tear down
method.
Also, the wtmp configuration file is not modified since the test was
modified a few years ago: there is no need to backup and restore it.
(From OE-Core rev: c90f79ae221573b2d5100f2d25b12f77e33113d7)
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/lib/oeqa/runtime/cases/logrotate.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py index 0d4b9ac60b..9fe1170226 100644 --- a/meta/lib/oeqa/runtime/cases/logrotate.py +++ b/meta/lib/oeqa/runtime/cases/logrotate.py | |||
| @@ -12,17 +12,6 @@ from oeqa.core.decorator.depends import OETestDepends | |||
| 12 | from oeqa.runtime.decorator.package import OEHasPackage | 12 | from oeqa.runtime.decorator.package import OEHasPackage |
| 13 | 13 | ||
| 14 | class LogrotateTest(OERuntimeTestCase): | 14 | class LogrotateTest(OERuntimeTestCase): |
| 15 | |||
| 16 | @classmethod | ||
| 17 | def setUpClass(cls): | ||
| 18 | cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak', | ||
| 19 | ignore_ssh_fails=True) | ||
| 20 | |||
| 21 | @classmethod | ||
| 22 | def tearDownClass(cls): | ||
| 23 | cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf /var/log/logrotate_dir', ignore_ssh_fails=True) | ||
| 24 | cls.tc.target.run('rm -rf /var/log/logrotate_testfile && rm -rf /etc/logrotate.d/logrotate_testfile', ignore_ssh_fails=True) | ||
| 25 | |||
| 26 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 15 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
| 27 | @OEHasPackage(['logrotate']) | 16 | @OEHasPackage(['logrotate']) |
| 28 | def test_logrotate_wtmp(self): | 17 | def test_logrotate_wtmp(self): |
| @@ -33,6 +22,7 @@ class LogrotateTest(OERuntimeTestCase): | |||
| 33 | 22 | ||
| 34 | # Create a folder to store rotated file and add the corresponding | 23 | # Create a folder to store rotated file and add the corresponding |
| 35 | # configuration option | 24 | # configuration option |
| 25 | self.addCleanup(self.target.run, 'rm -rf /var/log/logrotate_dir') | ||
| 36 | status, output = self.target.run('mkdir /var/log/logrotate_dir') | 26 | status, output = self.target.run('mkdir /var/log/logrotate_dir') |
| 37 | msg = ('Could not create logrotate_dir. Output: %s' % output) | 27 | msg = ('Could not create logrotate_dir. Output: %s' % output) |
| 38 | self.assertEqual(status, 0, msg = msg) | 28 | self.assertEqual(status, 0, msg = msg) |
| @@ -55,10 +45,17 @@ class LogrotateTest(OERuntimeTestCase): | |||
| 55 | self.assertEqual(status, 0, msg = msg) | 45 | self.assertEqual(status, 0, msg = msg) |
| 56 | 46 | ||
| 57 | # Create a new configuration file dedicated to a /var/log/logrotate_testfile | 47 | # Create a new configuration file dedicated to a /var/log/logrotate_testfile |
| 48 | self.addCleanup(self.target.run, 'rm -f /var/log/logrotate_testfile') | ||
| 58 | status, output = self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1}" > /etc/logrotate.d/logrotate_testfile') | 49 | status, output = self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1}" > /etc/logrotate.d/logrotate_testfile') |
| 59 | msg = ('Could not write to /etc/logrotate.d/logrotate_testfile') | 50 | msg = ('Could not write to /etc/logrotate.d/logrotate_testfile') |
| 60 | self.assertEqual(status, 0, msg = msg) | 51 | self.assertEqual(status, 0, msg = msg) |
| 61 | 52 | ||
| 53 | self.addCleanup(self.target.run, 'rm -rf /var/log/logrotate_dir') | ||
| 54 | status, output = self.target.run('mkdir /var/log/logrotate_dir') | ||
| 55 | msg = ('Could not create logrotate_dir. Output: %s' % output) | ||
| 56 | self.assertEqual(status, 0, msg = msg) | ||
| 57 | |||
| 58 | self.addCleanup(self.target.run, 'rm -f /etc/logrotate.d/logrotate_testfile') | ||
| 62 | status, output = self.target.run('echo "create \n olddir /var/log/logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf') | 59 | status, output = self.target.run('echo "create \n olddir /var/log/logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf') |
| 63 | msg = ('Could not write to /tmp/logrotate_test2.conf') | 60 | msg = ('Could not write to /tmp/logrotate_test2.conf') |
| 64 | self.assertEqual(status, 0, msg = msg) | 61 | self.assertEqual(status, 0, msg = msg) |
