summaryrefslogtreecommitdiff
path: root/tests/api_send_wlan0_1s2r
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-06-30 12:11:59 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-06-30 12:11:59 +0200
commitd0ae9f329685a19136cfd9a890b305db3bc384b9 (patch)
treeb3c72908b8930db16b1f682bb7119abeaf72fadf /tests/api_send_wlan0_1s2r
parent1bef51d87860f782f687533012167bebb43c093d (diff)
Improve tests
Diffstat (limited to 'tests/api_send_wlan0_1s2r')
-rw-r--r--tests/api_send_wlan0_1s2r/out16
-rw-r--r--tests/api_send_wlan0_1s2r/receiver.py29
-rw-r--r--tests/api_send_wlan0_1s2r/sender.py6
-rwxr-xr-xtests/api_send_wlan0_1s2r/simulator.py15
4 files changed, 66 insertions, 0 deletions
diff --git a/tests/api_send_wlan0_1s2r/out b/tests/api_send_wlan0_1s2r/out
new file mode 100644
index 0000000..bb052dd
--- /dev/null
+++ b/tests/api_send_wlan0_1s2r/out
@@ -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
diff --git a/tests/api_send_wlan0_1s2r/receiver.py b/tests/api_send_wlan0_1s2r/receiver.py
new file mode 100644
index 0000000..5b86500
--- /dev/null
+++ b/tests/api_send_wlan0_1s2r/receiver.py
@@ -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()
+
diff --git a/tests/api_send_wlan0_1s2r/sender.py b/tests/api_send_wlan0_1s2r/sender.py
new file mode 100644
index 0000000..ef1517b
--- /dev/null
+++ b/tests/api_send_wlan0_1s2r/sender.py
@@ -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)
diff --git a/tests/api_send_wlan0_1s2r/simulator.py b/tests/api_send_wlan0_1s2r/simulator.py
new file mode 100755
index 0000000..e721a93
--- /dev/null
+++ b/tests/api_send_wlan0_1s2r/simulator.py
@@ -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()