From d0ae9f329685a19136cfd9a890b305db3bc384b9 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 30 Jun 2022 12:11:59 +0200 Subject: Improve tests --- tests/api_send_eth0_2s1r/out | 7 +++++++ tests/api_send_eth0_2s1r/receiver.py | 13 +++++++++++++ tests/api_send_eth0_2s1r/sender.py | 5 +++++ tests/api_send_eth0_2s1r/simulator.py | 15 +++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 tests/api_send_eth0_2s1r/out create mode 100644 tests/api_send_eth0_2s1r/receiver.py create mode 100644 tests/api_send_eth0_2s1r/sender.py create mode 100755 tests/api_send_eth0_2s1r/simulator.py (limited to 'tests/api_send_eth0_2s1r') diff --git a/tests/api_send_eth0_2s1r/out b/tests/api_send_eth0_2s1r/out new file mode 100644 index 0000000..663e5cf --- /dev/null +++ b/tests/api_send_eth0_2s1r/out @@ -0,0 +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] 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/api_send_eth0_2s1r/receiver.py b/tests/api_send_eth0_2s1r/receiver.py new file mode 100644 index 0000000..2f268fd --- /dev/null +++ b/tests/api_send_eth0_2s1r/receiver.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +def execute(api): + ##### Simple receive from node 0 + code, data=api.receive("eth0") + msg="Received: "+data if code == 0 else "Receive failed code="+str(code) + api.log(msg) + + ##### Simple receive from node 1 + code, data=api.receive("eth0") + msg="Received: "+data if code == 0 else "Receive failed code="+str(code) + api.log(msg) + diff --git a/tests/api_send_eth0_2s1r/sender.py b/tests/api_send_eth0_2s1r/sender.py new file mode 100644 index 0000000..90daae5 --- /dev/null +++ b/tests/api_send_eth0_2s1r/sender.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +def execute(api): + api.send("eth0","Hello World from {}!".format(api.node_id),1,2) + diff --git a/tests/api_send_eth0_2s1r/simulator.py b/tests/api_send_eth0_2s1r/simulator.py new file mode 100755 index 0000000..4cce1d0 --- /dev/null +++ b/tests/api_send_eth0_2s1r/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("sender") +s.create_node("receiver") + +s.run() -- cgit v1.2.3