Johnny Chen | 7737777 | 2010-09-07 17:06:13 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test lldb settings command. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
| 9 | |
| 10 | class SettingsCommandTestCase(TestBase): |
| 11 | |
| 12 | mydir = "settings" |
| 13 | |
Johnny Chen | 1a9f4dd | 2010-09-16 01:53:04 +0000 | [diff] [blame] | 14 | @classmethod |
| 15 | def classCleanup(cls): |
Johnny Chen | a91b947 | 2010-10-22 21:06:04 +0000 | [diff] [blame] | 16 | """Cleanup the test byproducts.""" |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 17 | system(["/bin/sh", "-c", "rm -f output1.txt"]) |
| 18 | system(["/bin/sh", "-c", "rm -f output2.txt"]) |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 19 | system(["/bin/sh", "-c", "rm -f stderr.txt"]) |
Johnny Chen | 138532a | 2010-10-08 00:47:30 +0000 | [diff] [blame] | 20 | system(["/bin/sh", "-c", "rm -f stdout.txt"]) |
Johnny Chen | 1a9f4dd | 2010-09-16 01:53:04 +0000 | [diff] [blame] | 21 | |
Johnny Chen | 7fa6c95 | 2011-02-04 00:50:49 +0000 | [diff] [blame] | 22 | 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 Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 26 | substrs = ["target.env-vars", |
Johnny Chen | 7fa6c95 | 2011-02-04 00:50:49 +0000 | [diff] [blame] | 27 | "environment variables", |
| 28 | "executable's environment"]) |
| 29 | |
Johnny Chen | 8cc80b2 | 2012-01-23 19:49:28 +0000 | [diff] [blame] | 30 | def test_append_target_env_vars(self): |
| 31 | """Test that 'replace target.run-args' works.""" |
| 32 | # 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( |
| 36 | lambda: self.runCmd("settings set -r target.env-vars")) |
| 37 | |
| 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( |
| 48 | lambda: self.runCmd("settings set -r target.run-args")) |
| 49 | |
| 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', |
| 56 | substrs = ['target.run-args (array) = ', |
| 57 | '[0]: "__a__"', |
| 58 | '[1]: "a"', |
| 59 | '[2]: "__A__"', |
| 60 | '[3]: "b"', |
| 61 | '[4]: "c"']) |
| 62 | |
Johnny Chen | 5928f64 | 2012-01-21 01:45:18 +0000 | [diff] [blame] | 63 | 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( |
| 69 | lambda: self.runCmd("settings set -r target.run-args")) |
| 70 | |
| 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', |
| 75 | substrs = ['target.run-args (array) = ', |
| 76 | '[0]: "A"', |
| 77 | '[1]: "b"', |
| 78 | '[2]: "c"']) |
| 79 | |
Johnny Chen | 7737777 | 2010-09-07 17:06:13 +0000 | [diff] [blame] | 80 | def test_set_prompt(self): |
| 81 | """Test that 'set prompt' actually changes the prompt.""" |
Johnny Chen | 881c371 | 2010-09-07 17:12:10 +0000 | [diff] [blame] | 82 | |
Johnny Chen | 23cb371 | 2010-09-27 17:36:59 +0000 | [diff] [blame] | 83 | # Set prompt to 'lldb2'. |
Johnny Chen | 622220b | 2010-12-20 21:29:34 +0000 | [diff] [blame] | 84 | self.runCmd("settings set prompt lldb2") |
Johnny Chen | 881c371 | 2010-09-07 17:12:10 +0000 | [diff] [blame] | 85 | |
| 86 | # Immediately test the setting. |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 87 | self.expect("settings show prompt", SETTING_MSG("prompt"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 88 | startstr = 'prompt (string) = "lldb2"') |
Johnny Chen | 881c371 | 2010-09-07 17:12:10 +0000 | [diff] [blame] | 89 | |
| 90 | # The overall display should also reflect the new setting. |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 91 | self.expect("settings show", SETTING_MSG("prompt"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 92 | substrs = ['prompt (string) = "lldb2"']) |
Johnny Chen | 7737777 | 2010-09-07 17:06:13 +0000 | [diff] [blame] | 93 | |
Johnny Chen | 23cb371 | 2010-09-27 17:36:59 +0000 | [diff] [blame] | 94 | # Use '-r' option to reset to the original default prompt. |
| 95 | self.runCmd("settings set -r prompt") |
| 96 | |
Johnny Chen | a37764b | 2010-09-07 17:31:05 +0000 | [diff] [blame] | 97 | def test_set_term_width(self): |
| 98 | """Test that 'set term-width' actually changes the term-width.""" |
| 99 | |
Johnny Chen | a37764b | 2010-09-07 17:31:05 +0000 | [diff] [blame] | 100 | self.runCmd("settings set term-width 70") |
| 101 | |
| 102 | # Immediately test the setting. |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 103 | self.expect("settings show term-width", SETTING_MSG("term-width"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 104 | startstr = "term-width (int) = 70") |
Johnny Chen | a37764b | 2010-09-07 17:31:05 +0000 | [diff] [blame] | 105 | |
| 106 | # The overall display should also reflect the new setting. |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 107 | self.expect("settings show", SETTING_MSG("term-width"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 108 | substrs = ["term-width (int) = 70"]) |
Johnny Chen | a37764b | 2010-09-07 17:31:05 +0000 | [diff] [blame] | 109 | |
Johnny Chen | 41b780d | 2012-01-18 19:07:08 +0000 | [diff] [blame] | 110 | #rdar://problem/10712130 |
Johnny Chen | 41b780d | 2012-01-18 19:07:08 +0000 | [diff] [blame] | 111 | 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 Cabecinhas | 5158f3d | 2012-05-18 21:35:43 +0000 | [diff] [blame^] | 118 | def cleanup(): |
| 119 | format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n" |
| 120 | self.runCmd("settings set frame-format %s" % format_string, check=False) |
| 121 | self.runCmd('command unalias hello', check=False) |
| 122 | |
| 123 | # Execute the cleanup function during test case tear down. |
| 124 | self.addTearDownHook(cleanup) |
| 125 | |
Johnny Chen | 41b780d | 2012-01-18 19:07:08 +0000 | [diff] [blame] | 126 | format_string = "frame #${frame.index}: ${frame.pc}{ ${module.file.basename}`${function.name-with-args}{${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\n" |
| 127 | self.runCmd("settings set frame-format %s" % format_string) |
| 128 | |
| 129 | # Immediately test the setting. |
| 130 | self.expect("settings show frame-format", SETTING_MSG("frame-format"), |
| 131 | substrs = [format_string]) |
| 132 | |
| 133 | self.runCmd("breakpoint set -n main") |
| 134 | self.runCmd("run") |
| 135 | self.expect("thread backtrace", |
| 136 | substrs = ["`main", os.getcwd()]) |
| 137 | |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 138 | def test_set_auto_confirm(self): |
| 139 | """Test that after 'set auto-confirm true', manual confirmation should not kick in.""" |
| 140 | self.buildDefault() |
| 141 | |
| 142 | exe = os.path.join(os.getcwd(), "a.out") |
| 143 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 144 | |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 145 | self.runCmd("settings set auto-confirm true") |
| 146 | |
| 147 | # Immediately test the setting. |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 148 | self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 149 | startstr = "auto-confirm (boolean) = true") |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 150 | |
| 151 | # Now 'breakpoint delete' should just work fine without confirmation |
| 152 | # prompt from the command interpreter. |
| 153 | self.runCmd("breakpoint set -n main") |
| 154 | self.expect("breakpoint delete", |
| 155 | startstr = "All breakpoints removed") |
| 156 | |
| 157 | # Restore the original setting of auto-confirm. |
| 158 | self.runCmd("settings set -r auto-confirm") |
Johnny Chen | a913ea4 | 2010-10-19 19:39:20 +0000 | [diff] [blame] | 159 | self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"), |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 160 | startstr = "auto-confirm (boolean) = false") |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 161 | |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 162 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 163 | @dsym_test |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 164 | def test_run_args_and_env_vars_with_dsym(self): |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 165 | """Test that run-args and env-vars are passed to the launched process.""" |
| 166 | self.buildDsym() |
| 167 | self.pass_run_args_and_env_vars() |
| 168 | |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 169 | @dwarf_test |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 170 | def test_run_args_and_env_vars_with_dwarf(self): |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 171 | """Test that run-args and env-vars are passed to the launched process.""" |
| 172 | self.buildDwarf() |
| 173 | self.pass_run_args_and_env_vars() |
| 174 | |
| 175 | def pass_run_args_and_env_vars(self): |
| 176 | """Test that run-args and env-vars are passed to the launched process.""" |
| 177 | exe = os.path.join(os.getcwd(), "a.out") |
| 178 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 179 | |
| 180 | # Set the run-args and the env-vars. |
Johnny Chen | 707d822 | 2010-10-19 23:40:13 +0000 | [diff] [blame] | 181 | # And add hooks to restore the settings during tearDown(). |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 182 | self.runCmd('settings set target.run-args A B C') |
Johnny Chen | 707d822 | 2010-10-19 23:40:13 +0000 | [diff] [blame] | 183 | self.addTearDownHook( |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 184 | lambda: self.runCmd("settings set -r target.run-args")) |
| 185 | self.runCmd('settings set target.env-vars ["MY_ENV_VAR"]=YES') |
Johnny Chen | 707d822 | 2010-10-19 23:40:13 +0000 | [diff] [blame] | 186 | self.addTearDownHook( |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 187 | lambda: self.runCmd("settings set -r target.env-vars")) |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 188 | |
| 189 | self.runCmd("run", RUN_SUCCEEDED) |
| 190 | |
| 191 | # Read the output file produced by running the program. |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 192 | with open('output2.txt', 'r') as f: |
Johnny Chen | 277c8f0 | 2010-10-08 22:10:42 +0000 | [diff] [blame] | 193 | output = f.read() |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 194 | |
Johnny Chen | be7da21 | 2010-10-08 20:01:03 +0000 | [diff] [blame] | 195 | self.expect(output, exe=False, |
| 196 | substrs = ["argv[1] matches", |
| 197 | "argv[2] matches", |
| 198 | "argv[3] matches", |
| 199 | "Environment variable 'MY_ENV_VAR' successfully passed."]) |
Johnny Chen | d5e111c | 2010-09-15 22:27:29 +0000 | [diff] [blame] | 200 | |
Johnny Chen | 80554b8 | 2010-12-04 00:44:56 +0000 | [diff] [blame] | 201 | def test_pass_host_env_vars(self): |
| 202 | """Test that the host env vars are passed to the launched process.""" |
| 203 | self.buildDefault() |
| 204 | |
| 205 | exe = os.path.join(os.getcwd(), "a.out") |
| 206 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 207 | |
| 208 | # By default, inherit-env is 'true'. |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 209 | self.expect('settings show target.inherit-env', "Default inherit-env is 'true'", |
| 210 | startstr = "target.inherit-env (boolean) = true") |
Johnny Chen | 80554b8 | 2010-12-04 00:44:56 +0000 | [diff] [blame] | 211 | |
| 212 | # Set some host environment variables now. |
| 213 | os.environ["MY_HOST_ENV_VAR1"] = "VAR1" |
| 214 | os.environ["MY_HOST_ENV_VAR2"] = "VAR2" |
| 215 | |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 216 | # This is the function to unset the two env variables set above. |
| 217 | def unset_env_variables(): |
| 218 | os.environ.pop("MY_HOST_ENV_VAR1") |
| 219 | os.environ.pop("MY_HOST_ENV_VAR2") |
| 220 | |
| 221 | self.addTearDownHook(unset_env_variables) |
Johnny Chen | 80554b8 | 2010-12-04 00:44:56 +0000 | [diff] [blame] | 222 | self.runCmd("run", RUN_SUCCEEDED) |
| 223 | |
| 224 | # Read the output file produced by running the program. |
Johnny Chen | a245f93 | 2010-12-14 23:43:29 +0000 | [diff] [blame] | 225 | with open('output1.txt', 'r') as f: |
Johnny Chen | 80554b8 | 2010-12-04 00:44:56 +0000 | [diff] [blame] | 226 | output = f.read() |
| 227 | |
| 228 | self.expect(output, exe=False, |
| 229 | substrs = ["The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.", |
| 230 | "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed."]) |
| 231 | |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 232 | def test_set_error_output_path(self): |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 233 | """Test that setting target.error/output-path for the launched process works.""" |
Johnny Chen | 2fcc0e5 | 2010-09-16 18:26:06 +0000 | [diff] [blame] | 234 | self.buildDefault() |
| 235 | |
| 236 | exe = os.path.join(os.getcwd(), "a.out") |
| 237 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 238 | |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 239 | # Set the error-path and output-path and verify both are set. |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 240 | self.runCmd("settings set target.error-path stderr.txt") |
| 241 | self.runCmd("settings set target.output-path stdout.txt") |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 242 | # And add hooks to restore the original settings during tearDown(). |
Johnny Chen | 707d822 | 2010-10-19 23:40:13 +0000 | [diff] [blame] | 243 | self.addTearDownHook( |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 244 | lambda: self.runCmd("settings set -r target.output-path")) |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 245 | self.addTearDownHook( |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 246 | lambda: self.runCmd("settings set -r target.error-path")) |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 247 | |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 248 | self.expect("settings show target.error-path", |
| 249 | SETTING_MSG("target.error-path"), |
| 250 | startstr = 'target.error-path (string) = "stderr.txt"') |
Johnny Chen | 707d822 | 2010-10-19 23:40:13 +0000 | [diff] [blame] | 251 | |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 252 | self.expect("settings show target.output-path", |
| 253 | SETTING_MSG("target.output-path"), |
| 254 | startstr = 'target.output-path (string) = "stdout.txt"') |
Johnny Chen | 2fcc0e5 | 2010-09-16 18:26:06 +0000 | [diff] [blame] | 255 | |
| 256 | self.runCmd("run", RUN_SUCCEEDED) |
| 257 | |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 258 | # The 'stderr.txt' file should now exist. |
| 259 | self.assertTrue(os.path.isfile("stderr.txt"), |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 260 | "'stderr.txt' exists due to target.error-path.") |
Johnny Chen | 93b0c8b | 2011-01-25 17:39:43 +0000 | [diff] [blame] | 261 | |
| 262 | # Read the output file produced by running the program. |
| 263 | with open('stderr.txt', 'r') as f: |
| 264 | output = f.read() |
| 265 | |
| 266 | self.expect(output, exe=False, |
| 267 | startstr = "This message should go to standard error.") |
| 268 | |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 269 | # The 'stdout.txt' file should now exist. |
| 270 | self.assertTrue(os.path.isfile("stdout.txt"), |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 271 | "'stdout.txt' exists due to target.output-path.") |
Johnny Chen | 3e9c50c | 2010-10-18 17:51:45 +0000 | [diff] [blame] | 272 | |
Johnny Chen | 2fcc0e5 | 2010-09-16 18:26:06 +0000 | [diff] [blame] | 273 | # Read the output file produced by running the program. |
Johnny Chen | be7da21 | 2010-10-08 20:01:03 +0000 | [diff] [blame] | 274 | with open('stdout.txt', 'r') as f: |
| 275 | output = f.read() |
Johnny Chen | 2fcc0e5 | 2010-09-16 18:26:06 +0000 | [diff] [blame] | 276 | |
Johnny Chen | be7da21 | 2010-10-08 20:01:03 +0000 | [diff] [blame] | 277 | self.expect(output, exe=False, |
| 278 | startstr = "This message should go to standard out.") |
Johnny Chen | 2fcc0e5 | 2010-09-16 18:26:06 +0000 | [diff] [blame] | 279 | |
Caroline Tice | c9c235e | 2011-01-31 18:18:54 +0000 | [diff] [blame] | 280 | def test_print_dictionary_setting(self): |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 281 | self.runCmd ("settings set -r target.env-vars") |
| 282 | self.runCmd ("settings set target.env-vars [\"MY_VAR\"]=some-value") |
| 283 | self.expect ("settings show target.env-vars", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 284 | substrs = [ "MY_VAR=some-value" ]) |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 285 | self.runCmd ("settings set -r target.env-vars") |
Caroline Tice | c9c235e | 2011-01-31 18:18:54 +0000 | [diff] [blame] | 286 | |
| 287 | def test_print_array_setting(self): |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 288 | self.runCmd ("settings set -r target.run-args") |
| 289 | self.runCmd ("settings set target.run-args gobbledy-gook") |
| 290 | self.expect ("settings show target.run-args", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 291 | substrs = [ '[0]: "gobbledy-gook"' ]) |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 292 | self.runCmd ("settings set -r target.run-args") |
Caroline Tice | c9c235e | 2011-01-31 18:18:54 +0000 | [diff] [blame] | 293 | |
| 294 | def test_settings_with_quotes (self): |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 295 | self.runCmd ("settings set -r target.run-args") |
| 296 | self.runCmd ("settings set target.run-args a b c") |
| 297 | self.expect ("settings show target.run-args", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 298 | substrs = [ '[0]: "a"', |
| 299 | '[1]: "b"', |
| 300 | '[2]: "c"' ]) |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 301 | self.runCmd ("settings set target.run-args 'a b c'") |
| 302 | self.expect ("settings show target.run-args", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 303 | substrs = [ '[0]: "a b c"' ]) |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 304 | self.runCmd ("settings set -r target.run-args") |
| 305 | self.runCmd ("settings set -r target.env-vars") |
| 306 | self.runCmd ('settings set target.env-vars ["MY_FILE"]="this is a file name with spaces.txt"') |
| 307 | self.expect ("settings show target.env-vars", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 308 | substrs = [ 'MY_FILE=this is a file name with spaces.txt' ]) |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 309 | self.runCmd ("settings set -r target.env-vars") |
Caroline Tice | c9c235e | 2011-01-31 18:18:54 +0000 | [diff] [blame] | 310 | |
Johnny Chen | 7737777 | 2010-09-07 17:06:13 +0000 | [diff] [blame] | 311 | |
Caroline Tice | b904ca5 | 2011-03-10 22:29:54 +0000 | [diff] [blame] | 312 | def test_all_settings_exist (self): |
| 313 | self.expect ("settings show", |
| 314 | substrs = [ "frame-format (string) = ", |
| 315 | "prompt (string) = ", |
| 316 | "script-lang (string) = ", |
| 317 | "term-width (int) = ", |
| 318 | "thread-format (string) = ", |
| 319 | "use-external-editor (boolean) = ", |
| 320 | "auto-confirm (boolean) = ", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 321 | "target.default-arch (string) =", |
Caroline Tice | b904ca5 | 2011-03-10 22:29:54 +0000 | [diff] [blame] | 322 | "target.expr-prefix (string) = ", |
Greg Clayton | 1d88596 | 2011-11-08 02:43:13 +0000 | [diff] [blame] | 323 | "target.run-args (array) =", |
| 324 | "target.env-vars (dictionary) =", |
| 325 | "target.inherit-env (boolean) = ", |
| 326 | "target.input-path (string) = ", |
| 327 | "target.output-path (string) = ", |
| 328 | "target.error-path (string) = ", |
| 329 | "target.disable-aslr (boolean) = ", |
| 330 | "target.disable-stdio (boolean) = ", |
Greg Clayton | 4c20717 | 2011-04-19 22:32:36 +0000 | [diff] [blame] | 331 | "target.process.thread.step-avoid-regexp (string) =", |
Caroline Tice | b904ca5 | 2011-03-10 22:29:54 +0000 | [diff] [blame] | 332 | "target.process.thread.trace-thread (boolean) =" ]) |
| 333 | |
| 334 | |
Johnny Chen | 7737777 | 2010-09-07 17:06:13 +0000 | [diff] [blame] | 335 | if __name__ == '__main__': |
| 336 | import atexit |
| 337 | lldb.SBDebugger.Initialize() |
| 338 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 339 | unittest2.main() |