From 6dbd3e123d3930fafbcdbb2bc2727842276ce257 Mon Sep 17 00:00:00 2001 From: Ken McMillan Date: Mon, 12 Dec 2016 18:47:11 -0800 Subject: [PATCH] more repl tests --- doc/examples/udp_test2_expect.py | 19 +++++++++++++++++++ doc/examples/udp_test_expect.py | 16 ++++++++++++++++ test/run_expects.py | 11 +++++++---- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 doc/examples/udp_test2_expect.py create mode 100644 doc/examples/udp_test_expect.py diff --git a/doc/examples/udp_test2_expect.py b/doc/examples/udp_test2_expect.py new file mode 100644 index 0000000..fd98a22 --- /dev/null +++ b/doc/examples/udp_test2_expect.py @@ -0,0 +1,19 @@ +import pexpect +import sys + +def run(name,opts,res): + child = [pexpect.spawn('./{} {}'.format(name,idx)) for idx in range(2)] + for idx in range(2): + child[idx].logfile = sys.stdout + try: + child[0].expect('>') + child[0].sendline('foo.send(1,2)') + child[1].expect(r'< foo.recv\(2\)') + child[1].sendline('foo.send(0,3)') + child[0].expect(r'foo.recv\(3\)') + child[0].sendline('foo.send(0,4)') + child[0].expect(r'< foo.recv\(4\)') + return True + except pexpect.EOF: + print child.before + return False diff --git a/doc/examples/udp_test_expect.py b/doc/examples/udp_test_expect.py new file mode 100644 index 0000000..fce6603 --- /dev/null +++ b/doc/examples/udp_test_expect.py @@ -0,0 +1,16 @@ +import pexpect +import sys + +def run(name,opts,res): + child = pexpect.spawn('./{}'.format(name)) + child.logfile = sys.stdout + try: + child.expect('>') + child.sendline('foo.send(0,1,2)') + child.expect(r'< foo.recv\(1,2\)') + child.sendline('foo.send(1,0,3)') + child.expect(r'foo.recv\(0,3\)') + return True + except pexpect.EOF: + print child.before + return False diff --git a/test/run_expects.py b/test/run_expects.py index b23ee3c..be86d0b 100644 --- a/test/run_expects.py +++ b/test/run_expects.py @@ -73,12 +73,14 @@ tests = [ repls = [ ['../doc/examples', [ - ['leader_election_ring_repl','isolate=iso_impl','leader_election_ring_repl_iso_impl_expect'], +# ['leader_election_ring_repl','isolate=iso_impl','leader_election_ring_repl_iso_impl_expect'], # ['helloworld',None], # ['account',None], # ['account2',None], # ['account3',None], # ['leader_election_ring_repl',None], +# ['udp_test','isolate=iso_impl',None], + ['udp_test2','isolate=iso_impl',None], ] ] ] @@ -110,7 +112,8 @@ class Test(object): child = pexpect.spawn(pc) child.logfile = sys.stdout child.expect(pexpect.EOF) - if child.wait() != 0: + child.close() + if child.exitstatus != 0: print child.before return False return self.expect() @@ -162,8 +165,8 @@ def get_tests(cls,arr): #get_tests(IvyCheck,checks) #get_tests(IvyTest,tests) -#get_tests(IvyRepl,repls) -get_tests(IvyToCpp,to_cpps) +get_tests(IvyRepl,repls) +#get_tests(IvyToCpp,to_cpps) num_failures = 0 for test in all_tests: