summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-06-29 11:19:36 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-06-29 11:19:36 +0200
commit1bef51d87860f782f687533012167bebb43c093d (patch)
tree3c1e8160eadd3b7e5d314d9b1759486783544531 /tests
parentbe6d819080fc6c4dccd5b7e56d1da6a1ab930d4f (diff)
Debug event processing
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run.sh3
-rw-r--r--tests/simple_receivet0_eth0_1s1r/out5
-rw-r--r--tests/simple_receivet0_eth0_1s1r/receiver.py14
-rw-r--r--tests/simple_receivet0_eth0_1s1r/sender.py5
-rwxr-xr-xtests/simple_receivet0_eth0_1s1r/simulator.py14
-rw-r--r--tests/simple_receivet0_eth0_1s1r/yoctosim.debug43
-rw-r--r--tests/simple_send0_eth0_1s1r/out16
-rw-r--r--tests/simple_send0_eth0_1s1r/receiver.py23
-rw-r--r--tests/simple_send0_eth0_1s1r/sender.py12
-rwxr-xr-xtests/simple_send0_eth0_1s1r/simulator.py14
-rw-r--r--tests/simple_send_eth0_2s1r/out2
-rw-r--r--tests/simple_send_eth0_3s1r/out14
-rw-r--r--tests/simple_send_eth0_3s1r/sender.py4
-rw-r--r--tests/simple_send_wlan0_1s2r/out2
-rw-r--r--tests/simple_sendt_eth0_1s1r/out4
-rw-r--r--tests/simple_sendt_wlan0_1s2r/out2
16 files changed, 162 insertions, 15 deletions
diff --git a/tests/run.sh b/tests/run.sh
index 8720736..ba51e28 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -10,6 +10,7 @@ wai=$(dirname $(readlink -f "$0")) # Current script directory
tests=$(find ${wai}/ -maxdepth 1 -mindepth 1 -type d) # Find tests
out=$(mktemp)
test_timeout=20
+abort=1
for test in ${tests}
do
@@ -38,7 +39,7 @@ do
echo "------------- Got -------------"
cat "$out";
rm "$out"
- exit 1
+ [ $abort -eq 1 ] && exit 1
fi
# Prepare for next test
diff --git a/tests/simple_receivet0_eth0_1s1r/out b/tests/simple_receivet0_eth0_1s1r/out
new file mode 100644
index 0000000..b9f63cd
--- /dev/null
+++ b/tests/simple_receivet0_eth0_1s1r/out
@@ -0,0 +1,5 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=0.000,src=n1] Receive failed code=-1
+[t=1.000,src=n1] Receive 1 bytes on eth0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=esds] Simulation ends
diff --git a/tests/simple_receivet0_eth0_1s1r/receiver.py b/tests/simple_receivet0_eth0_1s1r/receiver.py
new file mode 100644
index 0000000..bbb7ff7
--- /dev/null
+++ b/tests/simple_receivet0_eth0_1s1r/receiver.py
@@ -0,0 +1,14 @@
+#!/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 not works
+ receivet(api,0)
+ api.wait(1)
+ # Should works
+ receivet(api,0)
diff --git a/tests/simple_receivet0_eth0_1s1r/sender.py b/tests/simple_receivet0_eth0_1s1r/sender.py
new file mode 100644
index 0000000..45d0460
--- /dev/null
+++ b/tests/simple_receivet0_eth0_1s1r/sender.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,1)
+
diff --git a/tests/simple_receivet0_eth0_1s1r/simulator.py b/tests/simple_receivet0_eth0_1s1r/simulator.py
new file mode 100755
index 0000000..7c3e389
--- /dev/null
+++ b/tests/simple_receivet0_eth0_1s1r/simulator.py
@@ -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(debug=True)
diff --git a/tests/simple_receivet0_eth0_1s1r/yoctosim.debug b/tests/simple_receivet0_eth0_1s1r/yoctosim.debug
new file mode 100644
index 0000000..9d879f4
--- /dev/null
+++ b/tests/simple_receivet0_eth0_1s1r/yoctosim.debug
@@ -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:
+[]
diff --git a/tests/simple_send0_eth0_1s1r/out b/tests/simple_send0_eth0_1s1r/out
new file mode 100644
index 0000000..3ffee9f
--- /dev/null
+++ b/tests/simple_send0_eth0_1s1r/out
@@ -0,0 +1,16 @@
+[t=0.000,src=n0] Send 0 bytes to n1 on eth0
+[t=0.000,src=n1] Receive 0 bytes on eth0
+[t=0.000,src=n1] Received: Hello World!
+[t=0.000,src=n0] Send 0 bytes to n1 on eth0
+[t=0.000,src=n1] Receive 0 bytes on eth0
+[t=0.000,src=n1] Received: Hello World!
+[t=1.000,src=n0] Send 0 bytes to n1 on eth0
+[t=1.000,src=n1] Receive 0 bytes on eth0
+[t=1.000,src=n1] Received: Hello World!
+[t=3.000,src=n0] Send 0 bytes to n1 on eth0
+[t=3.000,src=n1] Receive 0 bytes on eth0
+[t=3.000,src=n1] Received: Hello World!
+[t=3.000,src=n0] Send 0 bytes to n1 on eth0
+[t=3.000,src=n1] Receive 0 bytes on eth0
+[t=3.000,src=n1] Received: Hello World!
+[t=3.000,src=esds] Simulation ends
diff --git a/tests/simple_send0_eth0_1s1r/receiver.py b/tests/simple_send0_eth0_1s1r/receiver.py
new file mode 100644
index 0000000..3f7a7db
--- /dev/null
+++ b/tests/simple_send0_eth0_1s1r/receiver.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+def receive(api):
+ ##### Simple receive
+ code, data=api.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+
+def execute(api):
+ receive(api)
+ # Simulated time t=0s here
+ receive(api)
+ # Simulated time t=0s here
+ receive(api)
+ # Simulated time t=1s here
+ receive(api)
+ # Simulated time t=3s here
+ code, data=api.receivet("eth0",0)
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+ # Simulated time t=3s here
+
+
diff --git a/tests/simple_send0_eth0_1s1r/sender.py b/tests/simple_send0_eth0_1s1r/sender.py
new file mode 100644
index 0000000..25472ac
--- /dev/null
+++ b/tests/simple_send0_eth0_1s1r/sender.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",0,1)
+ api.wait(0)
+ api.send("eth0","Hello World!",0,1)
+ api.wait(1)
+ api.send("eth0","Hello World!",0,1)
+ api.wait(1)
+ api.wait(1)
+ api.send("eth0","Hello World!",0,1)
+ api.send("eth0","Hello World!",0,1)
diff --git a/tests/simple_send0_eth0_1s1r/simulator.py b/tests/simple_send0_eth0_1s1r/simulator.py
new file mode 100755
index 0000000..7c3e389
--- /dev/null
+++ b/tests/simple_send0_eth0_1s1r/simulator.py
@@ -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(debug=True)
diff --git a/tests/simple_send_eth0_2s1r/out b/tests/simple_send_eth0_2s1r/out
index 4a5ebb8..663e5cf 100644
--- a/tests/simple_send_eth0_2s1r/out
+++ b/tests/simple_send_eth0_2s1r/out
@@ -1,7 +1,7 @@
[t=0.000,src=n0] Send 1 bytes to n2 on eth0
[t=0.000,src=n1] Send 1 bytes to n2 on eth0
[t=2.000,src=n2] Receive 1 bytes on eth0
-[t=2.000,src=n2] Received: Hello World from 0!
[t=2.000,src=n2] Receive 1 bytes on eth0
+[t=2.000,src=n2] Received: Hello World from 0!
[t=2.000,src=n2] Received: Hello World from 1!
[t=2.000,src=esds] Simulation ends
diff --git a/tests/simple_send_eth0_3s1r/out b/tests/simple_send_eth0_3s1r/out
index 8cf82a6..714a4c8 100644
--- a/tests/simple_send_eth0_3s1r/out
+++ b/tests/simple_send_eth0_3s1r/out
@@ -2,32 +2,32 @@
[t=0.000,src=n1] Send 1 bytes to n3 on eth0
[t=0.000,src=n2] Send 1 bytes to n3 on eth0
[t=3.000,src=n3] Receive 1 bytes on eth0
-[t=3.000,src=n3] Received: Hello World from 0!
[t=3.000,src=n3] Receive 1 bytes on eth0
-[t=3.000,src=n3] Received: Hello World from 1!
[t=3.000,src=n3] Receive 1 bytes on eth0
-[t=3.000,src=n3] Received: Hello World from 2!
+[t=3.000,src=n3] Received: Hello World from 0!
[t=3.000,src=n0] Send 2 bytes to n3 on eth0
[t=3.000,src=n1] Send 1 bytes to n3 on eth0
[t=3.000,src=n2] Send 1 bytes to n3 on eth0
+[t=3.000,src=n3] Received: Hello World from 1!
+[t=3.000,src=n3] Received: Hello World from 2!
[t=6.000,src=n3] Receive 1 bytes on eth0
-[t=6.000,src=n3] Received: Hello World from 1!
[t=6.000,src=n3] Receive 1 bytes on eth0
+[t=6.000,src=n3] Received: Hello World from 1!
[t=6.000,src=n3] Received: Hello World from 2!
[t=7.000,src=n3] Receive 2 bytes on eth0
-[t=7.000,src=n3] Received: Hello World from 0!
+[t=7.000,src=n3] Received: Hello World (2bytes) from 0!
[t=7.000,src=n0] Send 2 bytes to n3 on eth0
[t=7.000,src=n1] Send 2 bytes to n3 on eth0
[t=7.000,src=n2] Send 1 bytes to n3 on eth0
[t=10.000,src=n3] Receive 1 bytes on eth0
[t=10.000,src=n3] Received: Hello World from 2!
[t=12.000,src=n3] Receive 2 bytes on eth0
-[t=12.000,src=n3] Received: Hello World from 0!
[t=12.000,src=n3] Receive 2 bytes on eth0
-[t=12.000,src=n3] Received: Hello World from 1!
+[t=12.000,src=n3] Received: Hello World (2bytes) from 0!
[t=12.000,src=n0] Send 1 bytes to n3 on eth0
[t=12.000,src=n1] Send 2 bytes to n3 on eth0
[t=12.000,src=n2] Send 3 bytes to n3 on eth0
+[t=12.000,src=n3] Received: Hello World (2bytes) from 1!
[t=15.000,src=n3] Receive 1 bytes on eth0
[t=15.000,src=n3] Received: Hello World from 0!
[t=17.000,src=n3] Receive 2 bytes on eth0
diff --git a/tests/simple_send_eth0_3s1r/sender.py b/tests/simple_send_eth0_3s1r/sender.py
index d3c7bf2..6b8312b 100644
--- a/tests/simple_send_eth0_3s1r/sender.py
+++ b/tests/simple_send_eth0_3s1r/sender.py
@@ -8,14 +8,14 @@ def execute(api):
# These send should start at 3s and be completed at 7s
if api.node_id==0:
- api.send("eth0","Hello World from {}!".format(api.node_id),2,3) # Should lasts 3s + 1s = 4s
+ api.send("eth0","Hello World (2bytes) from {}!".format(api.node_id),2,3) # Should lasts 3s + 1s = 4s
else:
api.send("eth0","Hello World from {}!".format(api.node_id),1,3) # Should lasts 3s
api.wait(1) # Sync with node 0 at 7s
# Those sends should start at 7s and be completed at 12s
if api.node_id<=1:
- api.send("eth0","Hello World from {}!".format(api.node_id),2,3) # Should last 3s + 2s = 5s
+ api.send("eth0","Hello World (2bytes) from {}!".format(api.node_id),2,3) # Should last 3s + 2s = 5s
# Completed at 12s since 3 nodes are sharing the bandwidth up to 10s
# then the 2 two remaining node send their last byte up to 12s
else:
diff --git a/tests/simple_send_wlan0_1s2r/out b/tests/simple_send_wlan0_1s2r/out
index 98cc425..bb052dd 100644
--- a/tests/simple_send_wlan0_1s2r/out
+++ b/tests/simple_send_wlan0_1s2r/out
@@ -1,7 +1,7 @@
[t=0.000,src=n0] Send 1 bytes on wlan0
[t=1.000,src=n1] Receive 1 bytes on wlan0
-[t=1.000,src=n1] Received: Hello World!
[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
diff --git a/tests/simple_sendt_eth0_1s1r/out b/tests/simple_sendt_eth0_1s1r/out
index e6d70d5..254b865 100644
--- a/tests/simple_sendt_eth0_1s1r/out
+++ b/tests/simple_sendt_eth0_1s1r/out
@@ -1,11 +1,11 @@
[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 worked!
+[t=1.000,src=n1] Received: Hello World!
[t=1.000,src=n0] Send 1 bytes to n1 on eth0
[t=1.500,src=n0] Send failed
[t=1.500,src=n0] Send 1 bytes to n1 on eth0
[t=2.500,src=n1] Receive 1 bytes on eth0
-[t=2.500,src=n1] Received: Hello World!
[t=2.500,src=n0] Send worked!
+[t=2.500,src=n1] Received: Hello World!
[t=2.500,src=esds] Simulation ends
diff --git a/tests/simple_sendt_wlan0_1s2r/out b/tests/simple_sendt_wlan0_1s2r/out
index 5a4f82c..9428958 100644
--- a/tests/simple_sendt_wlan0_1s2r/out
+++ b/tests/simple_sendt_wlan0_1s2r/out
@@ -1,7 +1,7 @@
[t=0.000,src=n0] Send 1 bytes on wlan0
[t=1.000,src=n1] Receive 1 bytes on wlan0
-[t=1.000,src=n1] Received: Hello World!
[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=n0] Send 1 bytes on wlan0
[t=1.500,src=esds] Simulation ends