llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Raphael Isemann (Teemperor)

<details>
<summary>Changes</summary>

This removes the various `types/` tests in LLDB. These tests suffer from 
various problems:

* They are slow. Their current runtime is nearly 90s on my new machine, which 
is a lot for tests that only print a few integers/float vars.

* Their scope is very vague. E.g., `TestCharType` doesn't just test char types, 
but also tests capturing them in block functions. Also while most tests are 
related to basic types, some also test edge cases of struct types and other 
things that belong into their own test folder.

* They are very overengineered. Tests should be stupid and not have whole 
dedicated output-capturing-and-parsing system.

* They don't really test anything. There are no edge cases or problematic 
values tested.

The tests will were replaced by the following previous commits:

[TODO]

---

Patch is 50.60 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/208402.diff


32 Files Affected:

- (removed) lldb/test/API/types/AbstractBase.py (-303) 
- (removed) lldb/test/API/types/HideTestFailures.py (-78) 
- (removed) lldb/test/API/types/Makefile (-5) 
- (removed) lldb/test/API/types/TestCharType.py (-27) 
- (removed) lldb/test/API/types/TestCharTypeExpr.py (-29) 
- (removed) lldb/test/API/types/TestDoubleTypes.py (-22) 
- (removed) lldb/test/API/types/TestDoubleTypesExpr.py (-26) 
- (removed) lldb/test/API/types/TestFloatTypes.py (-22) 
- (removed) lldb/test/API/types/TestFloatTypesExpr.py (-26) 
- (removed) lldb/test/API/types/TestIntegerType.py (-27) 
- (removed) lldb/test/API/types/TestIntegerTypeExpr.py (-32) 
- (removed) lldb/test/API/types/TestLongTypes.py (-45) 
- (removed) lldb/test/API/types/TestLongTypesExpr.py (-47) 
- (removed) lldb/test/API/types/TestRecursiveTypes.py (-49) 
- (removed) lldb/test/API/types/TestShortType.py (-27) 
- (removed) lldb/test/API/types/TestShortTypeExpr.py (-27) 
- (removed) lldb/test/API/types/basic_type.cpp (-225) 
- (removed) lldb/test/API/types/char.cpp (-9) 
- (removed) lldb/test/API/types/double.cpp (-9) 
- (removed) lldb/test/API/types/float.cpp (-9) 
- (removed) lldb/test/API/types/int.cpp (-9) 
- (removed) lldb/test/API/types/long.cpp (-18) 
- (removed) lldb/test/API/types/long_long.cpp (-18) 
- (removed) lldb/test/API/types/recursive_type_1.cpp (-12) 
- (removed) lldb/test/API/types/recursive_type_2.cpp (-10) 
- (removed) lldb/test/API/types/recursive_type_main.cpp (-8) 
- (removed) lldb/test/API/types/short.cpp (-9) 
- (removed) lldb/test/API/types/unsigned_char.cpp (-9) 
- (removed) lldb/test/API/types/unsigned_int.cpp (-9) 
- (removed) lldb/test/API/types/unsigned_long.cpp (-18) 
- (removed) lldb/test/API/types/unsigned_long_long.cpp (-18) 
- (removed) lldb/test/API/types/unsigned_short.cpp (-9) 


