diff -r eb1aa6f8701e Lib/test/test_pty.py
--- a/Lib/test/test_pty.py Sun Dec 25 16:24:15 2016 +0200
+++ b/Lib/test/test_pty.py Sun Dec 25 17:32:20 2016 +0100
@@ -197,6 +197,48 @@
# pty.fork() passed.
+class PtyLinuxIntegrtionTest(unittest.TestCase):
+ """Test black-box functionality. Linux-specific. May actually fork and exec
+ local programs! Should not be intrusive for your local machine.
+ """
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ @staticmethod
+ def _skip_not_available(exe_path):
+ if not (os.path.isfile(exe_path) and
+ os.access(exe_path, os.R_OK | os.X_OK)):
+ raise unittest.SkipTest("File `{:s}' seems not to be available "
+ "on your system".format(exe_path))
+
+ def _spawn_binary_return_returncode(self, binary):
+ """Helper function to do pty.spawn() on binary and return the return
+ code, assuming successful termination."""
+ self._skip_not_available(binary)
+
+ ret = pty.spawn(binary)
+
+ #behavior of waitpid in module posix
+ self.assertLess(ret, 2**16)
+ killsig = ret & 0xff
+ self.assertEqual(killsig, 0)
+
+ retcode = (ret & 0xff00) >> 8
+ return retcode
+
+ def test_spawn_bin_true(self):
+ """Spawn /bin/true and read return code."""
+ retcode = self._spawn_binary_return_returncode('/bin/true')
+ self.assertEqual(retcode, 0)
+
+ def test_spawn_bin_false(self):
+ """Spawn /bin/false and read return code."""
+ retcode = self._spawn_binary_return_returncode('/bin/false')
+ self.assertEqual(retcode, 1)
+
class SmallPtyTests(unittest.TestCase):
"""These tests don't spawn children or hang."""