public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
To: openembedded-core@lists.openembedded.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Joshua Watt <jpewhacker@gmail.com>,
	 Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Subject: [PATCH v2 1/2] oeqa: runtime: logrotate: Remove setup and tear down methods
Date: Thu, 16 Oct 2025 09:50:25 +0200	[thread overview]
Message-ID: <20251016-mathieu-test-clean-setup-v2-1-c4295b9334b8@bootlin.com> (raw)
In-Reply-To: <20251016-mathieu-test-clean-setup-v2-0-c4295b9334b8@bootlin.com>

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.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
 meta/lib/oeqa/runtime/cases/logrotate.py | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/meta/lib/oeqa/runtime/cases/logrotate.py b/meta/lib/oeqa/runtime/cases/logrotate.py
index 0d4b9ac60baa..9fe1170226c8 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
 from oeqa.runtime.decorator.package import OEHasPackage
 
 class LogrotateTest(OERuntimeTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.tc.target.run('cp /etc/logrotate.d/wtmp $HOME/wtmp.oeqabak',
-                          ignore_ssh_fails=True)
-
-    @classmethod
-    def tearDownClass(cls):
-        cls.tc.target.run('mv -f $HOME/wtmp.oeqabak /etc/logrotate.d/wtmp && rm -rf /var/log/logrotate_dir', ignore_ssh_fails=True)
-        cls.tc.target.run('rm -rf /var/log/logrotate_testfile && rm -rf /etc/logrotate.d/logrotate_testfile', ignore_ssh_fails=True)
-
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['logrotate'])
     def test_logrotate_wtmp(self):
@@ -33,6 +22,7 @@ class LogrotateTest(OERuntimeTestCase):
 
         # Create a folder to store rotated file and add the corresponding
         # configuration option
+        self.addCleanup(self.target.run, 'rm -rf /var/log/logrotate_dir')
         status, output = self.target.run('mkdir /var/log/logrotate_dir')
         msg = ('Could not create logrotate_dir. Output: %s' % output)
         self.assertEqual(status, 0, msg = msg)
@@ -55,10 +45,17 @@ class LogrotateTest(OERuntimeTestCase):
         self.assertEqual(status, 0, msg = msg)
 
         # Create a new configuration file dedicated to a /var/log/logrotate_testfile
+        self.addCleanup(self.target.run, 'rm -f /var/log/logrotate_testfile')
         status, output = self.target.run('echo "/var/log/logrotate_testfile {\n missingok \n monthly \n rotate 1}" > /etc/logrotate.d/logrotate_testfile')
         msg = ('Could not write to /etc/logrotate.d/logrotate_testfile')
         self.assertEqual(status, 0, msg = msg)
 
+        self.addCleanup(self.target.run, 'rm -rf /var/log/logrotate_dir')
+        status, output = self.target.run('mkdir /var/log/logrotate_dir')
+        msg = ('Could not create logrotate_dir. Output: %s' % output)
+        self.assertEqual(status, 0, msg = msg)
+
+        self.addCleanup(self.target.run, 'rm -f /etc/logrotate.d/logrotate_testfile')
         status, output = self.target.run('echo "create \n olddir /var/log/logrotate_dir \n include /etc/logrotate.d/logrotate_testfile" > /tmp/logrotate-test2.conf')
         msg = ('Could not write to /tmp/logrotate_test2.conf')
         self.assertEqual(status, 0, msg = msg)

-- 
2.47.3



  reply	other threads:[~2025-10-16  7:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16  7:50 [PATCH v2 0/2] oeqa: runtime: Clean setup/tear down function on weston and logrotate Mathieu Dubois-Briand
2025-10-16  7:50 ` Mathieu Dubois-Briand [this message]
2025-10-16  7:50 ` [PATCH v2 2/2] oeqa: runtime: weston: Remove tear down method Mathieu Dubois-Briand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251016-mathieu-test-clean-setup-v2-1-c4295b9334b8@bootlin.com \
    --to=mathieu.dubois-briand@bootlin.com \
    --cc=jpewhacker@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox