[Lldb-commits] [lldb] r327625 - Next batch of test-tree-cleaning changes

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 15 08:20:35 PDT 2018


I don't seem to receive mails either (although I should).
Vedant is babysitting the bots this week. Vedant, are you receiving
blame mails or the mail notification is disabled altogether?

On Thu, Mar 15, 2018 at 8:06 AM, Pavel Labath <labath at google.com> wrote:
> Yes, it certainly looks that way. Taking a look now.
>
> PS: I didn't get any email about this.
>
> On Thu, 15 Mar 2018 at 15:04, Davide Italiano <dccitaliano at gmail.com> wrote:
>>
>> This is the most likely cause for the failures we're starting to see
>> on both our bots on greendragon.
>> Can you please take a look?
>>
>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/5791/
>>
>>
>> Thanks!
>>
>> --
>> Davide
>>
>> On Thu, Mar 15, 2018 at 6:47 AM, Pavel Labath via lldb-commits
>> <lldb-commits at lists.llvm.org> wrote:
>> > Author: labath
>> > Date: Thu Mar 15 06:47:09 2018
>> > New Revision: 327625
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=327625&view=rev
>> > Log:
>> > Next batch of test-tree-cleaning changes
>> >
>> > Summary:
>> > The changes here fall into several categories.
>> >
>> > - some tests were redirecting inferior stdout/err to a file. For these I
>> >   make sure we use an absolute path for the file. I also create a
>> >   lldbutil.read_file_on_target helper function to encapsulate the
>> >   differences between reading a file locally and remotely.
>> > - some tests were redirecting the pexpect I/O into a file. For these I
>> >   use a python StringIO object to avoid creating a file altogether.
>> > - the TestSettings inferior was creating a file. Here, I make sure the
>> >   inferior is launched with pwd=build-dir so that the files end up
>> >   created there.
>> > - lldb-mi --log (used by some tests) creates a log file in PWD without
>> >   the ability say differently. To make this work I make sure to run
>> >   lldb-mi with PWD=build_dir. This in turn necessitated a couple of
>> >   changes in other lldb-mi tests, which were using relative paths to
>> >   access the source tree.
>> >
>> > Reviewers: aprantl
>> >
>> > Subscribers: ki.stfu, mehdi_amini, lldb-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D44159
>> >
>> > Modified:
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
>> >     lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
>> >     lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
>> >
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -19,6 +19,7 @@ import six
>> >  class ProcessLaunchTestCase(TestBase):
>> >
>> >      mydir = TestBase.compute_mydir(__file__)
>> > +    NO_DEBUG_INFO_TESTCASE = True
>> >
>> >      def setUp(self):
>> >          # Call super's setUp().
>> > @@ -38,8 +39,8 @@ class ProcessLaunchTestCase(TestBase):
>> >                      patterns=["Current executable set to .*a.out"])
>> >
>> >          in_file = "input-file.txt"
>> > -        out_file = "output-test.out"
>> > -        err_file = "output-test.err"
>> > +        out_file = lldbutil.append_to_process_working_directory(self,
>> > "output-test.out")
>> > +        err_file = lldbutil.append_to_process_working_directory(self,
>> > "output-test.err")
>> >
>> >          # Make sure the output files do not exist before launching the
>> > process
>> >          try:
>> > @@ -52,8 +53,8 @@ class ProcessLaunchTestCase(TestBase):
>> >          except OSError:
>> >              pass
>> >
>> > -        launch_command = "process launch -i " + \
>> > -            in_file + " -o " + out_file + " -e " + err_file
>> > +        launch_command = "process launch -i '{0}' -o '{1}' -e '{2}' -w
>> > '{3}'".format(
>> > +                in_file, out_file, err_file,
>> > self.get_process_working_directory())
>> >
>> >          if lldb.remote_platform:
>> >              self.runCmd('platform put-file "{local}"
>> > "{remote}"'.format(
>> > @@ -62,55 +63,19 @@ class ProcessLaunchTestCase(TestBase):
>> >          self.expect(launch_command,
>> >                      patterns=["Process .* launched: .*a.out"])
>> >
>> > -        if lldb.remote_platform:
>> > -            self.runCmd('platform get-file "{remote}"
>> > "{local}"'.format(
>> > -                remote=out_file, local=out_file))
>> > -            self.runCmd('platform get-file "{remote}"
>> > "{local}"'.format(
>> > -                remote=err_file, local=err_file))
>> > -
>> >          success = True
>> >          err_msg = ""
>> >
>> > -        # Check to see if the 'stdout' file was created
>> > -        try:
>> > -            out_f = open(out_file)
>> > -        except IOError:
>> > +        out = lldbutil.read_file_on_target(self, out_file)
>> > +        if out != "This should go to stdout.\n":
>> >              success = False
>> > -            err_msg = err_msg + "   ERROR: stdout file was not
>> > created.\n"
>> > -        else:
>> > -            # Check to see if the 'stdout' file contains the right
>> > output
>> > -            line = out_f.readline()
>> > -            if line != "This should go to stdout.\n":
>> > -                success = False
>> > -                err_msg = err_msg + "    ERROR: stdout file does not
>> > contain correct output.\n"
>> > -                out_f.close()
>> > +            err_msg = err_msg + "    ERROR: stdout file does not
>> > contain correct output.\n"
>> >
>> > -        # Try to delete the 'stdout' file
>> > -        try:
>> > -            os.remove(out_file)
>> > -        except OSError:
>> > -            pass
>> >
>> > -        # Check to see if the 'stderr' file was created
>> > -        try:
>> > -            err_f = open(err_file)
>> > -        except IOError:
>> > +        err = lldbutil.read_file_on_target(self, err_file)
>> > +        if err != "This should go to stderr.\n":
>> >              success = False
>> > -            err_msg = err_msg + "     ERROR:  stderr file was not
>> > created.\n"
>> > -        else:
>> > -            # Check to see if the 'stderr' file contains the right
>> > output
>> > -            line = err_f.readline()
>> > -            if line != "This should go to stderr.\n":
>> > -                success = False
>> > -                err_msg = err_msg + "    ERROR: stderr file does not
>> > contain correct output.\n\
>> > -"
>> > -                err_f.close()
>> > -
>> > -        # Try to delete the 'stderr' file
>> > -        try:
>> > -            os.remove(err_file)
>> > -        except OSError:
>> > -            pass
>> > +            err_msg = err_msg + "    ERROR: stderr file does not
>> > contain correct output.\n"
>> >
>> >          if not success:
>> >              self.fail(err_msg)
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -10,7 +10,7 @@ import lldb
>> >  from lldbsuite.test.decorators import *
>> >  from lldbsuite.test.lldbtest import *
>> >  from lldbsuite.test import lldbutil
>> > -
>> > +import six
>> >
>> >  class SingleQuoteInCommandLineTestCase(TestBase):
>> >
>> > @@ -50,32 +50,24 @@ class SingleQuoteInCommandLineTestCase(T
>> >               self.getBuildArtifact(self.myexe)))
>> >          child = self.child
>> >          child.setecho(True)
>> > -        # Turn on logging for input/output to/from the child.
>> > -        with open('child_send.txt', 'w') as f_send:
>> > -            with open('child_read.txt', 'w') as f_read:
>> > -                child.logfile_send = f_send
>> > -                child.logfile_read = f_read
>> > -
>> > -                child.expect_exact(prompt)
>> > -
>> > -                child.send("help watchpoint")
>> > -                child.sendline('')
>> > -                child.expect_exact(prompt)
>> > +        child.logfile_send = send = six.StringIO()
>> > +        child.logfile_read = read = six.StringIO()
>> > +        child.expect_exact(prompt)
>> > +
>> > +        child.send("help watchpoint")
>> > +        child.sendline('')
>> > +        child.expect_exact(prompt)
>> >
>> >          # Now that the necessary logging is done, restore logfile to
>> > None to
>> >          # stop further logging.
>> >          child.logfile_send = None
>> >          child.logfile_read = None
>> >
>> > -        with open('child_send.txt', 'r') as fs:
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_send.txt:")
>> > -                print(fs.read())
>> > -        with open('child_read.txt', 'r') as fr:
>> > -            from_child = fr.read()
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_read.txt:")
>> > -                print(from_child)
>> > +        if self.TraceOn():
>> > +            print("\n\nContents of send")
>> > +            print(send.getvalue())
>> > +            print("\n\nContents of read")
>> > +            print(read.getvalue())
>> >
>> > -            self.expect(from_child, exe=False,
>> > -                        substrs=["Current executable set to"])
>> > +        self.expect(read.getvalue(), exe=False,
>> > +                    substrs=["Current executable set to"])
>> >
>> > Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > --- lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py (original)
>> > +++ lldb/trunk/packages/Python/lldbsuite/test/lldbutil.py Thu Mar 15
>> > 06:47:09 2018
>> > @@ -1321,6 +1321,21 @@ def skip_if_library_missing(test, target
>> >           target))
>> >
>> >
>> > +def read_file_on_target(test, remote):
>> > +    if lldb.remote_platform:
>> > +        local = test.getBuildArtifact("file_from_target")
>> > +        error = lldb.remote_platform.Get(lldb.SBFileSpec(remote,
>> > False),
>> > +                    lldb.SBFileSpec(local, True))
>> > +        test.assertTrue(error.Success(), "Reading file {0} failed:
>> > {1}".format(remote, error))
>> > +    else:
>> > +        local = remote
>> > +    with open(local, 'r') as f:
>> > +        return f.read()
>> > +
>> > +def read_file_from_process_wd(test, name):
>> > +    path = append_to_process_working_directory(test, name)
>> > +    return read_file_on_target(test, path)
>> > +
>> >  def wait_for_file_on_target(testcase, file_path, max_attempts=6):
>> >      for i in range(max_attempts):
>> >          err, retcode, msg = testcase.run_platform_command("ls %s" %
>> > file_path)
>> > @@ -1335,9 +1350,4 @@ def wait_for_file_on_target(testcase, fi
>> >              "File %s not found even after %d attempts." %
>> >              (file_path, max_attempts))
>> >
>> > -    err, retcode, data = testcase.run_platform_command("cat %s" %
>> > (file_path))
>> > -
>> > -    testcase.assertTrue(
>> > -        err.Success() and retcode == 0, "Failed to read file %s: %s,
>> > retcode: %d" %
>> > -        (file_path, err.GetCString(), retcode))
>> > -    return data
>> > +    return read_file_on_target(testcase, file_path)
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > --- lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
>> > (original)
>> > +++ lldb/trunk/packages/Python/lldbsuite/test/settings/TestSettings.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -17,16 +17,8 @@ from lldbsuite.test import lldbutil
>> >  class SettingsCommandTestCase(TestBase):
>> >
>> >      mydir = TestBase.compute_mydir(__file__)
>> > +    NO_DEBUG_INFO_TESTCASE = True
>> >
>> > -    @classmethod
>> > -    def classCleanup(cls):
>> > -        """Cleanup the test byproducts."""
>> > -        cls.RemoveTempFile("output1.txt")
>> > -        cls.RemoveTempFile("output2.txt")
>> > -        cls.RemoveTempFile("stderr.txt")
>> > -        cls.RemoveTempFile("stdout.txt")
>> > -
>> > -    @no_debug_info_test
>> >      def test_apropos_should_also_search_settings_description(self):
>> >          """Test that 'apropos' command should also search descriptions
>> > for the settings variables."""
>> >
>> > @@ -35,7 +27,6 @@ class SettingsCommandTestCase(TestBase):
>> >                               "environment variables",
>> >                               "executable's environment"])
>> >
>> > -    @no_debug_info_test
>> >      def test_append_target_env_vars(self):
>> >          """Test that 'append target.run-args' works."""
>> >          # Append the env-vars.
>> > @@ -48,7 +39,6 @@ class SettingsCommandTestCase(TestBase):
>> >          self.expect('settings show target.env-vars',
>> >                      substrs=['MY_ENV_VAR=YES'])
>> >
>> > -    @no_debug_info_test
>> >      def test_insert_before_and_after_target_run_args(self):
>> >          """Test that 'insert-before/after target.run-args' works."""
>> >          # Set the run-args first.
>> > @@ -70,7 +60,6 @@ class SettingsCommandTestCase(TestBase):
>> >                               '[3]: "b"',
>> >                               '[4]: "c"'])
>> >
>> > -    @no_debug_info_test
>> >      def test_replace_target_run_args(self):
>> >          """Test that 'replace target.run-args' works."""
>> >          # Set the run-args and then replace the index-0 element.
>> > @@ -88,7 +77,6 @@ class SettingsCommandTestCase(TestBase):
>> >                               '[1]: "b"',
>> >                               '[2]: "c"'])
>> >
>> > -    @no_debug_info_test
>> >      def test_set_prompt(self):
>> >          """Test that 'set prompt' actually changes the prompt."""
>> >
>> > @@ -106,7 +94,6 @@ class SettingsCommandTestCase(TestBase):
>> >          # Use '-r' option to reset to the original default prompt.
>> >          self.runCmd("settings clear prompt")
>> >
>> > -    @no_debug_info_test
>> >      def test_set_term_width(self):
>> >          """Test that 'set term-width' actually changes the
>> > term-width."""
>> >
>> > @@ -153,7 +140,8 @@ class SettingsCommandTestCase(TestBase):
>> >                      substrs=[format_string])
>> >
>> >          self.runCmd("breakpoint set -n main")
>> > -        self.runCmd("run")
>> > +        self.runCmd("process launch --working-dir
>> > '{0}'".format(self.get_process_working_directory()),
>> > +                RUN_SUCCEEDED)
>> >          self.expect("thread backtrace",
>> >                      substrs=["`main", self.getSourceDir()])
>> >
>> > @@ -231,13 +219,11 @@ class SettingsCommandTestCase(TestBase):
>> >          self.addTearDownHook(
>> >              lambda: self.runCmd("settings clear target.env-vars"))
>> >
>> > -        self.runCmd("run", RUN_SUCCEEDED)
>> > +        self.runCmd("process launch --working-dir
>> > '{0}'".format(self.get_process_working_directory()),
>> > +                RUN_SUCCEEDED)
>> >
>> >          # Read the output file produced by running the program.
>> > -        if lldb.remote_platform:
>> > -            self.runCmd('platform get-file "output2.txt"
>> > "output2.txt"')
>> > -        with open('output2.txt', 'r') as f:
>> > -            output = f.read()
>> > +        output = lldbutil.read_file_from_process_wd(self,
>> > "output2.txt")
>> >
>> >          self.expect(
>> >              output,
>> > @@ -272,13 +258,11 @@ class SettingsCommandTestCase(TestBase):
>> >              os.environ.pop("MY_HOST_ENV_VAR2")
>> >
>> >          self.addTearDownHook(unset_env_variables)
>> > -        self.runCmd("run", RUN_SUCCEEDED)
>> > +        self.runCmd("process launch --working-dir
>> > '{0}'".format(self.get_process_working_directory()),
>> > +                RUN_SUCCEEDED)
>> >
>> >          # Read the output file produced by running the program.
>> > -        if lldb.remote_platform:
>> > -            self.runCmd('platform get-file "output1.txt"
>> > "output1.txt"')
>> > -        with open('output1.txt', 'r') as f:
>> > -            output = f.read()
>> > +        output = lldbutil.read_file_from_process_wd(self,
>> > "output1.txt")
>> >
>> >          self.expect(
>> >              output,
>> > @@ -296,8 +280,10 @@ class SettingsCommandTestCase(TestBase):
>> >          self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
>> >
>> >          # Set the error-path and output-path and verify both are set.
>> > -        self.runCmd("settings set target.error-path stderr.txt")
>> > -        self.runCmd("settings set target.output-path stdout.txt")
>> > +        self.runCmd("settings set target.error-path '{0}'".format(
>> > +            lldbutil.append_to_process_working_directory(self,
>> > "stderr.txt")))
>> > +        self.runCmd("settings set target.output-path '{0}".format(
>> > +            lldbutil.append_to_process_working_directory(self,
>> > "stdout.txt")))
>> >          # And add hooks to restore the original settings during
>> > tearDown().
>> >          self.addTearDownHook(
>> >              lambda: self.runCmd("settings clear target.output-path"))
>> > @@ -306,44 +292,26 @@ class SettingsCommandTestCase(TestBase):
>> >
>> >          self.expect("settings show target.error-path",
>> >                      SETTING_MSG("target.error-path"),
>> > -                    substrs=['target.error-path (file) =
>> > "stderr.txt"'])
>> > +                    substrs=['target.error-path (file)',
>> > 'stderr.txt"'])
>> >
>> >          self.expect("settings show target.output-path",
>> >                      SETTING_MSG("target.output-path"),
>> > -                    substrs=['target.output-path (file) =
>> > "stdout.txt"'])
>> > -
>> > -        self.runCmd("run", RUN_SUCCEEDED)
>> > -
>> > -        if lldb.remote_platform:
>> > -            self.runCmd('platform get-file "stderr.txt" "stderr.txt"')
>> > -            self.runCmd('platform get-file "stdout.txt" "stdout.txt"')
>> > -
>> > -        # The 'stderr.txt' file should now exist.
>> > -        self.assertTrue(os.path.isfile("stderr.txt"),
>> > -                        "'stderr.txt' exists due to
>> > target.error-path.")
>> > +                    substrs=['target.output-path (file)',
>> > 'stdout.txt"'])
>> >
>> > -        # Read the output file produced by running the program.
>> > -        with open('stderr.txt', 'r') as f:
>> > -            output = f.read()
>> > +        self.runCmd("process launch --working-dir
>> > '{0}'".format(self.get_process_working_directory()),
>> > +                RUN_SUCCEEDED)
>> >
>> > +        output = lldbutil.read_file_from_process_wd(self, "stderr.txt")
>> >          message = "This message should go to standard error."
>> >          if lldbplatformutil.hasChattyStderr(self):
>> >              self.expect(output, exe=False, substrs=[message])
>> >          else:
>> >              self.expect(output, exe=False, startstr=message)
>> >
>> > -        # The 'stdout.txt' file should now exist.
>> > -        self.assertTrue(os.path.isfile("stdout.txt"),
>> > -                        "'stdout.txt' exists due to
>> > target.output-path.")
>> > -
>> > -        # Read the output file produced by running the program.
>> > -        with open('stdout.txt', 'r') as f:
>> > -            output = f.read()
>> > -
>> > +        output = lldbutil.read_file_from_process_wd(self, "stdout.txt")
>> >          self.expect(output, exe=False,
>> >                      startstr="This message should go to standard out.")
>> >
>> > -    @no_debug_info_test
>> >      def test_print_dictionary_setting(self):
>> >          self.runCmd("settings clear target.env-vars")
>> >          self.runCmd("settings set target.env-vars
>> > [\"MY_VAR\"]=some-value")
>> > @@ -351,7 +319,6 @@ class SettingsCommandTestCase(TestBase):
>> >                      substrs=["MY_VAR=some-value"])
>> >          self.runCmd("settings clear target.env-vars")
>> >
>> > -    @no_debug_info_test
>> >      def test_print_array_setting(self):
>> >          self.runCmd("settings clear target.run-args")
>> >          self.runCmd("settings set target.run-args gobbledy-gook")
>> > @@ -359,7 +326,6 @@ class SettingsCommandTestCase(TestBase):
>> >                      substrs=['[0]: "gobbledy-gook"'])
>> >          self.runCmd("settings clear target.run-args")
>> >
>> > -    @no_debug_info_test
>> >      def test_settings_with_quotes(self):
>> >          self.runCmd("settings clear target.run-args")
>> >          self.runCmd("settings set target.run-args a b c")
>> > @@ -392,7 +358,6 @@ class SettingsCommandTestCase(TestBase):
>> >                      'thread-format (format-string) = "abc def   "')
>> >          self.runCmd('settings clear thread-format')
>> >
>> > -    @no_debug_info_test
>> >      def test_settings_with_trailing_whitespace(self):
>> >
>> >          # boolean
>> > @@ -517,7 +482,6 @@ class SettingsCommandTestCase(TestBase):
>> >                      substrs=['disassembly-format (format-string) = "foo
>> > "'])
>> >          self.runCmd("settings clear disassembly-format", check=False)
>> >
>> > -    @no_debug_info_test
>> >      def test_all_settings_exist(self):
>> >          self.expect("settings show",
>> >                      substrs=["auto-confirm",
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/terminal/TestSTTYBeforeAndAfter.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -7,6 +7,7 @@ from __future__ import print_function
>> >
>> >  import os
>> >  import lldb
>> > +import six
>> >  from lldbsuite.test.decorators import *
>> >  from lldbsuite.test.lldbtest import *
>> >  from lldbsuite.test import lldbutil
>> > @@ -58,13 +59,10 @@ class TestSTTYBeforeAndAfter(TestBase):
>> >          child.expect(expect_prompt)
>> >
>> >          # Turn on loggings for input/output to/from the child.
>> > -        with open('child_send1.txt', 'w') as f_send1:
>> > -            with open('child_read1.txt', 'w') as f_read1:
>> > -                child.logfile_send = f_send1
>> > -                child.logfile_read = f_read1
>> > -
>> > -                child.sendline('stty -a')
>> > -                child.expect(expect_prompt)
>> > +        child.logfile_send = child_send1 = six.StringIO()
>> > +        child.logfile_read = child_read1 = six.StringIO()
>> > +        child.sendline('stty -a')
>> > +        child.expect(expect_prompt)
>> >
>> >          # Now that the stage1 logging is done, restore logfile to None
>> > to
>> >          # stop further logging.
>> > @@ -79,43 +77,30 @@ class TestSTTYBeforeAndAfter(TestBase):
>> >          child.sendline('quit')
>> >          child.expect(expect_prompt)
>> >
>> > -        with open('child_send2.txt', 'w') as f_send2:
>> > -            with open('child_read2.txt', 'w') as f_read2:
>> > -                child.logfile_send = f_send2
>> > -                child.logfile_read = f_read2
>> > -
>> > -                child.sendline('stty -a')
>> > -                child.expect(expect_prompt)
>> > +        child.logfile_send = child_send2 = six.StringIO()
>> > +        child.logfile_read = child_read2 = six.StringIO()
>> > +        child.sendline('stty -a')
>> > +        child.expect(expect_prompt)
>> >
>> > -                child.sendline('exit')
>> > +        child.sendline('exit')
>> >
>> >          # Now that the stage2 logging is done, restore logfile to None
>> > to
>> >          # stop further logging.
>> >          child.logfile_send = None
>> >          child.logfile_read = None
>> >
>> > -        with open('child_send1.txt', 'r') as fs:
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_send1.txt:")
>> > -                print(fs.read())
>> > -        with open('child_read1.txt', 'r') as fr:
>> > -            from_child1 = fr.read()
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_read1.txt:")
>> > -                print(from_child1)
>> > -
>> > -        with open('child_send2.txt', 'r') as fs:
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_send2.txt:")
>> > -                print(fs.read())
>> > -        with open('child_read2.txt', 'r') as fr:
>> > -            from_child2 = fr.read()
>> > -            if self.TraceOn():
>> > -                print("\n\nContents of child_read2.txt:")
>> > -                print(from_child2)
>> > +        if self.TraceOn():
>> > +            print("\n\nContents of child_send1:")
>> > +            print(child_send1.getvalue())
>> > +            print("\n\nContents of child_read1:")
>> > +            print(child_read1.getvalue())
>> > +            print("\n\nContents of child_send2:")
>> > +            print(child_send2.getvalue())
>> > +            print("\n\nContents of child_read2:")
>> > +            print(child_read2.getvalue())
>> >
>> > -        stty_output1_lines = from_child1.splitlines()
>> > -        stty_output2_lines = from_child2.splitlines()
>> > +        stty_output1_lines = child_read1.getvalue().splitlines()
>> > +        stty_output2_lines = child_read2.getvalue().splitlines()
>> >          zipped = list(zip(stty_output1_lines, stty_output2_lines))
>> >          for tuple in zipped:
>> >              if self.TraceOn():
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/TestMiFile.py Thu
>> > Mar 15 06:47:09 2018
>> > @@ -59,7 +59,7 @@ class MiFileTestCase(lldbmi_testcase.MiT
>> >
>> >          # Test that -file-exec-and-symbols works for relative path
>> >          import os
>> > -        path = os.path.relpath(self.myexe)
>> > +        path = os.path.relpath(self.myexe, self.getBuildDir())
>> >          self.runCmd("-file-exec-and-symbols %s" % path)
>> >          self.expect("\^done")
>> >
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/lldbmi_testcase.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -44,7 +44,7 @@ class MiTestCaseBase(Base):
>> >      def spawnLldbMi(self, args=None):
>> >          import pexpect
>> >          self.child = pexpect.spawn("%s --interpreter %s" % (
>> > -            self.lldbMiExec, args if args else ""))
>> > +            self.lldbMiExec, args if args else ""),
>> > cwd=self.getBuildDir())
>> >          self.child.setecho(True)
>> >          self.mylog = self.getBuildArtifact("child.log")
>> >          self.child.logfile_read = open(self.mylog, "w")
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/startup_options/TestMiStartupOptions.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -94,7 +94,7 @@ class MiStartupOptionsTestCase(lldbmi_te
>> >          """Test that 'lldb-mi --interpreter %s' loads executable which
>> > is specified via relative path."""
>> >
>> >          # Prepare path to executable
>> > -        path = os.path.relpath(self.myexe)
>> > +        path = os.path.relpath(self.myexe, self.getBuildDir())
>> >          self.spawnLldbMi(args="%s" % path)
>> >
>> >          # Test that the executable is loaded when file was specified
>> > using
>> > @@ -258,7 +258,7 @@ class MiStartupOptionsTestCase(lldbmi_te
>> >      def test_lldbmi_log_option(self):
>> >          """Test that 'lldb-mi --log' creates a log file in the current
>> > directory."""
>> >
>> > -        logDirectory = "."
>> > +        logDirectory = self.getBuildDir()
>> >          self.spawnLldbMi(args="%s --log" % self.myexe)
>> >
>> >          # Test that the executable is loaded when file was specified
>> >
>> > Modified:
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py?rev=327625&r1=327624&r2=327625&view=diff
>> >
>> > ==============================================================================
>> > ---
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
>> > (original)
>> > +++
>> > lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/syntax/TestMiSyntax.py
>> > Thu Mar 15 06:47:09 2018
>> > @@ -47,7 +47,7 @@ class MiSyntaxTestCase(lldbmi_testcase.M
>> >          """Test that 'lldb-mi --interpreter' handles complicated
>> > strings."""
>> >
>> >          # Create an alias for myexe
>> > -        complicated_myexe = "C--mpl-x file's`s @#$%^&*()_+-={}[]| name"
>> > +        complicated_myexe = self.getBuildArtifact("C--mpl-x file's`s
>> > @#$%^&*()_+-={}[]| name")
>> >          os.symlink(self.myexe, complicated_myexe)
>> >          self.addTearDownHook(lambda: os.unlink(complicated_myexe))
>> >
>> >
>> >
>> > _______________________________________________
>> > lldb-commits mailing list
>> > lldb-commits at lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


More information about the lldb-commits mailing list