diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/test/settings/TestSettings.py | 17 | ||||
-rw-r--r-- | lldb/test/settings/main.cpp | 13 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py index e0653c442bd..2095a38576e 100644 --- a/lldb/test/settings/TestSettings.py +++ b/lldb/test/settings/TestSettings.py @@ -14,7 +14,8 @@ class SettingsCommandTestCase(TestBase): @classmethod def classCleanup(cls): """Cleanup the test byproducts.""" - system(["/bin/sh", "-c", "rm -f output.txt"]) + system(["/bin/sh", "-c", "rm -f output1.txt"]) + system(["/bin/sh", "-c", "rm -f output2.txt"]) system(["/bin/sh", "-c", "rm -f stdout.txt"]) def test_set_prompt(self): @@ -72,12 +73,12 @@ class SettingsCommandTestCase(TestBase): startstr = "auto-confirm (boolean) = 'false'") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_with_dsym(self): + def test_run_args_and_env_vars_with_dsym(self): """Test that run-args and env-vars are passed to the launched process.""" self.buildDsym() self.pass_run_args_and_env_vars() - def test_with_dwarf(self): + def test_run_args_and_env_vars_with_dwarf(self): """Test that run-args and env-vars are passed to the launched process.""" self.buildDwarf() self.pass_run_args_and_env_vars() @@ -99,7 +100,7 @@ class SettingsCommandTestCase(TestBase): self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - with open('output.txt', 'r') as f: + with open('output2.txt', 'r') as f: output = f.read() self.expect(output, exe=False, @@ -123,10 +124,16 @@ class SettingsCommandTestCase(TestBase): os.environ["MY_HOST_ENV_VAR1"] = "VAR1" os.environ["MY_HOST_ENV_VAR2"] = "VAR2" + # This is the function to unset the two env variables set above. + def unset_env_variables(): + os.environ.pop("MY_HOST_ENV_VAR1") + os.environ.pop("MY_HOST_ENV_VAR2") + + self.addTearDownHook(unset_env_variables) self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - with open('output.txt', 'r') as f: + with open('output1.txt', 'r') as f: output = f.read() self.expect(output, exe=False, diff --git a/lldb/test/settings/main.cpp b/lldb/test/settings/main.cpp index f54975439a7..82bddba18f9 100644 --- a/lldb/test/settings/main.cpp +++ b/lldb/test/settings/main.cpp @@ -15,8 +15,16 @@ int main(int argc, char const *argv[]) { - // The program writes its output to the "output.txt" file. - std::ofstream outfile("output.txt"); + // The program writes its output to the following file: + // + // o "output1.txt" for test_pass_host_env_vars() test case + // o "output2.txt" for test_run_args_and_env_vars_with_dsym() test case + // o "output2.txt" for test_run_args_and_env_vars_with_dwarf() test case + std::ofstream outfile; + if (argc == 1) + outfile.open("output1.txt"); + else + outfile.open("output2.txt"); for (unsigned i = 0; i < argc; ++i) { std::string theArg(argv[i]); @@ -56,5 +64,6 @@ main(int argc, char const *argv[]) std::cout << "This message should go to standard out.\n"; + outfile.close(); return 0; } |