[Lldb-commits] [lldb] 9bee13f - Move targetHasSVE function to lldbtest.py

Muhammad Omair Javaid via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 6 20:38:02 PDT 2020


Author: Muhammad Omair Javaid
Date: 2020-09-07T08:37:39+05:00
New Revision: 9bee13f89085b08e4e8e24c51c11526fcef6efe1

URL: https://github.com/llvm/llvm-project/commit/9bee13f89085b08e4e8e24c51c11526fcef6efe1
DIFF: https://github.com/llvm/llvm-project/commit/9bee13f89085b08e4e8e24c51c11526fcef6efe1.diff

LOG: Move targetHasSVE function to lldbtest.py

targetHasSVE helper function was added to test for availability of SVE support
by connected platform. We now intend to use this function in other testcases
and I am moving it to a generic location in lldbtest.py to allow usage by
other upcoming testcases.

Reviewed By: labath

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

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/lldbtest.py
    lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index e1966692b03c..73faa2aef5e4 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1293,6 +1293,29 @@ def isPPC64le(self):
             return True
         return False
 
+    def isAArch64SVE(self):
+        triple = self.dbg.GetSelectedPlatform().GetTriple()
+
+        # TODO other platforms, please implement this function
+        if not re.match(".*-.*-linux", triple):
+            return False
+
+        # Need to do something 
diff erent for non-Linux/Android targets
+        cpuinfo_path = self.getBuildArtifact("cpuinfo")
+        if configuration.lldb_platform_name:
+            self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        try:
+            f = open(cpuinfo_path, 'r')
+            cpuinfo = f.read()
+            f.close()
+        except:
+            return False
+
+        return " sve " in cpuinfo
+
     def getArchitecture(self):
         """Returns the architecture in effect the test suite is running with."""
         module = builder_module()

diff  --git a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
index 42d30f6cb113..b243a6692d85 100644
--- a/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
+++ b/lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_static_config/TestSVERegisters.py
@@ -10,29 +10,6 @@
 
 class RegisterCommandsTestCase(TestBase):
 
-    def targetHasSVE(self):
-        triple = self.dbg.GetSelectedPlatform().GetTriple()
-
-        # TODO other platforms, please implement this function
-        if not re.match(".*-.*-linux", triple):
-            return False
-
-        # Need to do something 
diff erent for non-Linux/Android targets
-        cpuinfo_path = self.getBuildArtifact("cpuinfo")
-        if configuration.lldb_platform_name:
-            self.runCmd('platform get-file "/proc/cpuinfo" ' + cpuinfo_path)
-        else:
-            cpuinfo_path = "/proc/cpuinfo"
-
-        try:
-            f = open(cpuinfo_path, 'r')
-            cpuinfo = f.read()
-            f.close()
-        except:
-            return False
-
-        return " sve " in cpuinfo
-
     def check_sve_register_size(self, set, name, expected):
         reg_value = set.GetChildMemberWithName(name)
         self.assertTrue(reg_value.IsValid(),
@@ -53,7 +30,7 @@ def test_sve_registers_configuration(self):
         exe = self.getBuildArtifact("a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
-        if not self.targetHasSVE():
+        if not self.isAArch64SVE():
             self.skipTest('SVE registers must be supported.')
 
         lldbutil.run_break_set_by_file_and_line(
@@ -108,7 +85,7 @@ def test_sve_registers_read_write(self):
         exe = self.getBuildArtifact("a.out")
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
-        if not self.targetHasSVE():
+        if not self.isAArch64SVE():
             self.skipTest('SVE registers must be supported.')
 
         lldbutil.run_break_set_by_file_and_line(


        


More information about the lldb-commits mailing list