[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
This revision was automatically updated to reflect the committed changes. Closed by commit rL325570: Avoid dirtying the source tree in breakpoint command tests (authored by labath, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D43464 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py @@ -0,0 +1,5 @@ +""" +A dummy module for testing the execution of various breakpoint commands. A +command will modify a global variable in this module and test will check its +value. +""" Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -11,18 +11,14 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class BreakpointCommandTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) -@classmethod -def classCleanup(cls): -"""Cleanup the test byproduct of breakpoint_command_sequence(self).""" -cls.RemoveTempFile("output.txt") -cls.RemoveTempFile("output2.txt") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" @@ -71,7 +67,7 @@ self.runCmd( "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") self.runCmd( -"breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") +"breakpoint command add -s python -o 'import side_effect; side_effect.one_liner = \"one liner was here\"' 2") self.runCmd( "breakpoint command add --python-function bktptcmd.function 3") @@ -104,9 +100,8 @@ "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs=["Breakpoint commands (Python):", - "here = open", - "here.write", - "here.close()"]) + "import side_effect", + "side_effect.one_liner"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs=["Breakpoint commands (Python):", "bktptcmd.function(frame, bp_loc, internal_dict)"]) @@ -151,40 +146,14 @@ extra_options="-f a.c", num_expected_locations=1) -# Run the program. Remove 'output.txt' if it exists. -self.RemoveTempFile("output.txt") -self.RemoveTempFile("output2.txt") +# Reset our canary variables and run the program. +side_effect.one_liner = None +side_effect.bktptcmd = None self.runCmd("run", RUN_SUCCEEDED) -# Check that the file 'output.txt' exists and contains the string -# "lldb". - -# The 'output.txt' file should now exist. -self.assertTrue( -os.path.isfile("output.txt"), -"'output.txt' exists due to breakpoint command for breakpoint 2.") -self.assertTrue( -os.path.isfile("output2.txt"), -"'output2.txt' exists due to breakpoint command for breakpoint 3.") - -# Read the output file produced by running the program. -with open('output.txt', 'r') as f: -output = f.read() - -self.expect( -output, -"File 'output.txt' and the content matches", -exe=False, -startstr="lldb") - -with open('output2.txt', 'r') as f: -output = f.read() - -self.expect( -output, -"File 'output2.txt'
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
aprantl added a comment. Awesome! https://reviews.llvm.org/D43464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
davide accepted this revision. davide added a comment. This revision is now accepted and ready to land. LGTM, thanks for doing this :) https://reviews.llvm.org/D43464 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
labath created this revision. labath added reviewers: jingham, aprantl. The paralelization patch exposed a bunch of cases where we were still touching the source tree (as these tests were now stepping on each others toes and being flaky). This patch removes such issues from breakpoint command tests. Since the only reason they were creating files was to indirectly test whether the breakpoint commands got executed (and plumbing the full build tree path to all places that needed it would be messy) I decided to modify the tests to check for a different side effect instead: modification of a global variable. This also makes the code simpler as checking the value of the global variable is easier, and there is nothing to clean up. As the tests aren't really doing anything debug-info related, I took the opportunity to also mark them as NO_DEBUG_INFO_TESTCASEs. https://reviews.llvm.org/D43464 Files: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py === --- /dev/null +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py @@ -0,0 +1,5 @@ +""" +A dummy module for testing the execution of various breakpoint commands. A +command will modify a global variable in this module and test will check its +value. +""" Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py === --- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py @@ -1,7 +1,5 @@ from __future__ import print_function - +import side_effect def function(frame, bp_loc, dict): -there = open("output2.txt", "w") -print("lldb", file=there) -there.close() +side_effect.bktptcmd = "function was here" Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py === --- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py +++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py @@ -12,12 +12,13 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class PythonBreakpointCommandSettingTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) -my_var = 10 +NO_DEBUG_INFO_TESTCASE = True @add_test_categories(['pyapi']) def test_step_out_python(self): @@ -69,12 +70,9 @@ self.assertTrue(got_one_in_B, "Failed to match the pattern in B") self.target.BreakpointDelete(no_files_bkpt.GetID()) -PythonBreakpointCommandSettingTestCase.my_var = 10 error = lldb.SBError() -error = body_bkpt.SetScriptCallbackBody("\ -import TestBreakpointCommandsFromPython\n\ -TestBreakpointCommandsFromPython.PythonBreakpointCommandSettingTestCase.my_var = 20\n\ -print('Hit breakpoint')") +error = body_bkpt.SetScriptCallbackBody( +"import side_effect; side_effect.callback = 'callback was here'") self.assertTrue( error.Success(), "Failed to set the script callback body: %s." % @@ -84,9 +82,9 @@ "command script import --allow-reload ./bktptcmd.py") func_bkpt.SetScriptCallbackFunction("bktptcmd.function") -# We will use the function that touches a text file, so remove it -# first: -self.RemoveTempFile("output2.txt") +# Clear out canary variables +side_effect.bktptcmd = None +side_effect.callback = None # Now launch the process, and do not stop at entry point. self.process = self.target.LaunchSimple( @@ -100,11 +98,5 @@ self.assertTrue(len(threads) == 1, "Stopped at inner breakpoint.") self.thread = threads[0] -self.assertTrue(PythonBreakpointCommandSettingTestCase.my_var == 20) - -# Check for the function version as well, which produced this file: -# Remember to clean up after ourselves... -self.assertTrue( -os.path.isfile("output2.txt"), -"'output2.txt' exists due to breakpoint command for breakpoint function.") -self.RemoveTempFile("output2.txt") +