[libcxx-commits] [libcxx] 88f0889 - [libcxx][pretty printers] Report not being able to trace test program

David Spickett via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 7 03:02:40 PDT 2021


Author: David Spickett
Date: 2021-10-07T11:02:35+01:00
New Revision: 88f08899da965f232d4c67842d5932481ea534fe

URL: https://github.com/llvm/llvm-project/commit/88f08899da965f232d4c67842d5932481ea534fe
DIFF: https://github.com/llvm/llvm-project/commit/88f08899da965f232d4c67842d5932481ea534fe.diff

LOG: [libcxx][pretty printers] Report not being able to trace test program

If you don't have ptrace permissions this test will fail to run
silently, this adds a check for that and anything else that
might do similar things.

The output will now be:
```
FAILED test program did not run correctly, check gdb warnings

/usr/bin/gdb: warning: Couldn't determine a path for the index cache
directory.
No symbol table is loaded.  Use the "file" command.
warning: Error disabling address space randomization: Operation not
permitted
warning: Could not trace the inferior process.
warning: ptrace: Operation not permitted

error: command failed with exit status: 255
```

We already have a feature to check for a compatible python enabled
gdb, so I think it's reasonable to check for this at test runtime.

Note that this is different to the catch all at the end of the test
script. That would be a case where you can trace but something else
made it stop mid way that wasn't our test breakpoints.

Reviewed By: saugustine

Differential Revision: https://reviews.llvm.org/D110936

Added: 
    

Modified: 
    libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
index b9d00371418e8..484ac9018945e 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.py
@@ -20,6 +20,14 @@
 import sys
 
 test_failures = 0
+# Sometimes the inital run command can fail to trace the process.
+# (e.g. you don't have ptrace permissions)
+# In these cases gdb still sends us an exited event so we cannot
+# see what "run" printed to check for a warning message, since
+# we get taken to our exit handler before we can look.
+# Instead check that at least one test has been run by the time
+# we exit.
+has_run_tests = False
 
 
 class CheckResult(gdb.Command):
@@ -30,6 +38,8 @@ def __init__(self):
 
     def invoke(self, arg, from_tty):
         try:
+            has_run_tests = True
+
             # Stack frame is:
             # 0. StopForDebugger
             # 1. ComparePrettyPrintToChars or ComparePrettyPrintToRegex
@@ -89,7 +99,12 @@ def _get_value_string(self, compare_frame, testcase_frame):
 
 def exit_handler(event=None):
     global test_failures
-    if test_failures:
+    global has_run_tests
+
+    if not has_run_tests:
+        print("FAILED test program did not run correctly, check gdb warnings")
+        test_failures = -1
+    elif test_failures:
         print("FAILED %d cases" % test_failures)
     exit(test_failures)
 


        


More information about the libcxx-commits mailing list