blob: f89dda4cb74164c7482656b779e727aebf614f88 [file] [log] [blame]
Johnny Chen77377772010-09-07 17:06:13 +00001"""
2Test lldb settings command.
3"""
4
Richard Mitton5c98c9a2013-10-03 01:50:35 +00005import os, time, re
Johnny Chen77377772010-09-07 17:06:13 +00006import unittest2
7import lldb
8from lldbtest import *
9
10class SettingsCommandTestCase(TestBase):
11
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Johnny Chen77377772010-09-07 17:06:13 +000013
Johnny Chen1a9f4dd2010-09-16 01:53:04 +000014 @classmethod
15 def classCleanup(cls):
Johnny Chena91b9472010-10-22 21:06:04 +000016 """Cleanup the test byproducts."""
Filipe Cabecinhas0eec15a2012-06-20 10:13:40 +000017 cls.RemoveTempFile("output1.txt")
18 cls.RemoveTempFile("output2.txt")
19 cls.RemoveTempFile("stderr.txt")
20 cls.RemoveTempFile("stdout.txt")
Johnny Chen1a9f4dd2010-09-16 01:53:04 +000021
Johnny Chen7fa6c952011-02-04 00:50:49 +000022 def test_apropos_should_also_search_settings_description(self):
23 """Test that 'apropos' command should also search descriptions for the settings variables."""
24
25 self.expect("apropos 'environment variable'",
Greg Clayton1d885962011-11-08 02:43:13 +000026 substrs = ["target.env-vars",
Johnny Chen7fa6c952011-02-04 00:50:49 +000027 "environment variables",
28 "executable's environment"])
29
Johnny Chen8cc80b22012-01-23 19:49:28 +000030 def test_append_target_env_vars(self):
Greg Clayton67cc0632012-08-22 17:17:09 +000031 """Test that 'append target.run-args' works."""
Johnny Chen8cc80b22012-01-23 19:49:28 +000032 # Append the env-vars.
33 self.runCmd('settings append target.env-vars MY_ENV_VAR=YES')
34 # And add hooks to restore the settings during tearDown().
35 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +000036 lambda: self.runCmd("settings clear target.env-vars"))
Johnny Chen8cc80b22012-01-23 19:49:28 +000037
38 # Check it immediately!
39 self.expect('settings show target.env-vars',
40 substrs = ['MY_ENV_VAR=YES'])
41
42 def test_insert_before_and_after_target_run_args(self):
43 """Test that 'insert-before/after target.run-args' works."""
44 # Set the run-args first.
45 self.runCmd('settings set target.run-args a b c')
46 # And add hooks to restore the settings during tearDown().
47 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +000048 lambda: self.runCmd("settings clear target.run-args"))
Johnny Chen8cc80b22012-01-23 19:49:28 +000049
50 # Now insert-before the index-0 element with '__a__'.
51 self.runCmd('settings insert-before target.run-args 0 __a__')
52 # And insert-after the index-1 element with '__A__'.
53 self.runCmd('settings insert-after target.run-args 1 __A__')
54 # Check it immediately!
55 self.expect('settings show target.run-args',
Greg Clayton67cc0632012-08-22 17:17:09 +000056 substrs = ['target.run-args',
Johnny Chen8cc80b22012-01-23 19:49:28 +000057 '[0]: "__a__"',
58 '[1]: "a"',
59 '[2]: "__A__"',
60 '[3]: "b"',
61 '[4]: "c"'])
62
Johnny Chen5928f642012-01-21 01:45:18 +000063 def test_replace_target_run_args(self):
64 """Test that 'replace target.run-args' works."""
65 # Set the run-args and then replace the index-0 element.
66 self.runCmd('settings set target.run-args a b c')
67 # And add hooks to restore the settings during tearDown().
68 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +000069 lambda: self.runCmd("settings clear target.run-args"))
Johnny Chen5928f642012-01-21 01:45:18 +000070
71 # Now replace the index-0 element with 'A', instead.
72 self.runCmd('settings replace target.run-args 0 A')
73 # Check it immediately!
74 self.expect('settings show target.run-args',
Greg Clayton67cc0632012-08-22 17:17:09 +000075 substrs = ['target.run-args (arguments) =',
Johnny Chen5928f642012-01-21 01:45:18 +000076 '[0]: "A"',
77 '[1]: "b"',
78 '[2]: "c"'])
79
Johnny Chen77377772010-09-07 17:06:13 +000080 def test_set_prompt(self):
81 """Test that 'set prompt' actually changes the prompt."""
Johnny Chen881c3712010-09-07 17:12:10 +000082
Johnny Chen23cb3712010-09-27 17:36:59 +000083 # Set prompt to 'lldb2'.
Greg Clayton00108402013-03-06 21:17:06 +000084 self.runCmd("settings set prompt 'lldb2 '")
Johnny Chen881c3712010-09-07 17:12:10 +000085
86 # Immediately test the setting.
Johnny Chena913ea42010-10-19 19:39:20 +000087 self.expect("settings show prompt", SETTING_MSG("prompt"),
Greg Clayton00108402013-03-06 21:17:06 +000088 startstr = 'prompt (string) = "lldb2 "')
Johnny Chen881c3712010-09-07 17:12:10 +000089
90 # The overall display should also reflect the new setting.
Johnny Chena913ea42010-10-19 19:39:20 +000091 self.expect("settings show", SETTING_MSG("prompt"),
Greg Clayton00108402013-03-06 21:17:06 +000092 substrs = ['prompt (string) = "lldb2 "'])
Johnny Chen77377772010-09-07 17:06:13 +000093
Johnny Chen23cb3712010-09-27 17:36:59 +000094 # Use '-r' option to reset to the original default prompt.
Greg Clayton67cc0632012-08-22 17:17:09 +000095 self.runCmd("settings clear prompt")
Johnny Chen23cb3712010-09-27 17:36:59 +000096
Johnny Chena37764b2010-09-07 17:31:05 +000097 def test_set_term_width(self):
98 """Test that 'set term-width' actually changes the term-width."""
99
Johnny Chena37764b2010-09-07 17:31:05 +0000100 self.runCmd("settings set term-width 70")
101
102 # Immediately test the setting.
Johnny Chena913ea42010-10-19 19:39:20 +0000103 self.expect("settings show term-width", SETTING_MSG("term-width"),
Greg Clayton4c207172011-04-19 22:32:36 +0000104 startstr = "term-width (int) = 70")
Johnny Chena37764b2010-09-07 17:31:05 +0000105
106 # The overall display should also reflect the new setting.
Johnny Chena913ea42010-10-19 19:39:20 +0000107 self.expect("settings show", SETTING_MSG("term-width"),
Greg Clayton4c207172011-04-19 22:32:36 +0000108 substrs = ["term-width (int) = 70"])
Johnny Chena37764b2010-09-07 17:31:05 +0000109
Johnny Chen41b780d2012-01-18 19:07:08 +0000110 #rdar://problem/10712130
Johnny Chen41b780d2012-01-18 19:07:08 +0000111 def test_set_frame_format(self):
112 """Test that 'set frame-format' with a backtick char in the format string works as well as fullpath."""
113 self.buildDefault()
114
115 exe = os.path.join(os.getcwd(), "a.out")
116 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
117
Filipe Cabecinhas5158f3d2012-05-18 21:35:43 +0000118 def cleanup():
Ashok Thirumurthibb82b842013-09-25 15:30:14 +0000119 self.runCmd("settings set frame-format %s" % self.format_string, check=False)
Filipe Cabecinhas5158f3d2012-05-18 21:35:43 +0000120
121 # Execute the cleanup function during test case tear down.
122 self.addTearDownHook(cleanup)
123
Ashok Thirumurthibb82b842013-09-25 15:30:14 +0000124 self.runCmd("settings show frame-format")
Richard Mitton5c98c9a2013-10-03 01:50:35 +0000125 m = re.match(
126 '^frame-format \(string\) = "(.*)\"$',
127 self.res.GetOutput())
128 self.assertTrue(m, "Bad settings string")
129 self.format_string = m.group(1)
Ashok Thirumurthibb82b842013-09-25 15:30:14 +0000130
131 # Change the default format to print function.name rather than function.name-with-args
132 format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\n"
Johnny Chen41b780d2012-01-18 19:07:08 +0000133 self.runCmd("settings set frame-format %s" % format_string)
134
135 # Immediately test the setting.
136 self.expect("settings show frame-format", SETTING_MSG("frame-format"),
137 substrs = [format_string])
138
139 self.runCmd("breakpoint set -n main")
140 self.runCmd("run")
141 self.expect("thread backtrace",
142 substrs = ["`main", os.getcwd()])
143
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000144 def test_set_auto_confirm(self):
145 """Test that after 'set auto-confirm true', manual confirmation should not kick in."""
146 self.buildDefault()
147
148 exe = os.path.join(os.getcwd(), "a.out")
149 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
150
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000151 self.runCmd("settings set auto-confirm true")
152
153 # Immediately test the setting.
Johnny Chena913ea42010-10-19 19:39:20 +0000154 self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"),
Greg Clayton4c207172011-04-19 22:32:36 +0000155 startstr = "auto-confirm (boolean) = true")
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000156
157 # Now 'breakpoint delete' should just work fine without confirmation
158 # prompt from the command interpreter.
159 self.runCmd("breakpoint set -n main")
160 self.expect("breakpoint delete",
161 startstr = "All breakpoints removed")
162
163 # Restore the original setting of auto-confirm.
Greg Clayton67cc0632012-08-22 17:17:09 +0000164 self.runCmd("settings clear auto-confirm")
Johnny Chena913ea42010-10-19 19:39:20 +0000165 self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"),
Greg Clayton4c207172011-04-19 22:32:36 +0000166 startstr = "auto-confirm (boolean) = false")
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000167
Ed Maste05081252013-12-10 14:25:28 +0000168 @unittest2.skipUnless(os.uname()[4] in ['amd64', 'i386', 'x86_64'], "requires x86 or x86_64")
Daniel Malead79ae052013-08-07 21:54:09 +0000169 def test_disassembler_settings(self):
170 """Test that user options for the disassembler take effect."""
171 self.buildDefault()
172
173 exe = os.path.join(os.getcwd(), "a.out")
174 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
175
176 # AT&T syntax
177 self.runCmd("settings set target.x86-disassembly-flavor att")
178 self.runCmd("settings set target.use-hex-immediates false")
179 self.expect("disassemble -n numberfn",
180 substrs = ["$90"])
181 self.runCmd("settings set target.use-hex-immediates true")
182 self.runCmd("settings set target.hex-immediate-style c")
183 self.expect("disassemble -n numberfn",
184 substrs = ["$0x5a"])
185 self.runCmd("settings set target.hex-immediate-style asm")
186 self.expect("disassemble -n numberfn",
187 substrs = ["$5ah"])
188
189 # Intel syntax
190 self.runCmd("settings set target.x86-disassembly-flavor intel")
191 self.runCmd("settings set target.use-hex-immediates false")
192 self.expect("disassemble -n numberfn",
193 substrs = ["90"])
194 self.runCmd("settings set target.use-hex-immediates true")
195 self.runCmd("settings set target.hex-immediate-style c")
196 self.expect("disassemble -n numberfn",
197 substrs = ["0x5a"])
198 self.runCmd("settings set target.hex-immediate-style asm")
199 self.expect("disassemble -n numberfn",
200 substrs = ["5ah"])
201
Johnny Chend5e111c2010-09-15 22:27:29 +0000202 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
Johnny Chen24086bc2012-04-06 19:54:10 +0000203 @dsym_test
Johnny Chena245f932010-12-14 23:43:29 +0000204 def test_run_args_and_env_vars_with_dsym(self):
Johnny Chend5e111c2010-09-15 22:27:29 +0000205 """Test that run-args and env-vars are passed to the launched process."""
206 self.buildDsym()
207 self.pass_run_args_and_env_vars()
208
Johnny Chen24086bc2012-04-06 19:54:10 +0000209 @dwarf_test
Johnny Chena245f932010-12-14 23:43:29 +0000210 def test_run_args_and_env_vars_with_dwarf(self):
Johnny Chend5e111c2010-09-15 22:27:29 +0000211 """Test that run-args and env-vars are passed to the launched process."""
212 self.buildDwarf()
213 self.pass_run_args_and_env_vars()
214
Daniel Maleae0f8f572013-08-26 23:57:52 +0000215 @not_remote_testsuite_ready
Johnny Chend5e111c2010-09-15 22:27:29 +0000216 def pass_run_args_and_env_vars(self):
217 """Test that run-args and env-vars are passed to the launched process."""
218 exe = os.path.join(os.getcwd(), "a.out")
219 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
220
221 # Set the run-args and the env-vars.
Johnny Chen707d8222010-10-19 23:40:13 +0000222 # And add hooks to restore the settings during tearDown().
Greg Clayton1d885962011-11-08 02:43:13 +0000223 self.runCmd('settings set target.run-args A B C')
Johnny Chen707d8222010-10-19 23:40:13 +0000224 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000225 lambda: self.runCmd("settings clear target.run-args"))
Greg Clayton1d885962011-11-08 02:43:13 +0000226 self.runCmd('settings set target.env-vars ["MY_ENV_VAR"]=YES')
Johnny Chen707d8222010-10-19 23:40:13 +0000227 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000228 lambda: self.runCmd("settings clear target.env-vars"))
Johnny Chend5e111c2010-09-15 22:27:29 +0000229
230 self.runCmd("run", RUN_SUCCEEDED)
231
232 # Read the output file produced by running the program.
Johnny Chena245f932010-12-14 23:43:29 +0000233 with open('output2.txt', 'r') as f:
Johnny Chen277c8f02010-10-08 22:10:42 +0000234 output = f.read()
Johnny Chend5e111c2010-09-15 22:27:29 +0000235
Johnny Chenbe7da212010-10-08 20:01:03 +0000236 self.expect(output, exe=False,
237 substrs = ["argv[1] matches",
238 "argv[2] matches",
239 "argv[3] matches",
240 "Environment variable 'MY_ENV_VAR' successfully passed."])
Johnny Chend5e111c2010-09-15 22:27:29 +0000241
Daniel Maleae0f8f572013-08-26 23:57:52 +0000242 @not_remote_testsuite_ready
Johnny Chen80554b82010-12-04 00:44:56 +0000243 def test_pass_host_env_vars(self):
244 """Test that the host env vars are passed to the launched process."""
245 self.buildDefault()
246
247 exe = os.path.join(os.getcwd(), "a.out")
248 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
249
250 # By default, inherit-env is 'true'.
Greg Clayton1d885962011-11-08 02:43:13 +0000251 self.expect('settings show target.inherit-env', "Default inherit-env is 'true'",
252 startstr = "target.inherit-env (boolean) = true")
Johnny Chen80554b82010-12-04 00:44:56 +0000253
254 # Set some host environment variables now.
255 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
256 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
257
Johnny Chena245f932010-12-14 23:43:29 +0000258 # This is the function to unset the two env variables set above.
259 def unset_env_variables():
260 os.environ.pop("MY_HOST_ENV_VAR1")
261 os.environ.pop("MY_HOST_ENV_VAR2")
262
263 self.addTearDownHook(unset_env_variables)
Johnny Chen80554b82010-12-04 00:44:56 +0000264 self.runCmd("run", RUN_SUCCEEDED)
265
266 # Read the output file produced by running the program.
Johnny Chena245f932010-12-14 23:43:29 +0000267 with open('output1.txt', 'r') as f:
Johnny Chen80554b82010-12-04 00:44:56 +0000268 output = f.read()
269
270 self.expect(output, exe=False,
271 substrs = ["The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.",
272 "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."])
273
Daniel Maleae0f8f572013-08-26 23:57:52 +0000274 @not_remote_testsuite_ready
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000275 def test_set_error_output_path(self):
Greg Clayton1d885962011-11-08 02:43:13 +0000276 """Test that setting target.error/output-path for the launched process works."""
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000277 self.buildDefault()
278
279 exe = os.path.join(os.getcwd(), "a.out")
280 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
281
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000282 # Set the error-path and output-path and verify both are set.
Greg Clayton1d885962011-11-08 02:43:13 +0000283 self.runCmd("settings set target.error-path stderr.txt")
284 self.runCmd("settings set target.output-path stdout.txt")
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000285 # And add hooks to restore the original settings during tearDown().
Johnny Chen707d8222010-10-19 23:40:13 +0000286 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000287 lambda: self.runCmd("settings clear target.output-path"))
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000288 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000289 lambda: self.runCmd("settings clear target.error-path"))
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000290
Greg Clayton1d885962011-11-08 02:43:13 +0000291 self.expect("settings show target.error-path",
292 SETTING_MSG("target.error-path"),
Todd Fiala6817df62014-04-25 21:04:48 +0000293 substrs = ['target.error-path (file) = ', 'stderr.txt"'])
Johnny Chen707d8222010-10-19 23:40:13 +0000294
Greg Clayton1d885962011-11-08 02:43:13 +0000295 self.expect("settings show target.output-path",
296 SETTING_MSG("target.output-path"),
Todd Fiala6817df62014-04-25 21:04:48 +0000297 substrs = ['target.output-path (file) = ', 'stdout.txt"'])
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000298
299 self.runCmd("run", RUN_SUCCEEDED)
300
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000301 # The 'stderr.txt' file should now exist.
302 self.assertTrue(os.path.isfile("stderr.txt"),
Greg Clayton1d885962011-11-08 02:43:13 +0000303 "'stderr.txt' exists due to target.error-path.")
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000304
305 # Read the output file produced by running the program.
306 with open('stderr.txt', 'r') as f:
307 output = f.read()
308
309 self.expect(output, exe=False,
310 startstr = "This message should go to standard error.")
311
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000312 # The 'stdout.txt' file should now exist.
313 self.assertTrue(os.path.isfile("stdout.txt"),
Greg Clayton1d885962011-11-08 02:43:13 +0000314 "'stdout.txt' exists due to target.output-path.")
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000315
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000316 # Read the output file produced by running the program.
Johnny Chenbe7da212010-10-08 20:01:03 +0000317 with open('stdout.txt', 'r') as f:
318 output = f.read()
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000319
Johnny Chenbe7da212010-10-08 20:01:03 +0000320 self.expect(output, exe=False,
321 startstr = "This message should go to standard out.")
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000322
Caroline Ticec9c235e2011-01-31 18:18:54 +0000323 def test_print_dictionary_setting(self):
Greg Clayton67cc0632012-08-22 17:17:09 +0000324 self.runCmd ("settings clear target.env-vars")
Greg Clayton1d885962011-11-08 02:43:13 +0000325 self.runCmd ("settings set target.env-vars [\"MY_VAR\"]=some-value")
326 self.expect ("settings show target.env-vars",
Greg Clayton4c207172011-04-19 22:32:36 +0000327 substrs = [ "MY_VAR=some-value" ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000328 self.runCmd ("settings clear target.env-vars")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000329
330 def test_print_array_setting(self):
Greg Clayton67cc0632012-08-22 17:17:09 +0000331 self.runCmd ("settings clear target.run-args")
Greg Clayton1d885962011-11-08 02:43:13 +0000332 self.runCmd ("settings set target.run-args gobbledy-gook")
333 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000334 substrs = [ '[0]: "gobbledy-gook"' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000335 self.runCmd ("settings clear target.run-args")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000336
337 def test_settings_with_quotes (self):
Greg Clayton67cc0632012-08-22 17:17:09 +0000338 self.runCmd ("settings clear target.run-args")
Greg Clayton1d885962011-11-08 02:43:13 +0000339 self.runCmd ("settings set target.run-args a b c")
340 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000341 substrs = [ '[0]: "a"',
342 '[1]: "b"',
343 '[2]: "c"' ])
Greg Clayton1d885962011-11-08 02:43:13 +0000344 self.runCmd ("settings set target.run-args 'a b c'")
345 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000346 substrs = [ '[0]: "a b c"' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000347 self.runCmd ("settings clear target.run-args")
348 self.runCmd ("settings clear target.env-vars")
Greg Clayton1d885962011-11-08 02:43:13 +0000349 self.runCmd ('settings set target.env-vars ["MY_FILE"]="this is a file name with spaces.txt"')
350 self.expect ("settings show target.env-vars",
Greg Clayton4c207172011-04-19 22:32:36 +0000351 substrs = [ 'MY_FILE=this is a file name with spaces.txt' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000352 self.runCmd ("settings clear target.env-vars")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000353
Greg Clayton00108402013-03-06 21:17:06 +0000354 def test_settings_with_trailing_whitespace (self):
355
356 # boolean
357 self.runCmd ("settings set target.skip-prologue true") # Set to known value
358 self.runCmd ("settings set target.skip-prologue false ") # Set to new value with trailing whitespace
359 # Make sure the setting was correctly set to "false"
360 self.expect ("settings show target.skip-prologue", SETTING_MSG("target.skip-prologue"),
361 startstr = "target.skip-prologue (boolean) = false")
362 self.runCmd("settings clear target.skip-prologue", check=False)
363 # integer
364 self.runCmd ("settings set term-width 70") # Set to known value
365 self.runCmd ("settings set term-width 60 \t") # Set to new value with trailing whitespaces
366 self.expect ("settings show term-width", SETTING_MSG("term-width"),
367 startstr = "term-width (int) = 60")
368 self.runCmd("settings clear term-width", check=False)
369 # string
370 self.runCmd ("settings set target.arg0 abc") # Set to known value
371 self.runCmd ("settings set target.arg0 cde\t ") # Set to new value with trailing whitespaces
372 self.expect ("settings show target.arg0", SETTING_MSG("target.arg0"),
373 startstr = 'target.arg0 (string) = "cde"')
374 self.runCmd("settings clear target.arg0", check=False)
375 # file
376 self.runCmd ("settings set target.output-path /bin/ls") # Set to known value
377 self.runCmd ("settings set target.output-path /bin/cat ") # Set to new value with trailing whitespaces
378 self.expect ("settings show target.output-path", SETTING_MSG("target.output-path"),
Daniel Malea7dadf492013-07-30 21:34:44 +0000379 startstr = 'target.output-path (file) = ', substrs=['/bin/cat"'])
Greg Clayton00108402013-03-06 21:17:06 +0000380 self.runCmd("settings clear target.output-path", check=False)
381 # enum
382 self.runCmd ("settings set stop-disassembly-display never") # Set to known value
383 self.runCmd ("settings set stop-disassembly-display always ") # Set to new value with trailing whitespaces
384 self.expect ("settings show stop-disassembly-display", SETTING_MSG("stop-disassembly-display"),
385 startstr = 'stop-disassembly-display (enum) = always')
386 self.runCmd("settings clear stop-disassembly-display", check=False)
387 # arguments
388 self.runCmd ("settings set target.run-args 1 2 3") # Set to known value
389 self.runCmd ("settings set target.run-args 3 4 5 ") # Set to new value with trailing whitespaces
390 self.expect ("settings show target.run-args", SETTING_MSG("target.run-args"),
391 substrs = [ 'target.run-args (arguments) =',
392 '[0]: "3"',
393 '[1]: "4"',
394 '[2]: "5"' ])
395 self.runCmd("settings clear target.run-args", check=False)
396 # dictionaries
397 self.runCmd ("settings clear target.env-vars") # Set to known value
398 self.runCmd ("settings set target.env-vars A=B C=D\t ") # Set to new value with trailing whitespaces
399 self.expect ("settings show target.env-vars", SETTING_MSG("target.env-vars"),
400 substrs = [ 'target.env-vars (dictionary of strings) =',
401 'A=B',
402 'C=D'])
403 self.runCmd("settings clear target.env-vars", check=False)
404
Caroline Ticeb904ca52011-03-10 22:29:54 +0000405 def test_all_settings_exist (self):
406 self.expect ("settings show",
Greg Clayton67cc0632012-08-22 17:17:09 +0000407 substrs = [ "auto-confirm",
408 "frame-format",
409 "notify-void",
410 "prompt",
411 "script-lang",
412 "stop-disassembly-count",
413 "stop-disassembly-display",
414 "stop-line-count-after",
415 "stop-line-count-before",
416 "term-width",
417 "thread-format",
418 "use-external-editor",
419 "target.default-arch",
420 "target.expr-prefix",
421 "target.prefer-dynamic-value",
422 "target.enable-synthetic-value",
423 "target.skip-prologue",
424 "target.source-map",
425 "target.exec-search-paths",
426 "target.max-children-count",
427 "target.max-string-summary-length",
428 "target.breakpoints-use-platform-avoid-list",
429 "target.run-args",
430 "target.env-vars",
431 "target.inherit-env",
432 "target.input-path",
433 "target.output-path",
434 "target.error-path",
435 "target.disable-aslr",
436 "target.disable-stdio",
Daniel Malead79ae052013-08-07 21:54:09 +0000437 "target.x86-disassembly-flavor",
438 "target.use-hex-immediates",
439 "target.hex-immediate-style",
Greg Clayton67cc0632012-08-22 17:17:09 +0000440 "target.process.disable-memory-cache",
441 "target.process.extra-startup-command",
442 "target.process.thread.step-avoid-regexp",
443 "target.process.thread.trace-thread"])
444
Caroline Ticeb904ca52011-03-10 22:29:54 +0000445
446
Johnny Chen77377772010-09-07 17:06:13 +0000447if __name__ == '__main__':
448 import atexit
449 lldb.SBDebugger.Initialize()
450 atexit.register(lambda: lldb.SBDebugger.Terminate())
451 unittest2.main()