[Lldb-commits] [lldb] r124489 - in /lldb/trunk/test/process_io: ./ Makefile TestProcessIO.py input-file.txt main.cpp
Caroline Tice
ctice at apple.com
Fri Jan 28 09:31:28 PST 2011
Author: ctice
Date: Fri Jan 28 11:31:28 2011
New Revision: 124489
URL: http://llvm.org/viewvc/llvm-project?rev=124489&view=rev
Log:
Add tests for 'process launch' I/O flags.
Added:
lldb/trunk/test/process_io/
lldb/trunk/test/process_io/Makefile
lldb/trunk/test/process_io/TestProcessIO.py
lldb/trunk/test/process_io/input-file.txt
lldb/trunk/test/process_io/main.cpp
Added: lldb/trunk/test/process_io/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/process_io/Makefile?rev=124489&view=auto
==============================================================================
--- lldb/trunk/test/process_io/Makefile (added)
+++ lldb/trunk/test/process_io/Makefile Fri Jan 28 11:31:28 2011
@@ -0,0 +1,6 @@
+LEVEL = ../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+
Added: lldb/trunk/test/process_io/TestProcessIO.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/process_io/TestProcessIO.py?rev=124489&view=auto
==============================================================================
--- lldb/trunk/test/process_io/TestProcessIO.py (added)
+++ lldb/trunk/test/process_io/TestProcessIO.py Fri Jan 28 11:31:28 2011
@@ -0,0 +1,119 @@
+"""
+Test lldb process IO launch flags..
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class ProcessLaunchIOTestCase(TestBase):
+
+ mydir = "process_io"
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym (self):
+ self.buildDsym ()
+ self.process_io_test ()
+
+ def test_with_dwarf (self):
+ self.buildDwarf ()
+ self.process_io_test ()
+
+ def do_nothing (self):
+ i = 1
+
+ def process_io_test (self):
+ exe = os.path.join (os.getcwd(), "a.out")
+ self.expect("file " + exe,
+ patterns = [ "Current executable set to .*a.out" ])
+
+
+ in_file = os.path.join (os.getcwd(), "input-file.txt")
+ out_file = os.path.join (os.getcwd(), "output-test.out")
+ err_file = os.path.join (os.getcwd(), "output-test.err")
+
+
+ # Make sure the output files do not exist before launching the process
+ try:
+ os.remove (out_file)
+ except OSError:
+ # do_nothing (self)
+ i = 1
+
+ try:
+ os.remove (err_file)
+ except OSError:
+ # do_nothing (self)
+ i = 1
+
+ launch_command = "process launch -i " + in_file + " -o " + out_file + " -e " + err_file
+
+ self.expect (launch_command,
+ patterns = [ "Process .* launched: .*a.out" ])
+
+
+ success = True
+ err_msg = ""
+
+ # Check to see if the 'stdout' file was created
+ try:
+ out_f = open (out_file)
+ except IOError:
+ success = False
+ err_msg = err_msg + " ERROR: stdout file was not created.\n"
+ else:
+ # Check to see if the 'stdout' file contains the right output
+ line = out_f.readline ();
+ if line != "This should go to stdout.\n":
+ success = False
+ err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n"
+ out_f.close();
+
+ # Try to delete the 'stdout' file
+ try:
+ os.remove (out_file)
+ except OSError:
+ # do_nothing (self)
+ i = 1
+
+ # Check to see if the 'stderr' file was created
+ try:
+ err_f = open (err_file)
+ except IOError:
+ success = False
+ err_msg = err_msg + " ERROR: stderr file was not created.\n"
+ else:
+ # Check to see if the 'stderr' file contains the right output
+ line = err_f.readline ()
+ if line != "This should go to stderr.\n":
+ success = False
+ err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n\
+"
+ err_f.close()
+
+ # Try to delete the 'stderr' file
+ try:
+ os.remove (err_file)
+ except OSError:
+ # do_nothing (self)
+ i = 1
+
+ if not success:
+ # This test failed, but we need to make the main testing
+ # mechanism realize something is wrong.
+ #
+ # First, print out the real error message.
+ self.fail (err_msg)
+ #print err_msg
+
+ # Second, force a test case to fail:
+ #self.expect ("help quit",
+ # patterns = ["Intentional failure .*"])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
+
Added: lldb/trunk/test/process_io/input-file.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/process_io/input-file.txt?rev=124489&view=auto
==============================================================================
--- lldb/trunk/test/process_io/input-file.txt (added)
+++ lldb/trunk/test/process_io/input-file.txt Fri Jan 28 11:31:28 2011
@@ -0,0 +1,2 @@
+This should go to stdout.
+This should go to stderr.
Added: lldb/trunk/test/process_io/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/process_io/main.cpp?rev=124489&view=auto
==============================================================================
--- lldb/trunk/test/process_io/main.cpp (added)
+++ lldb/trunk/test/process_io/main.cpp Fri Jan 28 11:31:28 2011
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char **argv)
+{
+ char buffer[1024];
+
+ fgets (buffer, sizeof (buffer), stdin);
+ fprintf (stdout, "%s", buffer);
+
+
+ fgets (buffer, sizeof (buffer), stdin);
+ fprintf (stderr, "%s", buffer);
+
+ return 0;
+}
More information about the lldb-commits
mailing list