From c3c3b5a87d8b800ea011ec2238eafe9d1150d99f Mon Sep 17 00:00:00 2001 From: Phil <phil@secdev.org> Date: Tue, 5 May 2009 00:25:52 +0200 Subject: [PATCH] Added new automaton regression tests --- test/regression.uts | 61 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/test/regression.uts b/test/regression.uts index 8c69930a..f5b5f732 100644 --- a/test/regression.uts +++ b/test/regression.uts @@ -896,6 +896,10 @@ a=ATMT6() a.run() assert( _ == 'Mercury' ) +a.restart() +a.run() +assert( _ == 'Mercury' ) + = Automaton test io event ~ automaton @@ -927,6 +931,14 @@ a.io.tst.send(_) a.run() assert( _ == "Saturn" ) +a.restart() +a.run(wait=False) +a.io.tst.send("at") +a.io.tst.recv() +a.io.tst.send(_) +a.run() +assert( _ == "Saturn" ) + = Automaton test io event from external fd ~ automaton class ATMT8(Automaton): @@ -957,7 +969,54 @@ os.write(w,"ra") os.write(w,"nu") a.run() assert( _ == "Uranus" ) - + +a.restart() +a.run(wait=False) +os.write(w,"ra") +os.write(w,"nu") +a.run() +assert( _ == "Uranus" ) + += Automaton test interception_points, and restart +~ automaton +class ATMT9(Automaton): + def my_send(self, x): + self.io.loop.send(x) + @ATMT.state(initial=1) + def BEGIN(self): + self.res = "V" + self.send(Raw("ENU")) + @ATMT.ioevent(BEGIN, name="loop") + def received_sth(self, fd): + self.res += fd.recv().load + raise self.END() + @ATMT.state(final=1) + def END(self): + self.res += "s" + return self.res + +a=ATMT9(debug=5) +a.run() +assert( _ == "VENUs" ) + +a.restart() +a.run() +assert( _ == "VENUs" ) + +a.restart() +a.BEGIN.intercepts() +while True: + try: + x = a.run() + except Automaton.InterceptionPoint,p: + a.accept_packet(Raw(p.packet.load.lower()), wait=False) + else: + break + +x +assert( _ == "Venus" ) + + + Test IP options -- GitLab