blob: c7cfe6c71376bdb333f0e61ad9400e7930d21a03 [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(
Greg Clayton554f68d2015-02-04 22:00:53 +0000126 '^frame-format \(format-string\) = "(.*)\"$',
Richard Mitton5c98c9a2013-10-03 01:50:35 +0000127 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
Zachary Turner045fde52014-07-18 01:02:02 +0000168 @unittest2.skipUnless(os.name != "nt" and 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
215 def pass_run_args_and_env_vars(self):
216 """Test that run-args and env-vars are passed to the launched process."""
217 exe = os.path.join(os.getcwd(), "a.out")
218 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
219
220 # Set the run-args and the env-vars.
Johnny Chen707d8222010-10-19 23:40:13 +0000221 # And add hooks to restore the settings during tearDown().
Greg Clayton1d885962011-11-08 02:43:13 +0000222 self.runCmd('settings set target.run-args A B C')
Johnny Chen707d8222010-10-19 23:40:13 +0000223 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000224 lambda: self.runCmd("settings clear target.run-args"))
Greg Clayton1d885962011-11-08 02:43:13 +0000225 self.runCmd('settings set target.env-vars ["MY_ENV_VAR"]=YES')
Johnny Chen707d8222010-10-19 23:40:13 +0000226 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000227 lambda: self.runCmd("settings clear target.env-vars"))
Johnny Chend5e111c2010-09-15 22:27:29 +0000228
229 self.runCmd("run", RUN_SUCCEEDED)
230
231 # Read the output file produced by running the program.
Vince Harroned7cbb22015-02-18 23:14:49 +0000232 if lldb.remote_platform:
233 self.runCmd('platform get-file "output2.txt" "output2.txt"')
Johnny Chena245f932010-12-14 23:43:29 +0000234 with open('output2.txt', 'r') as f:
Johnny Chen277c8f02010-10-08 22:10:42 +0000235 output = f.read()
Johnny Chend5e111c2010-09-15 22:27:29 +0000236
Johnny Chenbe7da212010-10-08 20:01:03 +0000237 self.expect(output, exe=False,
238 substrs = ["argv[1] matches",
239 "argv[2] matches",
240 "argv[3] matches",
241 "Environment variable 'MY_ENV_VAR' successfully passed."])
Johnny Chend5e111c2010-09-15 22:27:29 +0000242
Vince Harroned7cbb22015-02-18 23:14:49 +0000243 @skipIfRemote # it doesn't make sense to send host env to remote target
Johnny Chen80554b82010-12-04 00:44:56 +0000244 def test_pass_host_env_vars(self):
245 """Test that the host env vars are passed to the launched process."""
246 self.buildDefault()
247
248 exe = os.path.join(os.getcwd(), "a.out")
249 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
250
251 # By default, inherit-env is 'true'.
Greg Clayton1d885962011-11-08 02:43:13 +0000252 self.expect('settings show target.inherit-env', "Default inherit-env is 'true'",
253 startstr = "target.inherit-env (boolean) = true")
Johnny Chen80554b82010-12-04 00:44:56 +0000254
255 # Set some host environment variables now.
256 os.environ["MY_HOST_ENV_VAR1"] = "VAR1"
257 os.environ["MY_HOST_ENV_VAR2"] = "VAR2"
258
Johnny Chena245f932010-12-14 23:43:29 +0000259 # This is the function to unset the two env variables set above.
260 def unset_env_variables():
261 os.environ.pop("MY_HOST_ENV_VAR1")
262 os.environ.pop("MY_HOST_ENV_VAR2")
263
264 self.addTearDownHook(unset_env_variables)
Johnny Chen80554b82010-12-04 00:44:56 +0000265 self.runCmd("run", RUN_SUCCEEDED)
266
267 # Read the output file produced by running the program.
Vince Harroned7cbb22015-02-18 23:14:49 +0000268 if lldb.remote_platform:
269 self.runCmd('platform get-file "output1.txt" "output1.txt"')
Johnny Chena245f932010-12-14 23:43:29 +0000270 with open('output1.txt', 'r') as f:
Johnny Chen80554b82010-12-04 00:44:56 +0000271 output = f.read()
272
273 self.expect(output, exe=False,
274 substrs = ["The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.",
275 "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."])
276
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000277 def test_set_error_output_path(self):
Greg Clayton1d885962011-11-08 02:43:13 +0000278 """Test that setting target.error/output-path for the launched process works."""
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000279 self.buildDefault()
280
281 exe = os.path.join(os.getcwd(), "a.out")
282 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
283
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000284 # Set the error-path and output-path and verify both are set.
Greg Clayton1d885962011-11-08 02:43:13 +0000285 self.runCmd("settings set target.error-path stderr.txt")
286 self.runCmd("settings set target.output-path stdout.txt")
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000287 # And add hooks to restore the original settings during tearDown().
Johnny Chen707d8222010-10-19 23:40:13 +0000288 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000289 lambda: self.runCmd("settings clear target.output-path"))
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000290 self.addTearDownHook(
Greg Clayton67cc0632012-08-22 17:17:09 +0000291 lambda: self.runCmd("settings clear target.error-path"))
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000292
Greg Clayton1d885962011-11-08 02:43:13 +0000293 self.expect("settings show target.error-path",
294 SETTING_MSG("target.error-path"),
Vince Harron1f4706c2015-02-18 23:12:26 +0000295 substrs = ['target.error-path (file) = "stderr.txt"'])
Johnny Chen707d8222010-10-19 23:40:13 +0000296
Greg Clayton1d885962011-11-08 02:43:13 +0000297 self.expect("settings show target.output-path",
298 SETTING_MSG("target.output-path"),
Vince Harron1f4706c2015-02-18 23:12:26 +0000299 substrs = ['target.output-path (file) = "stdout.txt"'])
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000300
301 self.runCmd("run", RUN_SUCCEEDED)
302
Vince Harron1f4706c2015-02-18 23:12:26 +0000303 if lldb.remote_platform:
304 self.runCmd('platform get-file "stderr.txt" "stderr.txt"')
305 self.runCmd('platform get-file "stdout.txt" "stdout.txt"')
306
307
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000308 # The 'stderr.txt' file should now exist.
309 self.assertTrue(os.path.isfile("stderr.txt"),
Greg Clayton1d885962011-11-08 02:43:13 +0000310 "'stderr.txt' exists due to target.error-path.")
Johnny Chen93b0c8b2011-01-25 17:39:43 +0000311
312 # Read the output file produced by running the program.
313 with open('stderr.txt', 'r') as f:
314 output = f.read()
315
316 self.expect(output, exe=False,
317 startstr = "This message should go to standard error.")
318
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000319 # The 'stdout.txt' file should now exist.
320 self.assertTrue(os.path.isfile("stdout.txt"),
Greg Clayton1d885962011-11-08 02:43:13 +0000321 "'stdout.txt' exists due to target.output-path.")
Johnny Chen3e9c50c2010-10-18 17:51:45 +0000322
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000323 # Read the output file produced by running the program.
Johnny Chenbe7da212010-10-08 20:01:03 +0000324 with open('stdout.txt', 'r') as f:
325 output = f.read()
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000326
Johnny Chenbe7da212010-10-08 20:01:03 +0000327 self.expect(output, exe=False,
328 startstr = "This message should go to standard out.")
Johnny Chen2fcc0e52010-09-16 18:26:06 +0000329
Caroline Ticec9c235e2011-01-31 18:18:54 +0000330 def test_print_dictionary_setting(self):
Greg Clayton67cc0632012-08-22 17:17:09 +0000331 self.runCmd ("settings clear target.env-vars")
Greg Clayton1d885962011-11-08 02:43:13 +0000332 self.runCmd ("settings set target.env-vars [\"MY_VAR\"]=some-value")
333 self.expect ("settings show target.env-vars",
Greg Clayton4c207172011-04-19 22:32:36 +0000334 substrs = [ "MY_VAR=some-value" ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000335 self.runCmd ("settings clear target.env-vars")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000336
337 def test_print_array_setting(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 gobbledy-gook")
340 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000341 substrs = [ '[0]: "gobbledy-gook"' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000342 self.runCmd ("settings clear target.run-args")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000343
344 def test_settings_with_quotes (self):
Greg Clayton67cc0632012-08-22 17:17:09 +0000345 self.runCmd ("settings clear target.run-args")
Greg Clayton1d885962011-11-08 02:43:13 +0000346 self.runCmd ("settings set target.run-args a b c")
347 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000348 substrs = [ '[0]: "a"',
349 '[1]: "b"',
350 '[2]: "c"' ])
Greg Clayton1d885962011-11-08 02:43:13 +0000351 self.runCmd ("settings set target.run-args 'a b c'")
352 self.expect ("settings show target.run-args",
Greg Clayton4c207172011-04-19 22:32:36 +0000353 substrs = [ '[0]: "a b c"' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000354 self.runCmd ("settings clear target.run-args")
355 self.runCmd ("settings clear target.env-vars")
Greg Clayton1d885962011-11-08 02:43:13 +0000356 self.runCmd ('settings set target.env-vars ["MY_FILE"]="this is a file name with spaces.txt"')
357 self.expect ("settings show target.env-vars",
Greg Clayton4c207172011-04-19 22:32:36 +0000358 substrs = [ 'MY_FILE=this is a file name with spaces.txt' ])
Greg Clayton67cc0632012-08-22 17:17:09 +0000359 self.runCmd ("settings clear target.env-vars")
Caroline Ticec9c235e2011-01-31 18:18:54 +0000360
Greg Clayton00108402013-03-06 21:17:06 +0000361 def test_settings_with_trailing_whitespace (self):
362
363 # boolean
364 self.runCmd ("settings set target.skip-prologue true") # Set to known value
365 self.runCmd ("settings set target.skip-prologue false ") # Set to new value with trailing whitespace
366 # Make sure the setting was correctly set to "false"
367 self.expect ("settings show target.skip-prologue", SETTING_MSG("target.skip-prologue"),
368 startstr = "target.skip-prologue (boolean) = false")
369 self.runCmd("settings clear target.skip-prologue", check=False)
370 # integer
371 self.runCmd ("settings set term-width 70") # Set to known value
372 self.runCmd ("settings set term-width 60 \t") # Set to new value with trailing whitespaces
373 self.expect ("settings show term-width", SETTING_MSG("term-width"),
374 startstr = "term-width (int) = 60")
375 self.runCmd("settings clear term-width", check=False)
376 # string
377 self.runCmd ("settings set target.arg0 abc") # Set to known value
378 self.runCmd ("settings set target.arg0 cde\t ") # Set to new value with trailing whitespaces
379 self.expect ("settings show target.arg0", SETTING_MSG("target.arg0"),
380 startstr = 'target.arg0 (string) = "cde"')
381 self.runCmd("settings clear target.arg0", check=False)
382 # file
Zachary Turner83887fb2015-01-21 00:40:27 +0000383 path1 = os.path.join(os.getcwd(), "path1.txt")
384 path2 = os.path.join(os.getcwd(), "path2.txt")
385 self.runCmd ("settings set target.output-path %s" % path1) # Set to known value
Greg Clayton00108402013-03-06 21:17:06 +0000386 self.expect ("settings show target.output-path", SETTING_MSG("target.output-path"),
Zachary Turner83887fb2015-01-21 00:40:27 +0000387 startstr = 'target.output-path (file) = ', substrs=[path1])
388 self.runCmd ("settings set target.output-path %s " % path2) # Set to new value with trailing whitespaces
389 self.expect ("settings show target.output-path", SETTING_MSG("target.output-path"),
390 startstr = 'target.output-path (file) = ', substrs=[path2])
Greg Clayton00108402013-03-06 21:17:06 +0000391 self.runCmd("settings clear target.output-path", check=False)
392 # enum
393 self.runCmd ("settings set stop-disassembly-display never") # Set to known value
394 self.runCmd ("settings set stop-disassembly-display always ") # Set to new value with trailing whitespaces
395 self.expect ("settings show stop-disassembly-display", SETTING_MSG("stop-disassembly-display"),
396 startstr = 'stop-disassembly-display (enum) = always')
397 self.runCmd("settings clear stop-disassembly-display", check=False)
398 # arguments
399 self.runCmd ("settings set target.run-args 1 2 3") # Set to known value
400 self.runCmd ("settings set target.run-args 3 4 5 ") # Set to new value with trailing whitespaces
401 self.expect ("settings show target.run-args", SETTING_MSG("target.run-args"),
402 substrs = [ 'target.run-args (arguments) =',
403 '[0]: "3"',
404 '[1]: "4"',
405 '[2]: "5"' ])
Pavel Labathdf50f942015-02-16 13:13:39 +0000406 self.runCmd ("settings set target.run-args 1 2 3") # Set to known value
407 self.runCmd ("settings set target.run-args 3 \ \ ") # Set to new value with trailing whitespaces
408 self.expect ("settings show target.run-args", SETTING_MSG("target.run-args"),
409 substrs = [ 'target.run-args (arguments) =',
410 '[0]: "3"',
411 '[1]: " "',
412 '[2]: " "' ])
Greg Clayton00108402013-03-06 21:17:06 +0000413 self.runCmd("settings clear target.run-args", check=False)
414 # dictionaries
415 self.runCmd ("settings clear target.env-vars") # Set to known value
416 self.runCmd ("settings set target.env-vars A=B C=D\t ") # Set to new value with trailing whitespaces
417 self.expect ("settings show target.env-vars", SETTING_MSG("target.env-vars"),
418 substrs = [ 'target.env-vars (dictionary of strings) =',
419 'A=B',
420 'C=D'])
421 self.runCmd("settings clear target.env-vars", check=False)
Pavel Labathdf50f942015-02-16 13:13:39 +0000422 # regex
423 self.runCmd ("settings clear target.process.thread.step-avoid-regexp") # Set to known value
424 self.runCmd ("settings set target.process.thread.step-avoid-regexp foo\\ ") # Set to new value with trailing whitespaces
425 self.expect ("settings show target.process.thread.step-avoid-regexp",
426 SETTING_MSG("target.process.thread.step-avoid-regexp"),
427 substrs = [ 'target.process.thread.step-avoid-regexp (regex) = foo\\ '])
428 self.runCmd("settings clear target.process.thread.step-avoid-regexp", check=False)
429 # format-string
430 self.runCmd ("settings clear disassembly-format") # Set to known value
431 self.runCmd ("settings set disassembly-format foo ") # Set to new value with trailing whitespaces
432 self.expect ("settings show disassembly-format",
433 SETTING_MSG("disassembly-format"),
434 substrs = [ 'disassembly-format (format-string) = "foo "'])
435 self.runCmd("settings clear disassembly-format", check=False)
Greg Clayton00108402013-03-06 21:17:06 +0000436
Caroline Ticeb904ca52011-03-10 22:29:54 +0000437 def test_all_settings_exist (self):
438 self.expect ("settings show",
Greg Clayton67cc0632012-08-22 17:17:09 +0000439 substrs = [ "auto-confirm",
440 "frame-format",
441 "notify-void",
442 "prompt",
443 "script-lang",
444 "stop-disassembly-count",
445 "stop-disassembly-display",
446 "stop-line-count-after",
447 "stop-line-count-before",
448 "term-width",
449 "thread-format",
450 "use-external-editor",
451 "target.default-arch",
452 "target.expr-prefix",
453 "target.prefer-dynamic-value",
454 "target.enable-synthetic-value",
455 "target.skip-prologue",
456 "target.source-map",
457 "target.exec-search-paths",
458 "target.max-children-count",
459 "target.max-string-summary-length",
460 "target.breakpoints-use-platform-avoid-list",
461 "target.run-args",
462 "target.env-vars",
463 "target.inherit-env",
464 "target.input-path",
465 "target.output-path",
466 "target.error-path",
467 "target.disable-aslr",
468 "target.disable-stdio",
Daniel Malead79ae052013-08-07 21:54:09 +0000469 "target.x86-disassembly-flavor",
470 "target.use-hex-immediates",
471 "target.hex-immediate-style",
Greg Clayton67cc0632012-08-22 17:17:09 +0000472 "target.process.disable-memory-cache",
473 "target.process.extra-startup-command",
474 "target.process.thread.step-avoid-regexp",
475 "target.process.thread.trace-thread"])
476
Caroline Ticeb904ca52011-03-10 22:29:54 +0000477
478
Johnny Chen77377772010-09-07 17:06:13 +0000479if __name__ == '__main__':
480 import atexit
481 lldb.SBDebugger.Initialize()
482 atexit.register(lambda: lldb.SBDebugger.Terminate())
483 unittest2.main()