[glib: 1/2] tests: Skip assert-msg-test.py if gdb is non-functional




commit 6e44151bf74d6afa2211d76c07164ee810368b29
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jun 29 14:41:07 2022 +0100

    tests: Skip assert-msg-test.py if gdb is non-functional
    
    Some of the CI runners disable ptrace, as they’re running inside a
    container and ptrace would allow container escape. On those systems, gdb
    can’t work, so skip the gdb test.
    
    Add some additional stderr debug output to make it clear that’s the
    case.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 glib/tests/assert-msg-test.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/assert-msg-test.py b/glib/tests/assert-msg-test.py
index 2d54a56192..d2c8f14516 100755
--- a/glib/tests/assert-msg-test.py
+++ b/glib/tests/assert-msg-test.py
@@ -95,6 +95,7 @@ class TestAssertMessage(unittest.TestCase):
         result = Result(info, out, err)
 
         print("Output:", result.out)
+        print("Error:", result.err)
         return result
 
     def runGdbAssertMessage(self, *args):
@@ -118,13 +119,14 @@ class TestAssertMessage(unittest.TestCase):
             env=env,
             universal_newlines=True,
         )
-        info.check_returncode()
         out = info.stdout.strip()
         err = info.stderr.strip()
 
         result = Result(info, out, err)
 
         print("Output:", result.out)
+        print("Error:", result.err)
+        print(result.info)
         return result
 
     def test_gassert(self):
@@ -146,6 +148,15 @@ class TestAssertMessage(unittest.TestCase):
             tmp.flush()
 
             result = self.runGdbAssertMessage("-x", tmp.name, self.__assert_msg_test)
+
+            # Some CI environments disable ptrace (as they’re running in a
+            # container). If so, skip the test as there’s nothing we can do.
+            if (
+                result.info.returncode != 0
+                and "ptrace: Operation not permitted" in result.err
+            ):
+                self.skipTest("GDB is not functional due to ptrace being disabled")
+
             self.assertEqual(result.info.returncode, 0)
             self.assertIn("$1 = 0x", result.out)
             self.assertIn("assertion failed: (42 < 0)", result.out)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]