public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] oeqa: runtime: Clean setup/tear down function on weston and logrotate
@ 2025-10-16  7:50 Mathieu Dubois-Briand
  2025-10-16  7:50 ` [PATCH v2 1/2] oeqa: runtime: logrotate: Remove setup and tear down methods Mathieu Dubois-Briand
  2025-10-16  7:50 ` [PATCH v2 2/2] oeqa: runtime: weston: Remove tear down method Mathieu Dubois-Briand
  0 siblings, 2 replies; 3+ messages in thread
From: Mathieu Dubois-Briand @ 2025-10-16  7:50 UTC (permalink / raw)
  To: openembedded-core; +Cc: Thomas Petazzoni, Joshua Watt, Mathieu Dubois-Briand

This was discussed on my previous series, introducing a new error on SSH
connection failure during tests: setup and tear down functions should
only do simple operations and not try to interact with the target.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
Changes in v2:
- Use addCleanup() method to remove files. I clearly prefer this version
  for the logrotate tests. I'm not so sure about the weston tests, as
  some file is expected to be kept across tests in some situation and so
  lead to some strange logic in my changes.
- Link to v1: https://lore.kernel.org/r/20251013-mathieu-test-clean-setup-v1-0-6cea9936d79b@bootlin.com

---
Mathieu Dubois-Briand (2):
      oeqa: runtime: logrotate: Remove setup and tear down methods
      oeqa: runtime: weston: Remove tear down method

 meta/lib/oeqa/runtime/cases/logrotate.py | 19 ++++++++-----------
 meta/lib/oeqa/runtime/cases/weston.py    |  9 +++++----
 2 files changed, 13 insertions(+), 15 deletions(-)
---
base-commit: d098b35cfc3098448bd81245f9593fcd728e4b20
change-id: 20251013-mathieu-test-clean-setup-6eec6fcc734d

Best regards,
-- 
Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] oeqa: runtime: logrotate: Remove setup and tear down methods
  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
  2025-10-16  7:50 ` [PATCH v2 2/2] oeqa: runtime: weston: Remove tear down method Mathieu Dubois-Briand
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Dubois-Briand @ 2025-10-16  7:50 UTC (permalink / raw)
  To: openembedded-core; +Cc: Thomas Petazzoni, Joshua Watt, Mathieu Dubois-Briand

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] oeqa: runtime: weston: Remove tear down method
  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 ` [PATCH v2 1/2] oeqa: runtime: logrotate: Remove setup and tear down methods Mathieu Dubois-Briand
@ 2025-10-16  7:50 ` Mathieu Dubois-Briand
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Dubois-Briand @ 2025-10-16  7:50 UTC (permalink / raw)
  To: openembedded-core; +Cc: Thomas Petazzoni, Joshua Watt, Mathieu Dubois-Briand

Tear down method is 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, remove log file just before it is created: it will remain on
the target after the test is run, but this should be acceptable.

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

diff --git a/meta/lib/oeqa/runtime/cases/weston.py b/meta/lib/oeqa/runtime/cases/weston.py
index e2cecffe8353..b0dccee73bf4 100644
--- a/meta/lib/oeqa/runtime/cases/weston.py
+++ b/meta/lib/oeqa/runtime/cases/weston.py
@@ -14,10 +14,6 @@ import time
 class WestonTest(OERuntimeTestCase):
     weston_log_file = '/tmp/weston-2.log'
 
-    @classmethod
-    def tearDownClass(cls):
-        cls.tc.target.run('rm %s' % cls.weston_log_file, ignore_ssh_fails=True)
-
     @OETestDepends(['ssh.SSHTest.test_ssh'])
     @OEHasPackage(['weston'])
     def test_weston_running(self):
@@ -67,6 +63,10 @@ class WestonTest(OERuntimeTestCase):
         existing_wl_processes = self.get_processes_of('weston-desktop-shell', 'existing')
         existing_weston_processes = self.get_processes_of('weston', 'existing')
 
+        # weston log file should be removed, except if test_weston_supports_xwayland() test has to be run.
+        if 'x11' not in self.td.get('DISTRO_FEATURES'):
+            self.addCleanup(self.target.run, 'rm -f %s' % self.weston_log_file)
+
         weston_thread = threading.Thread(target=self.run_weston_init)
         weston_thread.start()
         new_wl_processes, try_cnt = self.get_new_wayland_processes(existing_wl_processes)
@@ -83,6 +83,7 @@ class WestonTest(OERuntimeTestCase):
     @skipIfNotFeature('x11', 'Test requires x11 to be in DISTRO_FEATURES')
     @OEHasPackage(['weston'])
     def test_weston_supports_xwayland(self):
+        self.addCleanup(self.target.run, 'rm -f %s' % self.weston_log_file)
         cmd ='cat %s | grep "xserver listening on display"' % self.weston_log_file
         status, output = self.target.run(cmd)
         msg = ('xwayland does not appear to be running')

-- 
2.47.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-16  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 1/2] oeqa: runtime: logrotate: Remove setup and tear down methods Mathieu Dubois-Briand
2025-10-16  7:50 ` [PATCH v2 2/2] oeqa: runtime: weston: Remove tear down method Mathieu Dubois-Briand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox