mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-19 12:09:44 +00:00
Improve tests
This commit is contained in:
parent
1bef51d878
commit
d0ae9f3296
85 changed files with 77 additions and 44 deletions
16
tests/api_send_wlan0_1s2r/out
Normal file
16
tests/api_send_wlan0_1s2r/out
Normal file
|
@ -0,0 +1,16 @@
|
|||
[t=0.000,src=n0] Send 1 bytes on wlan0
|
||||
[t=1.000,src=n1] Receive 1 bytes on wlan0
|
||||
[t=1.000,src=n2] Receive 1 bytes on wlan0
|
||||
[t=1.000,src=n1] Received: Hello World!
|
||||
[t=1.000,src=n2] Received: Hello World!
|
||||
[t=1.000,src=n2] Turned off
|
||||
[t=1.000,src=n0] Send 1 bytes on wlan0
|
||||
[t=2.000,src=n1] Receive 1 bytes on wlan0
|
||||
[t=2.000,src=n1] Received: Hello World!
|
||||
[t=2.000,src=n2] Turned on
|
||||
[t=2.000,src=n0] Send 1 bytes on wlan0
|
||||
[t=2.500,src=n2] Turned off
|
||||
[t=3.000,src=n1] Receive 1 bytes on wlan0
|
||||
[t=3.000,src=n1] Received: Hello World!
|
||||
[t=3.000,src=n2] Turned on
|
||||
[t=3.000,src=esds] Simulation ends
|
29
tests/api_send_wlan0_1s2r/receiver.py
Normal file
29
tests/api_send_wlan0_1s2r/receiver.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def receive(node):
|
||||
##### Simple receive
|
||||
code, data=node.receive("wlan0")
|
||||
msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
|
||||
node.log(msg)
|
||||
|
||||
|
||||
def execute(api):
|
||||
# Should works for all receivers
|
||||
receive(api)
|
||||
|
||||
if api.node_id == 1:
|
||||
receive(api) # Should works
|
||||
else:
|
||||
api.turn_off()
|
||||
api.wait(1) # Node 2 should not receive anything during 1s
|
||||
api.turn_on()
|
||||
|
||||
|
||||
if api.node_id == 1:
|
||||
receive(api) # Should works
|
||||
else:
|
||||
api.wait(0.5) # Check if started communication get cancelled on turning off
|
||||
api.turn_off() # Node 2 should not receive anything
|
||||
api.wait(0.5) # Node 2 should not receive anything during 0.5s
|
||||
api.turn_on()
|
||||
|
6
tests/api_send_wlan0_1s2r/sender.py
Normal file
6
tests/api_send_wlan0_1s2r/sender.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.send("wlan0","Hello World!",1,1)
|
||||
api.send("wlan0","Hello World!",1,1)
|
||||
api.send("wlan0","Hello World!",1,1)
|
15
tests/api_send_wlan0_1s2r/simulator.py
Executable file
15
tests/api_send_wlan0_1s2r/simulator.py
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Load ESDS
|
||||
import esds
|
||||
import numpy as np
|
||||
|
||||
B=np.full((3,3),8)
|
||||
L=np.full((3,3),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.create_node("receiver")
|
||||
|
||||
s.run()
|
Loading…
Add table
Add a link
Reference in a new issue