Skip to contentSkip to conversation

oeqa/runtime: fix race-condition in minidebuginfo test

PATCH Superseded [email protected] 2 participants 2 messages Jun 11, 2024 – Jun 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 oeqa/runtime: fix race-condition in minidebuginfo test

From: Etienne Cordonnier <[email protected]>

Fix this error where 'coredumpctl info' warns that the coredump is still being processed:

```
AssertionError: 1 != 0 : MiniDebugInfo Test failed: No match found.
-- Notice: 1 [email protected] unit is running, output may be incomplete.
```
---
 meta/lib/oeqa/runtime/cases/systemd.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
meta/lib/oeqa/runtime/cases/systemd.py +13 -4
index 80fdae240a6..b399e2e279e 100644
@@ -150,12 +150,21 @@ class SystemdServiceTests(SystemdTest):
         t_thread.start()
         time.sleep(1)
 
-        status, output = self.target.run('pidof sleep')
+        status, sleep_pid = self.target.run('pidof sleep')
         # cause segfault on purpose
-        self.target.run('kill -SEGV %s' % output)
-        self.assertEqual(status, 0, msg = 'Not able to find process that runs sleep, output : %s' % output)
+        self.target.run('kill -SEGV %s' % sleep_pid)
+        self.assertEqual(status, 0, msg = 'Not able to find process that runs sleep, output : %s' % sleep_pid)
+
+        # Give some time to [email protected] to process the coredump
+        TIMEOUT_SEC = 20
+        for x in range(TIMEOUT_SEC):
+            status, output = self.target.run('coredumpctl list %s' % sleep_pid)
+            if status == 0:
+                break
+            self.assertLess(x, TIMEOUT_SEC - 1, msg="Timed out waiting for coredump creation")
+            time.sleep(1)
 
-        (status, output) = self.target.run('coredumpctl info')
+        (status, output) = self.target.run('coredumpctl info %s' % sleep_pid)
         self.assertEqual(status, 0, msg='MiniDebugInfo Test failed: %s' % output)
         self.assertEqual('sleep_for_duration (busybox.nosuid' in output or 'xnanosleep (sleep.coreutils' in output,
                          True, msg='Call stack is missing minidebuginfo symbols (functions shown as "n/a"): %s' % output)
Signature · 1 line
2.36.1.vfs.0.0
#1 lore raw

meta/lib/oeqa/runtime/cases/systemd.py class SystemdServiceTests(SystemdTest): · line 165

Quoted 9 lines · Etienne Cordonnier via lists.openembedded.org
meta/lib/oeqa/runtime/cases/systemd.py +8 -0
+        # Give some time to [email protected] to process the coredump
+        TIMEOUT_SEC = 20
+        for x in range(TIMEOUT_SEC):
+            status, output = self.target.run('coredumpctl list %s' % sleep_pid)
+            if status == 0:
+                break
+            self.assertLess(x, TIMEOUT_SEC - 1, msg="Timed out waiting for coredump creation")
+            time.sleep(1)

There’s a more Pythonic structure:

for x in range(20):

    status, output = self.target.run('coredumpctl list %s' % sleep_pid)
    if status == 0:
      break
    time.sleep(1)

else:
self.fail("Timed out waiting for coredump creation”)

Cheers,
Ross