mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-06 01:56:27 +02:00
Improve tests
This commit is contained in:
parent
1bef51d878
commit
d0ae9f3296
85 changed files with 77 additions and 44 deletions
|
@ -7,7 +7,7 @@ class Simulator:
|
|||
Flow-Level Discrete Event Simulator for Cyber-Physical Systems
|
||||
The general format for an event is (type,timestamp,event,priority)
|
||||
Event types:
|
||||
- 0 send (0,timestamp,(src,dst,interface,data,datasize,duration,datasize_remaining), 2)
|
||||
- 0 send (0,timestamp,(src,dst,interface,data,datasize,duration,datasize_remaining,start_timestamp), 2)
|
||||
- 1 timeout (1,timestamp,node_id,3)
|
||||
- 2 breakpoint_manual (3,timestamp,0,1)
|
||||
- 3 breakpoint_auto (4,timestamp,0,1)
|
||||
|
|
7
tests/api_read_clock_2n/node.py
Normal file
7
tests/api_read_clock_2n/node.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("Clock is {}s".format(api.read("clock"))) # Ensure clock is 0s for both node
|
||||
api.wait(5698.1256)
|
||||
api.log("Clock is {}s".format(api.read("clock"))) # Ensure clock is 5698.1256s for both node
|
||||
api.log("Clock is {}s".format(api.read("clock"))) # Ensure clock did not change in between for both node
|
13
tests/api_read_eth0_ncom_2s1r/receiver.py
Normal file
13
tests/api_read_eth0_ncom_2s1r/receiver.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Ensure no commmunications at t=0s
|
||||
api.wait(624)
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Ensure still no commmunications at t=624s
|
||||
api.wait(624)
|
||||
# Now we are at 624*2=1248 (first sender start a communication)
|
||||
api.wait(1) # Let the communication starts (otherwise value will be 0 (see api_read_order_ncom_1s2r))
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 1
|
||||
# Now second sender start a communication
|
||||
api.wait(1) # Let the second communication starts
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 2
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.wait(1248)
|
||||
api.wait(1248) # All communications start at t=1248s
|
||||
if api.node_id==0:
|
||||
api.send("eth0","hello",50,2)
|
||||
else:
|
||||
api.wait(1)
|
||||
api.wait(1) # Second sender start 1s after the first
|
||||
api.send("eth0","hello",50,2)
|
6
tests/api_read_order_ncom_1s2r/out
Normal file
6
tests/api_read_order_ncom_1s2r/out
Normal file
|
@ -0,0 +1,6 @@
|
|||
[t=0.000,src=n0] wlan0 is 0
|
||||
[t=0.000,src=n2] wlan0 is 0
|
||||
[t=0.000,src=n1] Send 1 bytes on wlan0
|
||||
[t=1.000,src=n0] Receive 1 bytes on wlan0
|
||||
[t=1.000,src=n2] Receive 1 bytes on wlan0
|
||||
[t=1.000,src=esds] Simulation ends
|
4
tests/api_read_order_ncom_1s2r/receiver.py
Normal file
4
tests/api_read_order_ncom_1s2r/receiver.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Ensure no commmunications at t=0s
|
4
tests/api_read_order_ncom_1s2r/sender.py
Normal file
4
tests/api_read_order_ncom_1s2r/sender.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.send("wlan0","hello",1,None)
|
17
tests/api_read_order_ncom_1s2r/simulator.py
Executable file
17
tests/api_read_order_ncom_1s2r/simulator.py
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/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}})
|
||||
|
||||
# Order at which receivers and senders are instanciated should not matter on the result
|
||||
# both receivers should have ncom_wlan0 equals to 0 (since non-blocking calls are processed before the blocking one, it should be the case)
|
||||
s.create_node("receiver")
|
||||
s.create_node("sender")
|
||||
s.create_node("receiver")
|
||||
|
||||
s.run(interferences=False)
|
13
tests/api_read_wlan0_ncom_2s1r/receiver.py
Normal file
13
tests/api_read_wlan0_ncom_2s1r/receiver.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Ensure no commmunications at t=0s
|
||||
api.wait(624)
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Ensure still no commmunications at t=624s
|
||||
api.wait(624)
|
||||
# Now we are at 624*2=1248 (first sender start a communication)
|
||||
api.wait(1) # Let the communication starts (otherwise value will be 0 (see api_read_order_ncom_1s2r))
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 1
|
||||
# Now second sender start a communication
|
||||
api.wait(1) # Let the second communication starts
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 2
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.wait(1248)
|
||||
api.wait(1248) # All communications start at t=1248s
|
||||
if api.node_id==0:
|
||||
api.send("wlan0","hello",50,None)
|
||||
else:
|
||||
api.wait(1)
|
||||
api.wait(1) # Second sender start 1s after the first
|
||||
api.send("wlan0","hello",50,None)
|
|
@ -7,8 +7,8 @@ def receivet(node,timeout):
|
|||
node.log(msg)
|
||||
|
||||
def execute(api):
|
||||
# Should not works
|
||||
# Should not works since communication start at t=0s
|
||||
receivet(api,0)
|
||||
api.wait(1)
|
||||
# Should works
|
||||
receivet(api,0)
|
||||
# Now communication started
|
||||
receivet(api,0) # Should work (no timeout error)
|
|
@ -11,4 +11,4 @@ s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False}, "eth0"
|
|||
s.create_node("sender")
|
||||
s.create_node("receiver")
|
||||
|
||||
s.run(debug=True)
|
||||
s.run()
|
|
@ -11,4 +11,4 @@ s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False}, "eth0"
|
|||
s.create_node("sender")
|
||||
s.create_node("receiver")
|
||||
|
||||
s.run(debug=True)
|
||||
s.run()
|
|
@ -11,4 +11,4 @@ s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False}, "eth0"
|
|||
s.create_node("sender")
|
||||
s.create_node("receiver")
|
||||
|
||||
s.run(debug=True)
|
||||
s.run()
|
|
@ -38,4 +38,4 @@ def callback(simulator):
|
|||
new_bw_eth0=simulator.netmat["eth0"]["bandwidth"]*2
|
||||
simulator.update_network({"wlan0":{"bandwidth":new_bw_wlan0, "latency":L, "is_wired":False}, "eth0":{"bandwidth":new_bw_eth0, "latency":L, "is_wired":True}})
|
||||
|
||||
s.run(breakpoints_every=1,breakpoint_callback=callback,debug=True)
|
||||
s.run(breakpoints_every=1,breakpoint_callback=callback)
|
||||
|
|
|
@ -39,4 +39,4 @@ def callback(simulator):
|
|||
new_lat_eth0=simulator.netmat["eth0"]["latency"]+1/2
|
||||
simulator.update_network({"wlan0":{"bandwidth":B, "latency":new_lat_wlan0, "is_wired":False},"eth0":{"bandwidth":B, "latency":new_lat_eth0, "is_wired":True}})
|
||||
|
||||
s.run(breakpoints_every=1,breakpoint_callback=callback,debug=True)
|
||||
s.run(breakpoints_every=1,breakpoint_callback=callback)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("Clock is {}s".format(api.read("clock")))
|
||||
api.wait(5698.1256)
|
||||
api.log("Clock is {}s".format(api.read("clock")))
|
||||
api.log("Clock is {}s".format(api.read("clock")))
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0")))
|
||||
api.wait(624)
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0")))
|
||||
api.wait(624)
|
||||
# Now we are at 624*2=1248 (first sender start a communication)
|
||||
api.wait(1) # Let the communication starts
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 1
|
||||
api.wait(1) # Now second sender start a communication
|
||||
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 2
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
def execute(api):
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0")))
|
||||
api.wait(624)
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0")))
|
||||
api.wait(624)
|
||||
# Now we are at 624*2=1248 (first sender start a communication)
|
||||
api.wait(1) # Let the communication starts
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 1
|
||||
api.wait(1) # Second sender start a communication
|
||||
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 2
|
Loading…
Add table
Reference in a new issue