From 7606a54363d3d90802977c9f5fb9046d4d780835 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 20 May 2020 23:23:50 -0700 Subject: [PATCH] [lldb/Reproducers] Fix/skip passive replay failures in python_api subdir Fixes or skips tests in the python_api subdirectory that were failing with passive replay. --- .../SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 1 + .../disassemble-raw-data/TestDisassembleRawData.py | 1 + .../interpreter/TestRunCommandInterpreterAPI.py | 2 ++ lldb/test/API/python_api/process/TestProcessAPI.py | 3 +++ .../process/read-mem-cstring/TestReadMemCString.py | 1 + lldb/test/API/python_api/target/TestTargetAPI.py | 24 +++++++++++++--------- .../value/change_values/TestChangeValueAPI.py | 16 ++++++++------- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 0b53205..6515d78 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -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( diff --git a/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py b/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py index 8e2bc4ac..49992f4 100644 --- a/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -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. diff --git a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py index a32805b..9f30f6a 100644 --- a/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py +++ b/lldb/test/API/python_api/interpreter/TestRunCommandInterpreterAPI.py @@ -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) diff --git a/lldb/test/API/python_api/process/TestProcessAPI.py b/lldb/test/API/python_api/process/TestProcessAPI.py index d26933a..4442284 100644 --- a/lldb/test/API/python_api/process/TestProcessAPI.py +++ b/lldb/test/API/python_api/process/TestProcessAPI.py @@ -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() diff --git a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py index fc26c3b..f18b8e3 100644 --- a/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py +++ b/lldb/test/API/python_api/process/read-mem-cstring/TestReadMemCString.py @@ -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() diff --git a/lldb/test/API/python_api/target/TestTargetAPI.py b/lldb/test/API/python_api/target/TestTargetAPI.py index 6e5be6e..c5b9605 100644 --- a/lldb/test/API/python_api/target/TestTargetAPI.py +++ b/lldb/test/API/python_api/target/TestTargetAPI.py @@ -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() diff --git a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py index b7977f1..64391eb 100644 --- a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py +++ b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py @@ -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. -- 2.7.4