summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-08-01 21:11:46 +0000
committerZac Medico <zmedico@gentoo.org>2007-08-01 21:11:46 +0000
commit874ace4aa8770e47ebde603a2c088bba5f32964d (patch)
tree6be255c2d551146fac047618c5defcde60c55605 /tests
parent729901d3647f483a0b1eeea2653665b77f1a3fe2 (diff)
downloadportage-874ace4aa8770e47ebde603a2c088bba5f32964d.tar.gz
portage-874ace4aa8770e47ebde603a2c088bba5f32964d.tar.bz2
portage-874ace4aa8770e47ebde603a2c088bba5f32964d.zip
Copy the portage.spawn() test from trunk.
svn path=/main/branches/2.1.2/; revision=7539
Diffstat (limited to 'tests')
-rw-r--r--tests/portage/test_spawn.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/portage/test_spawn.py b/tests/portage/test_spawn.py
new file mode 100644
index 000000000..66e8f9ea7
--- /dev/null
+++ b/tests/portage/test_spawn.py
@@ -0,0 +1,36 @@
+# Copyright 1998-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+import errno, os, sys
+from portage.tests import TestCase
+
+class SpawnTestCase(TestCase):
+
+ def testLogfile(self):
+ from portage import settings, spawn
+ from tempfile import mkstemp
+ logfile = None
+ try:
+ fd, logfile = mkstemp()
+ os.close(fd)
+ null_fd = os.open('/dev/null', os.O_RDWR)
+ test_string = 2 * "blah blah blah\n"
+ spawn("echo -n '%s'" % test_string, settings, logfile=logfile,
+ fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd})
+ os.close(null_fd)
+ f = open(logfile, 'r')
+ log_content = f.read()
+ f.close()
+ # When logging passes through a pty, it's lines will be separated
+ # by '\r\n', so use splitlines before comparing results.
+ self.assertEqual(test_string.splitlines(),
+ log_content.splitlines())
+ finally:
+ if logfile:
+ try:
+ os.unlink(logfile)
+ except EnvironmentError, e:
+ if e.errno != errno.ENOENT:
+ raise
+ del e