Add pty to run docker-based tests.
authory0169.zhang <y0169.zhang@samsung.com>
Tue, 27 Dec 2016 07:09:14 +0000 (16:09 +0900)
committery0169.zhang <y0169.zhang@samsung.com>
Tue, 27 Dec 2016 07:09:14 +0000 (16:09 +0900)
Change-Id: I0d8aae8f7e8d6c07f3e852116a45a657c4d93efb

debian/itest-core.install
packaging/itest-core.spec
scripts/runtest_pty [new file with mode: 0644]
setup.py

index 7e5e16434b486bb358e3613e107034f4acbc57d6..0ff6eb923a739ef8253f53ed739b31edfa739734 100644 (file)
@@ -3,4 +3,5 @@ usr/lib/python*/*packages/itest/conf/*.py
 usr/lib/python*/*packages/imgdiff/*.py
 usr/lib/python*/*packages/itest-*.egg-info
 usr/bin/runtest
+usr/bin/runtest_pty
 usr/bin/imgdiff
index ac26273f5ca359272721d2b1139251503ac0d7e7..effa514dfe3442aaeb8fc1ea97c08f40121b1e86 100644 (file)
@@ -76,6 +76,7 @@ Use this plugin with ``nosetests --with-xcase xml case``
 %{python_sitelib}/imgdiff/*
 %{python_sitelib}/itest/*
 %{_bindir}/runtest
+%{_bindir}/runtest_pty
 %{_bindir}/imgdiff
 
 %files -n spm
diff --git a/scripts/runtest_pty b/scripts/runtest_pty
new file mode 100644 (file)
index 0000000..03925d1
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#!-*-coding:utf-8-*-
+
+import sys
+import os
+import pty
+import select
+import time
+import subprocess
+
+def run_with_pty(command):
+    ret = 0
+
+    if command:
+        (master, slave) = pty.openpty()
+        process = subprocess.Popen(command, stdin=slave, stdout=slave, stderr=slave, shell=True)
+        while True:
+            r, w, e = select.select([master], [], [], 0) # timeout of 0 means "poll"
+            if r:
+                line = os.read(master, 1024)
+                #####
+                # Warning, uncomment at your own risk - several programs
+                # print empty lines that will cause this to break and
+                # the output will be all goofed up.
+                #if not line :
+                #    break
+                #print output.rstrip()
+                os.write(1, line)
+            elif process.poll() is not None :
+                break
+        os.close(master)
+        os.close(slave)
+        process.wait()
+        ret = process.returncode
+
+    return ret
+
+def main():
+    cmd = "runtest "
+    for i in range(1, len(sys.argv)):
+        cmd = cmd + sys.argv[i] + " "
+
+    sys.exit(run_with_pty(cmd))
+
+if __name__=="__main__":
+    main()
index 9c5cd0bfad2e96783c4931430ba5992d36cbb282..e6c69329b940f8f1b06f8cbd9583e08aabf46bd2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -23,6 +23,7 @@ setup(name='itest',
           },
       scripts=[
           'scripts/runtest',
+          'scripts/runtest_pty',
           'scripts/imgdiff',
           'scripts/spm',
           ],