From 3bc81942721dcbba5af957c3822c63b7161b2091 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 29 Mar 2008 00:40:27 +0100 Subject: * host/mex: - first mex version. --- host/mex/test/test.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 host/mex/test/test.py (limited to 'host/mex/test/test.py') diff --git a/host/mex/test/test.py b/host/mex/test/test.py new file mode 100644 index 00000000..48484486 --- /dev/null +++ b/host/mex/test/test.py @@ -0,0 +1,51 @@ +import sys +sys.path.append (sys.path[0] + '/..') + +from mex.hub import Hub +from mex.node import Node +from mex.msg import Msg +from mex.forked import Forked + +def log (x): + print x + +h = Hub (min_clients = 2, log = log) + +def c1 (): + n = Node () + def a (msg): + print 'oucouc' + nb, = msg.pop ('B') + nb += 1 + m = Msg (msg.mtype) + m.push ('B', nb) + n.response (m) + n.register (0x82, a) + m = Msg (0x81) + n.send (m) + n.wait () + +f1 = Forked (c1) + +def c2 (): + n = Node () + def a (msg): + print 'coucou' + n.register (0x81, a) + m = Msg (0x82) + m.push ('B', 42) + r = n.request (m) + assert r.mtype == 0x82 + assert r.pop ('B') == (43,) + n.wait (42) + n.wait () + +f2 = Forked (c2) + +try: + h.wait () +finally: + f1.kill () + f2.kill () + import time + time.sleep (1) -- cgit v1.2.3