[Lldb-commits] [lldb] r121811 - in /lldb/trunk/test/settings: TestSettings.py main.cpp
Johnny Chen
johnny.chen at apple.com
Tue Dec 14 15:43:29 PST 2010
Author: johnny
Date: Tue Dec 14 17:43:29 2010
New Revision: 121811
URL: http://llvm.org/viewvc/llvm-project?rev=121811&view=rev
Log:
Make the TestSettings.py test cases use different output filenames:
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
and add teardown hook to test_pass_host_env_vars() in order to properly
unset the host environment variables set while running the test case.
Modified:
lldb/trunk/test/settings/TestSettings.py
lldb/trunk/test/settings/main.cpp
Modified: lldb/trunk/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=121811&r1=121810&r2=121811&view=diff
==============================================================================
--- lldb/trunk/test/settings/TestSettings.py (original)
+++ lldb/trunk/test/settings/TestSettings.py Tue Dec 14 17:43:29 2010
@@ -14,7 +14,8 @@
@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 @@
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 @@
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 @@
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,
Modified: lldb/trunk/test/settings/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/main.cpp?rev=121811&r1=121810&r2=121811&view=diff
==============================================================================
--- lldb/trunk/test/settings/main.cpp (original)
+++ lldb/trunk/test/settings/main.cpp Tue Dec 14 17:43:29 2010
@@ -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 @@
std::cout << "This message should go to standard out.\n";
+ outfile.close();
return 0;
}
More information about the lldb-commits
mailing list