``````````diff
diff --git a/lldb/test/API/types/AbstractBase.py 
b/lldb/test/API/types/AbstractBase.py
deleted file mode 100644
index 0420ffd8f3bbb..0000000000000
--- a/lldb/test/API/types/AbstractBase.py
+++ /dev/null
@@ -1,303 +0,0 @@
-"""
-Abstract base class of basic types provides a generic type tester method.
-"""
-
-import os
-import re
-import lldb
-from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
-
-
-def Msg(var, val, using_frame_variable):
-    return "'%s %s' matches the output (from compiled code): %s" % (
-        "frame variable --show-types" if using_frame_variable else 
"expression",
-        var,
-        val,
-    )
-
-
-class GenericTester(TestBase):
-    # This is the pattern by design to match the " var = 'value'" output from
-    # printf() stmts (see basic_type.cpp).
-    pattern = re.compile(r" (\*?a[^=]*) = '([^=]*)'$")
-
-    SHARED_BUILD_TESTCASE = False
-
-    # Assert message.
-    DATA_TYPE_GROKKED = "Data type from expr parser output is parsed correctly"
-
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # We'll use the test method name as the exe_name.
-        # There are a bunch of test cases under test/types and we don't want 
the
-        # module cacheing subsystem to be confused with executable name "a.out"
-        # used for all the test cases.
-        self.exe_name = self.testMethodName
-        golden = "{}-golden-output.txt".format(self.testMethodName)
-        self.golden_filename = self.getBuildArtifact(golden)
-
-    def tearDown(self):
-        """Cleanup the test byproducts."""
-        if os.path.exists(self.golden_filename):
-            os.remove(self.golden_filename)
-        TestBase.tearDown(self)
-
-    # 
==========================================================================#
-    # Functions build_and_run() and build_and_run_expr() are generic functions 
#
-    # which are called from the Test*Types*.py test cases.  The API client is  
#
-    # responsible for supplying two mandatory arguments: the source file, 
e.g.,#
-    # 'int.cpp', and the atoms, e.g., set(['unsigned', 'long long']) to the    
#
-    # functions.  There are also three optional keyword arguments of interest, 
#
-    # as follows:                                                              
#
-    #                                                                          
#
-    # bc -> blockCaptured (defaulted to False)                                 
#
-    #         True: testing vars of various basic types from inside a block    
#
-    #         False: testing vars of various basic types from a function       
#
-    # qd -> quotedDisplay (defaulted to False)                                 
#
-    #         True: the output from 'frame var' or 'expr var' contains a pair  
#
-    #               of single quotes around the value                          
#
-    #         False: no single quotes are to be found around the value of      
#
-    #                variable                                                  
#
-    # 
==========================================================================#
-
-    def build_and_run(self, source, atoms, bc=False, qd=False):
-        self.build_and_run_with_source_atoms_expr(
-            source, atoms, expr=False, bc=bc, qd=qd
-        )
-
-    def build_and_run_expr(self, source, atoms, bc=False, qd=False):
-        self.build_and_run_with_source_atoms_expr(
-            source, atoms, expr=True, bc=bc, qd=qd
-        )
-
-    def build_and_run_with_source_atoms_expr(
-        self, source, atoms, expr, bc=False, qd=False
-    ):
-        # See also Makefile and basic_type.cpp:177.
-        if bc:
-            d = {
-                "CXX_SOURCES": source,
-                "EXE": self.exe_name,
-                "CFLAGS_EXTRAS": "-DTEST_BLOCK_CAPTURED_VARS",
-            }
-        else:
-            d = {"CXX_SOURCES": source, "EXE": self.exe_name}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        if expr:
-            self.generic_type_expr_tester(
-                self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd
-            )
-        else:
-            self.generic_type_tester(
-                self.exe_name, atoms, blockCaptured=bc, quotedDisplay=qd
-            )
-
-    def process_launch_o(self):
-        # process launch command output redirect always goes to host the
-        # process is running on
-        if lldb.remote_platform:
-            # process launch -o requires a path that is valid on the target
-            self.assertIsNotNone(lldb.remote_platform.GetWorkingDirectory())
-            remote_path = lldbutil.append_to_process_working_directory(
-                self, "lldb-stdout-redirect.txt"
-            )
-            self.runCmd("process launch -- 
{remote}".format(remote=remote_path))
-            # copy remote_path to local host
-            self.runCmd(
-                'platform get-file {remote} "{local}"'.format(
-                    remote=remote_path, local=self.golden_filename
-                )
-            )
-        else:
-            self.runCmd(
-                'process launch -o 
"{local}"'.format(local=self.golden_filename)
-            )
-
-    def get_golden_list(self, blockCaptured=False):
-        with open(self.golden_filename, "r") as f:
-            go = f.read()
-
-        golden_list = []
-        # Scan the golden output line by line, looking for the pattern:
-        #
-        #     variable = 'value'
-        #
-        for line in go.split(os.linesep):
-            # We'll ignore variables of array types from inside a block.
-            if blockCaptured and "[" in line:
-                continue
-            match = self.pattern.search(line)
-            if match:
-                var, val = match.group(1), match.group(2)
-                golden_list.append((var, val))
-        return golden_list
-
-    def generic_type_tester(
-        self, exe_name, atoms, quotedDisplay=False, blockCaptured=False
-    ):
-        """Test that variables with basic types are displayed correctly."""
-        self.runCmd("file %s" % self.getBuildArtifact(exe_name), 
CURRENT_EXECUTABLE_SET)
-
-        # First, capture the golden output emitted by the oracle, i.e., the
-        # series of printf statements.
-        self.process_launch_o()
-
-        # This golden list contains a list of (variable, value) pairs extracted
-        # from the golden output.
-        gl = self.get_golden_list(blockCaptured)
-
-        # This test uses a #include of "basic_type.cpp" so we need to enable
-        # always setting inlined breakpoints.
-        self.runCmd("settings set target.inline-breakpoint-strategy always")
-
-        # Inherit TCC permissions. We can leave this set.
-        self.runCmd("settings set target.inherit-tcc true")
-
-        # Kill rather than detach from the inferior if something goes wrong.
-        self.runCmd("settings set target.detach-on-error false")
-
-        # And add hooks to restore the settings during tearDown().
-        self.addTearDownHook(
-            lambda: self.runCmd(
-                "settings set target.inline-breakpoint-strategy headers"
-            )
-        )
-
-        # Bring the program to the point where we can issue a series of
-        # 'frame variable --show-types' command.
-        if blockCaptured:
-            break_line = line_number(
-                "basic_type.cpp", "// Break here to test block captured 
variables."
-            )
-        else:
-            break_line = line_number(
-                "basic_type.cpp",
-                "// Here is the line we will break on to check variables.",
-            )
-        lldbutil.run_break_set_by_file_and_line(
-            self, "basic_type.cpp", break_line, num_expected_locations=1, 
loc_exact=True
-        )
-
-        self.runCmd("run", RUN_SUCCEEDED)
-        self.expect(
-            "process status",
-            STOPPED_DUE_TO_BREAKPOINT,
-            substrs=[
-                "stop reason = breakpoint",
-                " at basic_type.cpp:%d" % break_line,
-            ],
-        )
-
-        # self.runCmd("frame variable --show-types")
-
-        # Now iterate through the golden list, comparing against the output 
from
-        # 'frame variable --show-types var'.
-        for var, val in gl:
-            self.runCmd("frame variable --show-types %s" % var)
-            output = self.res.GetOutput()
-
-            # The input type is in a canonical form as a set of named atoms.
-            # The display type string must contain each and every element.
-            #
-            # Example:
-            #     runCmd: frame variable --show-types a_array_bounded[0]
-            #     output: (char) a_array_bounded[0] = 'a'
-            #
-            try:
-                dt = re.match(r"^\((.*)\)", output).group(1)
-            except:
-                self.fail(self.DATA_TYPE_GROKKED)
-
-            # Expect the display type string to contain each and every atoms.
-            self.expect(
-                dt,
-                "Display type: '%s' must contain the type atoms: '%s'" % (dt, 
atoms),
-                exe=False,
-                substrs=list(atoms),
-            )
-
-            # The (var, val) pair must match, too.
-            nv = ("%s = '%s'" if quotedDisplay else "%s = %s") % (var, val)
-            self.expect(output, Msg(var, val, True), exe=False, substrs=[nv])
-
-    def generic_type_expr_tester(
-        self, exe_name, atoms, quotedDisplay=False, blockCaptured=False
-    ):
-        """Test that variable expressions with basic types are evaluated 
correctly."""
-
-        self.runCmd("file %s" % self.getBuildArtifact(exe_name), 
CURRENT_EXECUTABLE_SET)
-
-        # First, capture the golden output emitted by the oracle, i.e., the
-        # series of printf statements.
-        self.process_launch_o()
-
-        # This golden list contains a list of (variable, value) pairs extracted
-        # from the golden output.
-        gl = self.get_golden_list(blockCaptured)
-
-        # This test uses a #include of "basic_type.cpp" so we need to enable
-        # always setting inlined breakpoints.
-        self.runCmd("settings set target.inline-breakpoint-strategy always")
-        # And add hooks to restore the settings during tearDown().
-        self.addTearDownHook(
-            lambda: self.runCmd(
-                "settings set target.inline-breakpoint-strategy headers"
-            )
-        )
-
-        # Bring the program to the point where we can issue a series of
-        # 'expr' command.
-        if blockCaptured:
-            break_line = line_number(
-                "basic_type.cpp", "// Break here to test block captured 
variables."
-            )
-        else:
-            break_line = line_number(
-                "basic_type.cpp",
-                "// Here is the line we will break on to check variables.",
-            )
-        lldbutil.run_break_set_by_file_and_line(
-            self, "basic_type.cpp", break_line, num_expected_locations=1, 
loc_exact=True
-        )
-
-        self.runCmd("run", RUN_SUCCEEDED)
-        self.expect(
-            "process status",
-            STOPPED_DUE_TO_BREAKPOINT,
-            substrs=["stop reason = breakpoint", " at basic_type.cpp:%d" % 
break_line],
-        )
-
-        # self.runCmd("frame variable --show-types")
-
-        # Now iterate through the golden list, comparing against the output 
from
-        # 'expr var'.
-        for var, val in gl:
-            self.runCmd("expression %s" % var)
-            output = self.res.GetOutput()
-
-            # The input type is in a canonical form as a set of named atoms.
-            # The display type string must contain each and every element.
-            #
-            # Example:
-            #     runCmd: expr a
-            #     output: (double) $0 = 1100.12
-            #
-            try:
-                dt = re.match(r"^\((.*)\) \$[0-9]+ = ", output).group(1)
-            except:
-                self.fail(self.DATA_TYPE_GROKKED)
-
-            # Expect the display type string to contain each and every atoms.
-            self.expect(
-                dt,
-                "Display type: '%s' must contain the type atoms: '%s'" % (dt, 
atoms),
-                exe=False,
-                substrs=list(atoms),
-            )
-
-            # The val part must match, too.
-            valPart = ("'%s'" if quotedDisplay else "%s") % val
-            self.expect(output, Msg(var, val, False), exe=False, 
substrs=[valPart])
diff --git a/lldb/test/API/types/HideTestFailures.py 
b/lldb/test/API/types/HideTestFailures.py
deleted file mode 100644
index 3118617d7e041..0000000000000
--- a/lldb/test/API/types/HideTestFailures.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""
-Test that variables of integer basic types are displayed correctly.
-"""
-
-
-import AbstractBase
-import lldb
-from lldbsuite.test.lldbtest import *
-
-# rdar://problem/9649573
-# Capture the lldb and gdb-remote log files for test failures when run
-# with no "-w" option
-
-
-class DebugIntegerTypesFailures(TestBase):
-    SHARED_BUILD_TESTCASE = False
-
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # If we're lucky, test_long_type_with_dsym fails.
-        # Let's turn on logging just for that.
-        try:
-            if "test_long_type_with_dsym" in self.id():
-                self.runCmd(
-                    "log enable -n -f %s lldb commands event process state"
-                    % os.environ["DEBUG_LLDB_LOG"]
-                )
-                self.runCmd(
-                    "log enable -n -f %s gdb-remote packets process"
-                    % os.environ["DEBUG_GDB_REMOTE_LOG"]
-                )
-        except:
-            pass
-
-    def tearDown(self):
-        # If we're lucky, test_long_type_with_dsym fails.
-        # Let's turn off logging just for that.
-        if "test_long_type_with_dsym" in self.id():
-            self.runCmd("log disable lldb")
-            self.runCmd("log disable gdb-remote")
-        # Call super's tearDown().
-        TestBase.tearDown(self)
-
-    def test_char_type(self):
-        """Test that char-type variables are displayed correctly."""
-        d = {"CXX_SOURCES": "char.cpp"}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        self.generic_type_tester(set(["char"]), quotedDisplay=True)
-
-    def test_short_type(self):
-        """Test that short-type variables are displayed correctly."""
-        d = {"CXX_SOURCES": "short.cpp"}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        self.generic_type_tester(set(["short"]))
-
-    def test_int_type(self):
-        """Test that int-type variables are displayed correctly."""
-        d = {"CXX_SOURCES": "int.cpp"}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        self.generic_type_tester(set(["int"]))
-
-    def test_long_type(self):
-        """Test that long-type variables are displayed correctly."""
-        d = {"CXX_SOURCES": "long.cpp"}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        self.generic_type_tester(set(["long"]))
-
-    def test_long_long_type(self):
-        """Test that 'long long'-type variables are displayed correctly."""
-        d = {"CXX_SOURCES": "long_long.cpp"}
-        self.build(dictionary=d)
-        self.setTearDownCleanup(dictionary=d)
-        self.generic_type_tester(set(["long long"]))
diff --git a/lldb/test/API/types/Makefile b/lldb/test/API/types/Makefile
deleted file mode 100644
index d48ed7688a47e..0000000000000
--- a/lldb/test/API/types/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# Example:
-#
-# CXX_SOURCES := int.cpp
-
-include Makefile.rules
diff --git a/lldb/test/API/types/TestCharType.py 
b/lldb/test/API/types/TestCharType.py
deleted file mode 100644
index 049d40e5535bf..0000000000000
--- a/lldb/test/API/types/TestCharType.py
+++ /dev/null
@@ -1,27 +0,0 @@
-"""
-Test that variables of type char are displayed correctly.
-"""
-
-import AbstractBase
-
-from lldbsuite.test.decorators import *
-
-
-class CharTypeTestCase(AbstractBase.GenericTester):
-    def test_char_type(self):
-        """Test that char-type variables are displayed correctly."""
-        self.build_and_run("char.cpp", ["char"], qd=True)
-
-    @skipUnlessDarwin
-    def test_char_type_from_block(self):
-        """Test that char-type variables are displayed correctly from a 
block."""
-        self.build_and_run("char.cpp", ["char"], bc=True, qd=True)
-
-    def test_unsigned_char_type(self):
-        """Test that 'unsigned_char'-type variables are displayed correctly."""
-        self.build_and_run("unsigned_char.cpp", ["unsigned", "char"], qd=True)
-
-    @skipUnlessDarwin
-    def test_unsigned_char_type_from_block(self):
-        """Test that 'unsigned char'-type variables are displayed correctly 
from a block."""
-        self.build_and_run("unsigned_char.cpp", ["unsigned", "char"], bc=True, 
qd=True)
diff --git a/lldb/test/API/types/TestCharTypeExpr.py 
b/lldb/test/API/types/TestCharTypeExpr.py
deleted file mode 100644
index cc8b27f51b8d8..0000000000000
--- a/lldb/test/API/types/TestCharTypeExpr.py
+++ /dev/null
@@ -1,29 +0,0 @@
-"""
-Test that variable expressions of type char are evaluated correctly.
-"""
-
-import AbstractBase
-
-from lldbsuite.test.decorators import *
-
-
-class CharTypeExprTestCase(AbstractBase.GenericTester):
-    def test_char_type(self):
-        """Test that char-type variable expressions are evaluated correctly."""
-        self.build_and_run_expr("char.cpp", ["char"], qd=True)
-
-    @skipUnlessDarwin
-    def test_char_type_from_block(self):
-        """Test that char-type variables are displayed correctly from a 
block."""
-        self.build_and_run_expr("char.cpp", ["char"], bc=True, qd=True)
-
-    def test_unsigned_char_type(self):
-        """Test that 'unsigned_char'-type variable expressions are evaluated 
correctly."""
-        self.build_and_run_expr("unsigned_char.cpp", ["unsigned", "char"], 
qd=True)
-
-    @skipUnlessDarwin
-    def test_unsigned_char_type_from_block(self):
-        """Test that 'unsigned char'-type variables are displayed correctly 
from a block."""
-        self.build_and_run_expr(
-            "unsigned_char.cpp", ["unsigned", "char"], bc=True, qd=True
-        )
diff --git a/lldb/test/API/types/TestDoubleTypes.py 
b/lldb/test/API/types/TestDoubleTypes.py
deleted file mode 100644
index a863612cb0ddf..0000000000000
--- a/lldb/test/API/types/TestDoubleTypes.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""
-Test that variables of floating point types are displayed correctly.
-"""
-
-
-import AbstractBase
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class DoubleTypesTestCase(AbstractBase.GenericTester):
-    def test_double_type(self):
-        """Test that double-type variables are displayed correctly."""
-        self.build_and_run("double.cpp", set(["double"]))
-
-    @skipUnlessDarwin
-    def test_double_type_from_block(self):
-        """Test that double-type variables are displayed correctly from a 
block."""
-        self.build_and_run("double.cpp", set(["double"]), bc=True)
diff --git a/lldb/test/API/types/TestDoubleTypesExpr.py 
b/lldb/test/API/types/TestDoubleTypesExpr.py
deleted file mode 100644
index dd9bd68ae43ea..0000000000000
--- a/lldb/test/API/types/TestDoubleTypesExpr.py
+++ /dev/null
@@ -1,26 +0,0 @@
-"""
-Test that variable expressions of floating point types are evaluated correctly.
-"""
-
-
-import AbstractBase
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class DoubleTypesExprTestCase(AbstractBase.GenericTester):
-    # rdar://problem/8493023
-    # test/types failures for Test*TypesExpr.py: element offset computed wrong
-    # and sign error?
-
-    def test_double_type(self):
-        """Test that double-type variable expressions are evaluated 
correctly."""
-        self.build_and_run_expr("double.cpp", set(["double"]))
-
-    @skipUnlessDarwin
-    def test_double_type_from_block(self):
-        """Test that double-type variables are displayed correctly from a 
block."""
-        self.build_and_run_expr("double.cpp", set(["double"]), bc=...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/208402
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to