From 96deb6a966878f81cce07e9acd470f0d510ec053 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Mon, 2 Mar 2015 00:23:58 -0600 Subject: runtest.py: fix C# and VB tests. It is an ugly fix, but basically, use regular Popen (without pty) when using mono, and do hardcoded echo of the commands when they are sent/written. It could be worse I suppose... --- runtest.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/runtest.py b/runtest.py index 2abd9d6..af6a102 100755 --- a/runtest.py +++ b/runtest.py @@ -33,12 +33,16 @@ parser.add_argument('mal_cmd', nargs="*", class Runner(): def __init__(self, args, redirect=False): + self.redirect = redirect print "args: %s" % repr(args) if redirect: #cmd = '/bin/bash -c "' + " ".join(args) + ' |tee /dev/null"' - cmd = " ".join(args) + ' |tee /dev/null' - print "using redirect cmd: '%s'" % cmd - self.p = Popen(cmd, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT, shell=True) + #cmd = " ".join(args) + ' |tee /dev/null' + #cmd = " ".join(args) + ' |tee /tmp/joel' + #print "using redirect cmd: '%s'" % cmd + self.p = Popen(args, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT) + #self.p = Popen(cmd, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT, shell=True) + #self.p = Popen(["/bin/bash", "-c", cmd], bufsize=0, stdin=PIPE, stdout=PIPE, stderr=STDOUT) self.stdin = self.p.stdin self.stdout = self.p.stdout else: @@ -55,9 +59,9 @@ class Runner(): def read_to_prompt(self, prompts, timeout): end_time = time.time() + timeout while time.time() < end_time: - [outs,_,_] = select([self.stdin], [], [], 1) - if self.stdin in outs: - new_data = self.stdin.read(1) + [outs,_,_] = select([self.stdout], [], [], 1) + if self.stdout in outs: + new_data = self.stdout.read(1) #print "new_data: '%s'" % new_data self.buf += new_data for prompt in prompts: @@ -71,8 +75,11 @@ class Runner(): return buf return None - def write(self, str): - self.stdout.write(str) + def writeline(self, str): + self.stdin.write(str + "\n") + if self.redirect: + # Simulate echo + self.buf += str + "\r\n" def cleanup(self): if self.p: @@ -158,7 +165,7 @@ while test_data: sys.stdout.flush() expected = "%s%s%s%s" % (form, sep, out, ret) - r.write(form + "\n") + r.writeline(form) try: res = r.read_to_prompt(['\r\nuser> ', '\nuser> ', '\r\nmal-user> ', '\nmal-user> '], -- cgit v1.2.3