]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / single-quote-in-filename-to-lldb / TestSingleQuoteInFilename.py
1 """
2 Test the lldb command line takes a filename with single quote chars.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import lldb
10 from lldbsuite.test.decorators import *
11 from lldbsuite.test.lldbtest import *
12 from lldbsuite.test import lldbutil
13
14
15 class SingleQuoteInCommandLineTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18     myexe = "path with '09/a.out"
19
20     @classmethod
21     def classCleanup(cls):
22         """Cleanup the test byproducts."""
23         try:
24             os.remove("child_send.txt")
25             os.remove("child_read.txt")
26             os.remove(cls.myexe)
27         except:
28             pass
29
30     @expectedFailureAll(
31         hostoslist=["windows"],
32         bugnumber="llvm.org/pr22274: need a pexpect replacement for windows")
33     @no_debug_info_test
34     def test_lldb_invocation_with_single_quote_in_filename(self):
35         """Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it."""
36         import pexpect
37         self.buildDefault()
38         system([["cp", "a.out", "\"%s\"" % self.myexe]])
39
40         # The default lldb prompt.
41         prompt = "(lldb) "
42
43         # So that the child gets torn down after the test.
44         self.child = pexpect.spawn(
45             '%s %s "%s"' %
46             (lldbtest_config.lldbExec, self.lldbOption, self.myexe))
47         child = self.child
48         child.setecho(True)
49         # Turn on logging for input/output to/from the child.
50         with open('child_send.txt', 'w') as f_send:
51             with open('child_read.txt', 'w') as f_read:
52                 child.logfile_send = f_send
53                 child.logfile_read = f_read
54
55                 child.expect_exact(prompt)
56
57                 child.send("help watchpoint")
58                 child.sendline('')
59                 child.expect_exact(prompt)
60
61         # Now that the necessary logging is done, restore logfile to None to
62         # stop further logging.
63         child.logfile_send = None
64         child.logfile_read = None
65
66         with open('child_send.txt', 'r') as fs:
67             if self.TraceOn():
68                 print("\n\nContents of child_send.txt:")
69                 print(fs.read())
70         with open('child_read.txt', 'r') as fr:
71             from_child = fr.read()
72             if self.TraceOn():
73                 print("\n\nContents of child_read.txt:")
74                 print(from_child)
75
76             self.expect(from_child, exe=False,
77                         substrs=["Current executable set to"])