Skip to content

Commit

Permalink
Update tests to also work with gdb 15
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 20, 2024
1 parent 9d3bfe0 commit e49d834
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions substratevm/mx.substratevm/testhello.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def test():
# print details of greeter types
exec_string = execute("ptype 'hello.Hello$NamedGreeter'")
rexp = [r"type = class hello\.Hello\$NamedGreeter : public hello\.Hello\$Greeter {",
fr"{spaces_pattern}private:",
fr"{spaces_pattern}private:" if major < 15 else None,
fr"{spaces_pattern}{compressed_pattern if isolates else ''}java\.lang\.String \*name;",
r"",
fr"{spaces_pattern}public:",
Expand All @@ -350,7 +350,7 @@ def test():
r"}"]

checker = Checker('ptype NamedGreeter', rexp)
checker.check(exec_string, skip_fails=False)
checker.check(exec_string, skip_fails=True)

exec_string = execute("ptype 'hello.Hello$Greeter'")
rexp = [r"type = class hello\.Hello\$Greeter : public java\.lang\.Object {",
Expand All @@ -360,7 +360,7 @@ def test():
r"}"]

checker = Checker('ptype Greeter', rexp)
checker.check(exec_string, skip_fails=False)
checker.check(exec_string, skip_fails=True)

exec_string = execute("ptype 'java.lang.Object'")
rexp = [r"type = class java\.lang\.Object : public _objhdr {",
Expand Down Expand Up @@ -495,7 +495,7 @@ def test():
exec_string = execute("ptype 'hello.Hello'")
rexp = [r"type = class hello\.Hello : public java\.lang\.Object {",
# ptype lists inlined methods although they are not listed with info func
fr"{spaces_pattern}private:",
fr"{spaces_pattern}private:" if major < 15 else None,
fr"{spaces_pattern}static void inlineA\(void\);",
fr"{spaces_pattern}static void inlineCallChain\(void\);",
fr"{spaces_pattern}static void inlineFrom\(void\);",
Expand All @@ -519,7 +519,7 @@ def test():
fr"{spaces_pattern}static void noInlineThis\(void\);",
r"}"]
checker = Checker('ptype hello.Hello', rexp)
checker.check(exec_string, skip_fails=False)
checker.check(exec_string, skip_fails=True)

# list methods matching regural expression "nline", inline methods are not listed because they lack a definition
# (this is true for C/C++ as well)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import sys
import unittest

import gdb

# add test directory to path to allow import of gdb_helper.py
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__))))

Expand Down Expand Up @@ -68,9 +70,13 @@ def test_manual_load(self):
gdb_set_param("auto-load python-scripts", backup_auto_load_param)

def test_manual_load_without_executable(self):
# Exceptions raised by gdb-debughelpers.py are printed to gdbs stdout as a string in GDB 14.2
# This behavior might change in newer gdb version that makes self.assertRaises usable
self.assertIn('AssertionError', gdb_execute("source gdb-debughelpers.py"))
if int(gdb.VERSION.split('.')[0]) < 15:
# Exceptions raised by gdb-debughelpers.py are printed to gdbs stdout as a string in GDB 14.2 and older
self.assertIn('AssertionError', gdb_execute("source gdb-debughelpers.py"))
else:
# This will raise a gdb.error in GDB 15 and newer, but it does not state AssertionError as its cause
# Needed for github debuginfotest gate
self.assertRaises(gdb.error, lambda: gdb_execute("source gdb-debughelpers.py"))

def test_auto_reload(self):
gdb_start()
Expand Down

0 comments on commit e49d834

Please sign in to comment.