diff options
| author | Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> | 2025-10-09 15:09:35 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-13 18:01:04 +0100 |
| commit | 22d697a835a48ff40df1a02654756e53b7b8d902 (patch) | |
| tree | f8a56dbbd0bb7896fdee9e18d0b30a18f9be4ebe /meta | |
| parent | 2d844e061aa37f699046a336dfc264a55d39bda1 (diff) | |
| download | poky-22d697a835a48ff40df1a02654756e53b7b8d902.tar.gz | |
oeqa: runtime: logrotate: Fix typos and add comments
(From OE-Core rev: 7d1d3b4958bc48cf49ddb653c76c8cd536babac6)
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 | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py index 7cb43d98c5..0d4b9ac60b 100644 --- a/meta/lib/oeqa/runtime/cases/logrotate.py +++ b/meta/lib/oeqa/runtime/cases/logrotate.py | |||
| @@ -20,55 +20,56 @@ class LogrotateTest(OERuntimeTestCase): | |||
| 20 | 20 | ||
| 21 | @classmethod | 21 | @classmethod |
| 22 | def tearDownClass(cls): | 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) | 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) | 24 | cls.tc.target.run('rm -rf /var/log/logrotate_testfile && rm -rf /etc/logrotate.d/logrotate_testfile', ignore_ssh_fails=True) |
| 25 | 25 | ||
| 26 | @OETestDepends(['ssh.SSHTest.test_ssh']) | 26 | @OETestDepends(['ssh.SSHTest.test_ssh']) |
| 27 | @OEHasPackage(['logrotate']) | 27 | @OEHasPackage(['logrotate']) |
| 28 | def test_logrotate_wtmp(self): | 28 | def test_logrotate_wtmp(self): |
| 29 | |||
| 30 | # /var/log/wtmp may not always exist initially, so use touch to ensure it is present | 29 | # /var/log/wtmp may not always exist initially, so use touch to ensure it is present |
| 31 | status, output = self.target.run('touch /var/log/wtmp') | 30 | status, output = self.target.run('touch /var/log/wtmp') |
| 32 | msg = ('Could not create/update /var/log/wtmp with touch') | 31 | msg = ('Could not create/update /var/log/wtmp with touch') |
| 33 | self.assertEqual(status, 0, msg = msg) | 32 | self.assertEqual(status, 0, msg = msg) |
| 34 | 33 | ||
| 35 | status, output = self.target.run('mkdir /var/log//logrotate_dir') | 34 | # Create a folder to store rotated file and add the corresponding |
| 35 | # configuration option | ||
| 36 | status, output = self.target.run('mkdir /var/log/logrotate_dir') | ||
| 36 | msg = ('Could not create logrotate_dir. Output: %s' % output) | 37 | msg = ('Could not create logrotate_dir. Output: %s' % output) |
| 37 | self.assertEqual(status, 0, msg = msg) | 38 | self.assertEqual(status, 0, msg = msg) |
| 38 | 39 | ||
| 39 | status, output = self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/wtmp" > /tmp/logrotate-test.conf') | 40 | status, output = self.target.run('echo "create \n olddir /var/log/logrotate_dir \n include /etc/logrotate.d/wtmp" > /tmp/logrotate-test.conf') |
| 40 | msg = ('Could not write to /tmp/logrotate-test.conf') | 41 | msg = ('Could not write to /tmp/logrotate-test.conf') |
| 41 | self.assertEqual(status, 0, msg = msg) | 42 | self.assertEqual(status, 0, msg = msg) |
| 42 | 43 | ||
| 44 | # Call logrotate -f to force the rotation immediately | ||
| 43 | # If logrotate fails to rotate the log, view the verbose output of logrotate to see what prevented it | 45 | # If logrotate fails to rotate the log, view the verbose output of logrotate to see what prevented it |
| 44 | _, logrotate_output = self.target.run('logrotate -vf /tmp/logrotate-test.conf') | 46 | _, logrotate_output = self.target.run('logrotate -vf /tmp/logrotate-test.conf') |
| 45 | status, _ = self.target.run('find /var/log//logrotate_dir -type f | grep wtmp.1') | 47 | status, _ = self.target.run('find /var/log/logrotate_dir -type f | grep wtmp.1') |
| 46 | msg = ("logrotate did not successfully rotate the wtmp log. Output from logrotate -vf: \n%s" % (logrotate_output)) | 48 | msg = ("logrotate did not successfully rotate the wtmp log. Output from logrotate -vf: \n%s" % (logrotate_output)) |
| 47 | self.assertEqual(status, 0, msg = msg) | 49 | self.assertEqual(status, 0, msg = msg) |
| 48 | 50 | ||
| 49 | @OETestDepends(['logrotate.LogrotateTest.test_logrotate_wtmp']) | 51 | @OETestDepends(['logrotate.LogrotateTest.test_logrotate_wtmp']) |
| 50 | def test_logrotate_newlog(self): | 52 | def test_logrotate_newlog(self): |
| 51 | |||
| 52 | status, output = self.target.run('echo "oeqa logrotate test file" > /var/log/logrotate_testfile') | 53 | status, output = self.target.run('echo "oeqa logrotate test file" > /var/log/logrotate_testfile') |
| 53 | msg = ('Could not create logrotate test file in /var/log') | 54 | msg = ('Could not create logrotate test file in /var/log') |
| 54 | self.assertEqual(status, 0, msg = msg) | 55 | self.assertEqual(status, 0, msg = msg) |
| 55 | 56 | ||
| 56 | status, output = self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1" > /etc/logrotate.d/logrotate_testfile') | 57 | # Create a new configuration file dedicated to a /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') | ||
| 57 | msg = ('Could not write to /etc/logrotate.d/logrotate_testfile') | 59 | msg = ('Could not write to /etc/logrotate.d/logrotate_testfile') |
| 58 | self.assertEqual(status, 0, msg = msg) | 60 | self.assertEqual(status, 0, msg = msg) |
| 59 | 61 | ||
| 60 | status, output = self.target.run('echo "create \n olddir /var/log//logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf') | 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') |
| 61 | msg = ('Could not write to /tmp/logrotate_test2.conf') | 63 | msg = ('Could not write to /tmp/logrotate_test2.conf') |
| 62 | self.assertEqual(status, 0, msg = msg) | 64 | self.assertEqual(status, 0, msg = msg) |
| 63 | 65 | ||
| 64 | status, output = self.target.run('find /var/log//logrotate_dir -type f | grep logrotate_testfile.1') | 66 | status, output = self.target.run('find /var/log/logrotate_dir -type f | grep logrotate_testfile.1') |
| 65 | msg = ('A rotated log for logrotate_testfile is already present in logrotate_dir') | 67 | msg = ('A rotated log for logrotate_testfile is already present in logrotate_dir') |
| 66 | self.assertEqual(status, 1, msg = msg) | 68 | self.assertEqual(status, 1, msg = msg) |
| 67 | 69 | ||
| 70 | # Call logrotate -f to force the rotation immediately | ||
| 68 | # If logrotate fails to rotate the log, view the verbose output of logrotate instead of just listing the files in olddir | 71 | # If logrotate fails to rotate the log, view the verbose output of logrotate instead of just listing the files in olddir |
| 69 | _, logrotate_output = self.target.run('logrotate -vf /tmp/logrotate-test2.conf') | 72 | _, logrotate_output = self.target.run('logrotate -vf /tmp/logrotate-test2.conf') |
| 70 | status, _ = self.target.run('find /var/log//logrotate_dir -type f | grep logrotate_testfile.1') | 73 | status, _ = self.target.run('find /var/log/logrotate_dir -type f | grep logrotate_testfile.1') |
| 71 | msg = ('logrotate did not successfully rotate the logrotate_test log. Output from logrotate -vf: \n%s' % (logrotate_output)) | 74 | msg = ('logrotate did not successfully rotate the logrotate_test log. Output from logrotate -vf: \n%s' % (logrotate_output)) |
| 72 | self.assertEqual(status, 0, msg = msg) | 75 | self.assertEqual(status, 0, msg = msg) |
| 73 | |||
| 74 | |||
