fjricci created this revision.

The existing cpp-level checks using PR_MPX_ENABLE_MANAGEMENT aren't sufficient,
as this isn't defined for linux kernel versions below 3.19.


https://reviews.llvm.org/D32719

Files:
  
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
  
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py


Index: 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
===================================================================
--- 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
+++ 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
@@ -19,13 +19,28 @@
 
     mydir = TestBase.compute_mydir(__file__)
 
+    def hasMPX(self):
+        if lldb.remote_platform:
+            self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
+            cpuinfo_path = "cpuinfo"
+            self.addTearDownHook(lambda: os.unlink("cpuinfo"))
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        with open(cpuinfo_path, 'r') as f:
+            return " mpx " in f.read()
+
     @skipIf(compiler="clang")
     @skipIf(oslist=no_match(['linux']))
     @skipIf(archs=no_match(['i386', 'x86_64']))
     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) 
#GCC version >= 5 supports Intel(R) MPX.
     def test_mpx_boundary_violation(self):
         """Test Intel(R) MPX bound violation signal."""
         self.build()
+
+        if !self.hasMPX():
+            return
+
         self.mpx_boundary_violation()
 
     def mpx_boundary_violation(self):
Index: 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
===================================================================
--- 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
+++ 
packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
@@ -22,13 +22,28 @@
     def setUp(self):
         TestBase.setUp(self)
 
+    def hasMPX(self):
+        if lldb.remote_platform:
+            self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
+            cpuinfo_path = "cpuinfo"
+            self.addTearDownHook(lambda: os.unlink("cpuinfo"))
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        with open(cpuinfo_path, 'r') as f:
+            return " mpx " in f.read()
+
     @skipIf(compiler="clang")
     @skipIf(oslist=no_match(['linux']))
     @skipIf(archs=no_match(['i386', 'x86_64']))
     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) 
#GCC version >= 5 supports Intel(R) MPX.
     def test_mpx_registers_with_example_code(self):
         """Test Intel(R) MPX registers with example code."""
         self.build()
+
+        if !self.hasMPX():
+            return
+
         self.mpx_registers_with_example_code()
 
     def mpx_registers_with_example_code(self):


Index: packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
+++ packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/mpx_bound_violation/TestBoundViolation.py
@@ -19,13 +19,28 @@
 
     mydir = TestBase.compute_mydir(__file__)
 
+    def hasMPX(self):
+        if lldb.remote_platform:
+            self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
+            cpuinfo_path = "cpuinfo"
+            self.addTearDownHook(lambda: os.unlink("cpuinfo"))
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        with open(cpuinfo_path, 'r') as f:
+            return " mpx " in f.read()
+
     @skipIf(compiler="clang")
     @skipIf(oslist=no_match(['linux']))
     @skipIf(archs=no_match(['i386', 'x86_64']))
     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
     def test_mpx_boundary_violation(self):
         """Test Intel(R) MPX bound violation signal."""
         self.build()
+
+        if !self.hasMPX():
+            return
+
         self.mpx_boundary_violation()
 
     def mpx_boundary_violation(self):
Index: packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
+++ packages/Python/lldbsuite/test/functionalities/register/intel_xtended_registers/TestMPXRegisters.py
@@ -22,13 +22,28 @@
     def setUp(self):
         TestBase.setUp(self)
 
+    def hasMPX(self):
+        if lldb.remote_platform:
+            self.runCmd('platform get-file "/proc/cpuinfo" "cpuinfo"')
+            cpuinfo_path = "cpuinfo"
+            self.addTearDownHook(lambda: os.unlink("cpuinfo"))
+        else:
+            cpuinfo_path = "/proc/cpuinfo"
+
+        with open(cpuinfo_path, 'r') as f:
+            return " mpx " in f.read()
+
     @skipIf(compiler="clang")
     @skipIf(oslist=no_match(['linux']))
     @skipIf(archs=no_match(['i386', 'x86_64']))
     @skipIf(oslist=["linux"], compiler="gcc", compiler_version=["<", "5"]) #GCC version >= 5 supports Intel(R) MPX.
     def test_mpx_registers_with_example_code(self):
         """Test Intel(R) MPX registers with example code."""
         self.build()
+
+        if !self.hasMPX():
+            return
+
         self.mpx_registers_with_example_code()
 
     def mpx_registers_with_example_code(self):
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to