[lldb/Reproducers] Fix/skip passive replay failures in python_api subdir
authorJonas Devlieghere <jonas@devlieghere.com>
Thu, 21 May 2020 06:23:50 +0000 (23:23 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Thu, 21 May 2020 06:23:53 +0000 (23:23 -0700)
Fixes or skips tests in the python_api subdirectory that were failing
with passive replay.

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py
lldb/test/API/python_api/process/TestProcessAPI.py
lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py
lldb/test/API/python_api/target/TestTargetAPI.py
lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py

index 0b53205..6515d78 100644 (file)
@@ -414,6 +414,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
       FileSpec oso_file(oso_path);
       ConstString oso_object;
       if (FileSystem::Instance().Exists(oso_file)) {
+        FileSystem::Instance().Collect(oso_file);
         // The modification time returned by the FS can have a higher precision
         // than the one from the CU.
         auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>(
index 8e2bc4a..49992f4 100644 (file)
@@ -19,6 +19,7 @@ class DisassembleRawDataTestCase(TestBase):
     @add_test_categories(['pyapi'])
     @no_debug_info_test
     @skipIfRemote
+    @skipIfReproducer # GetInstructions is not instrumented.
     def test_disassemble_raw_data(self):
         """Test disassembling raw bytes with the API."""
         # Create a target from the debugger.
index a32805b..9f30f6a 100644 (file)
@@ -10,6 +10,7 @@ class CommandRunInterpreterLegacyAPICase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
     mydir = TestBase.compute_mydir(__file__)
 
+    @skipIfReproducer # lldb::FileSP used in typemap cannot be instrumented.
     def setUp(self):
         TestBase.setUp(self)
 
@@ -47,6 +48,7 @@ class CommandRunInterpreterAPICase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
     mydir = TestBase.compute_mydir(__file__)
 
+    @skipIfReproducer # lldb::FileSP used in typemap cannot be instrumented.
     def setUp(self):
         TestBase.setUp(self)
 
index d26933a..4442284 100644 (file)
@@ -24,6 +24,7 @@ class ProcessAPITestCase(TestBase):
             "// Set break point at this line and check variable 'my_char'.")
 
     @add_test_categories(['pyapi'])
+    @skipIfReproducer # SBProcess::ReadMemory is not instrumented.
     def test_read_memory(self):
         """Test Python SBProcess.ReadMemory() API."""
         self.build()
@@ -122,6 +123,7 @@ class ProcessAPITestCase(TestBase):
                 "Result from SBProcess.ReadUnsignedFromMemory() does not match our expected output")
 
     @add_test_categories(['pyapi'])
+    @skipIfReproducer # SBProcess::WriteMemory is not instrumented.
     def test_write_memory(self):
         """Test Python SBProcess.WriteMemory() API."""
         self.build()
@@ -181,6 +183,7 @@ class ProcessAPITestCase(TestBase):
             startstr=b'a')
 
     @add_test_categories(['pyapi'])
+    @skipIfReproducer # SBProcess::WriteMemory is not instrumented.
     def test_access_my_int(self):
         """Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs."""
         self.build()
index fc26c3b..f18b8e3 100644 (file)
@@ -13,6 +13,7 @@ class TestReadMemCString(TestBase):
     mydir = TestBase.compute_mydir(__file__)
     NO_DEBUG_INFO_TESTCASE = True
 
+    @skipIfReproducer # SBProcess::ReadCStringFromMemory is not instrumented.
     def test_read_memory_c_string(self):
         """Test corner case behavior of SBProcess::ReadCStringFromMemory"""
         self.build()
index 6e5be6e..c5b9605 100644 (file)
@@ -122,6 +122,7 @@ class TargetAPITestCase(TestBase):
         self.assertEqual(data_section.name, data_section2.name)
 
     @add_test_categories(['pyapi'])
+    @skipIfReproducer # SBTarget::ReadMemory is not instrumented.
     def test_read_memory(self):
         d = {'EXE': 'b.out'}
         self.build(dictionary=d)
@@ -214,16 +215,18 @@ class TargetAPITestCase(TestBase):
         self.expect(my_global_var.GetValue(), exe=False,
                     startstr="'X'")
 
-        # While we are at it, let's also exercise the similar
-        # SBModule.FindGlobalVariables() API.
-        for m in target.module_iter():
-            if os.path.normpath(m.GetFileSpec().GetDirectory()) == self.getBuildDir() and m.GetFileSpec().GetFilename() == exe_name:
-                value_list = m.FindGlobalVariables(
-                    target, 'my_global_var_of_char_type', 3)
-                self.assertTrue(value_list.GetSize() == 1)
-                self.assertTrue(
-                    value_list.GetValueAtIndex(0).GetValue() == "'X'")
-                break
+
+        if not configuration.is_reproducer():
+            # While we are at it, let's also exercise the similar
+            # SBModule.FindGlobalVariables() API.
+            for m in target.module_iter():
+                if os.path.normpath(m.GetFileSpec().GetDirectory()) == self.getBuildDir() and m.GetFileSpec().GetFilename() == exe_name:
+                    value_list = m.FindGlobalVariables(
+                        target, 'my_global_var_of_char_type', 3)
+                    self.assertTrue(value_list.GetSize() == 1)
+                    self.assertTrue(
+                        value_list.GetValueAtIndex(0).GetValue() == "'X'")
+                    break
 
     def find_compile_units(self, exe):
         """Exercise SBTarget.FindCompileUnits() API."""
@@ -285,6 +288,7 @@ class TargetAPITestCase(TestBase):
     @not_remote_testsuite_ready
     @add_test_categories(['pyapi'])
     @no_debug_info_test
+    @skipIfReproducer # Inferior doesn't run during replay.
     def test_launch_new_process_and_redirect_stdout(self):
         """Exercise SBTaget.Launch() API with redirected stdout."""
         self.build()
index b7977f1..64391eb 100644 (file)
@@ -134,8 +134,7 @@ class ChangeValueAPITestCase(TestBase):
         # gcc may set multiple locations for breakpoint
         breakpoint.SetEnabled(False)
 
-        # Now continue, grab the stdout and make sure we changed the real
-        # values as well...
+        # Now continue.
         process.Continue()
 
         self.assertEquals(process.GetState(), lldb.eStateStopped)
@@ -145,11 +144,14 @@ class ChangeValueAPITestCase(TestBase):
             thread.IsValid(),
             "There should be a thread stopped due to breakpoint condition")
 
-        expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666"
-        stdout = process.GetSTDOUT(1000)
-        self.assertTrue(
-            expected_value in stdout,
-            "STDOUT showed changed values.")
+        # Grab the stdout and make sure we changed the real values as well.
+        # This doesn't work for reproducers as the inferior doesn't run.
+        if not configuration.is_reproducer():
+            expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666"
+            stdout = process.GetSTDOUT(1000)
+            self.assertTrue(
+                expected_value in stdout,
+                "STDOUT showed changed values.")
 
         # Finally, change the stack pointer to 0, and we should not make it to
         # our end breakpoint.