Improve tests

This commit is contained in:
Loic Guegan 2022-06-30 12:11:59 +02:00
parent 1bef51d878
commit d0ae9f3296
85 changed files with 77 additions and 44 deletions

View file

@ -0,0 +1,8 @@
[t=0.000,src=n0] Send 1 bytes to n1 on eth0
[t=1.000,src=n1] Receive 1 bytes on eth0
[t=1.000,src=n1] Received: Hello World!
[t=1.000,src=n0] Send 1 bytes to n1 on eth0
[t=1.500,src=n1] Receive failed code=-1
[t=2.000,src=n1] Receive 1 bytes on eth0
[t=2.000,src=n1] Received: Hello World!
[t=2.000,src=esds] Simulation ends

View file

@ -0,0 +1,15 @@
#!/usr/bin/env python
def receivet(node,timeout):
##### Simple receive
code, data=node.receivet("eth0",timeout)
msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
node.log(msg)
def execute(api):
# Should works
receivet(api,2)
# Should failed
receivet(api,0.5) # At t=1.5s
# Should works (priorities says that communications should occurs before timeout)
receivet(api,0.5) # At t=2s (timeout+receive should occur)

View file

@ -0,0 +1,6 @@
#!/usr/bin/env python
def execute(api):
api.send("eth0","Hello World!",1,1)
api.send("eth0","Hello World!",1,1)

View file

@ -0,0 +1,14 @@
#!/usr/bin/env python
# Load ESDS
import esds
import numpy as np
B=np.full((2,2),8)
L=np.full((2,2),0)
s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False}, "eth0":{"bandwidth":B, "latency":L, "is_wired":True}})
s.create_node("sender")
s.create_node("receiver")
s.run()

View file

@ -0,0 +1,43 @@
Python version 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
Simulation started at 1654802960.7880125
Number of nodes is 2
Manual breakpoints list: []
Breakpoints every Nones
-----------------------------------------------
Started since 0.02s
Simulated time 0.000s (or more precisely 0s)
Node number per state: pending=1 request=1
Node sharing: n1=1
Ids of node in timeout mode:
Sorted events list:
[[0 1.0 array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 0], dtype=object)
1]
[1 2 array(1, dtype=object) 3]]
-----------------------------------------------
Started since 0.04s
Simulated time 1.000s (or more precisely 1.0s)
Node number per state: pending=1 request=1
Node sharing: n1=1
Ids of node in timeout mode:
Sorted events list:
[[1 1.5 array(1, dtype=object) 3]
[0 2.0
array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 1.0], dtype=object) 1]]
-----------------------------------------------
Started since 0.06s
Simulated time 1.500s (or more precisely 1.5s)
Node number per state: pending=1 request=1
Node sharing: n1=1
Ids of node in timeout mode:
Sorted events list:
[[0 2.0
array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 1.0], dtype=object) 1]
[1 2.0 array(1, dtype=object) 3]]
-----------------------------------------------
Started since 0.08s
Simulated time 2.000s (or more precisely 2.0s)
Node number per state: terminated=2
Node sharing:
Ids of node in timeout mode:
Sorted events list:
[]