From 964310303db99f17779eb768f413ccb355d66c95 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 23 Apr 2009 10:43:16 +0000 Subject: [PATCH] cloned sky ip ping test, but for contiki motes --- .../contiki_tests/ip_cooja_telnet_ping.csc | 112 ++++++++++++++++++ .../contiki_tests/ip_cooja_telnet_ping.info | 1 + .../contiki_tests/ip_cooja_telnet_ping.js | 44 +++++++ 3 files changed, 157 insertions(+) create mode 100644 tools/cooja/contiki_tests/ip_cooja_telnet_ping.csc create mode 100644 tools/cooja/contiki_tests/ip_cooja_telnet_ping.info create mode 100644 tools/cooja/contiki_tests/ip_cooja_telnet_ping.js diff --git a/tools/cooja/contiki_tests/ip_cooja_telnet_ping.csc b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.csc new file mode 100644 index 000000000..b462fdddb --- /dev/null +++ b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.csc @@ -0,0 +1,112 @@ + + + + My simulation + 1 + 1 + 123456 + 1000 + + se.sics.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + se.sics.cooja.contikimote.ContikiMoteType + mtype1 + Contiki Mote Type #1 + ../../../examples/telnet-server/telnet-server.c + make telnet-server.cooja TARGET=cooja DEFINES=WITH_UIP=1 + se.sics.cooja.interfaces.Position + se.sics.cooja.interfaces.Battery + se.sics.cooja.contikimote.interfaces.ContikiVib + se.sics.cooja.contikimote.interfaces.ContikiMoteID + se.sics.cooja.contikimote.interfaces.ContikiRS232 + se.sics.cooja.contikimote.interfaces.ContikiBeeper + se.sics.cooja.interfaces.RimeAddress + se.sics.cooja.contikimote.interfaces.ContikiIPAddress + se.sics.cooja.contikimote.interfaces.ContikiRadio + se.sics.cooja.contikimote.interfaces.ContikiButton + se.sics.cooja.contikimote.interfaces.ContikiPIR + se.sics.cooja.contikimote.interfaces.ContikiClock + se.sics.cooja.contikimote.interfaces.ContikiLED + se.sics.cooja.contikimote.interfaces.ContikiCFS + se.sics.cooja.interfaces.Mote2MoteRelations + false + uIPv4 + + + se.sics.cooja.contikimote.ContikiMote + mtype1 + + se.sics.cooja.interfaces.Position + 44.40540999693696 + 81.18952332401878 + 0.0 + + + se.sics.cooja.interfaces.Battery + false + + + se.sics.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + + + se.sics.cooja.plugins.SimControl + 248 + 4 + 200 + 2 + 2 + false + + + se.sics.cooja.plugins.Visualizer + + Addresses: IP or Rime + Mote IDs + Radio environment (UDGM) + LEDs + + 300 + 3 + 110 + 723 + 0 + false + + + se.sics.cooja.plugins.NativeIPGateway + 0 + + \Device\NPF_{53CBA059-40AA-4822-BB53-7A5B9AFE77D6} + true + + 388 + 2 + 331 + 635 + 109 + false + + + se.sics.cooja.plugins.MoteInterfaceViewer + 0 + + Serial port + 0,0 + + 388 + 1 + 234 + 635 + 420 + false + + + diff --git a/tools/cooja/contiki_tests/ip_cooja_telnet_ping.info b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.info new file mode 100644 index 000000000..07257425a --- /dev/null +++ b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.info @@ -0,0 +1 @@ +1xContiki node: examples/native-ip/telnet-server.c. Sends 10 pings to 172.16.0.1 via the native IP stack. Test succeeds if more than 5 ping replies are received. diff --git a/tools/cooja/contiki_tests/ip_cooja_telnet_ping.js b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.js new file mode 100644 index 000000000..637dfdac5 --- /dev/null +++ b/tools/cooja/contiki_tests/ip_cooja_telnet_ping.js @@ -0,0 +1,44 @@ +TIMEOUT(30000); + +/* conf */ +nrReplies = 0; +ipAddress = "172.16.0.1"; +osName = java.lang.System.getProperty("os.name").toLowerCase(); +if (osName.startsWith("win")) { + pingCmd = "ping -n 10 " + ipAddress; +} else { + pingCmd = "ping -c 10 " + ipAddress; +} +replyMsg = "from " + ipAddress; + +/* mote startup */ +WAIT_UNTIL(msg.contains('Telnet server')); + +/* override simulation delay, test times out is too fast otherwise */ +mote.getSimulation().setDelayTime(1); + +/* start ping process */ +var runnableObj = new Object(); +runnableObj.run = function() { + pingProcess = new java.lang.Runtime.getRuntime().exec(pingCmd); + log.log("cmd> " + pingCmd + "\n"); + + stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(pingProcess.getInputStream())); + while ((line = stdIn.readLine()) != null) { + log.log("> " + line + "\n"); + if (line.contains(replyMsg)) { + nrReplies++; + //log.log("reply #" + nrReplies + "\n"); + } + } + pingProcess.destroy(); + + if (nrReplies > 5) { + log.testOK(); /* Report test success and quit */ + } else { + log.log("Only " + nrReplies + "/10 ping replies was received\n"); + log.testFailed(); + } +} +var thread = new java.lang.Thread(new java.lang.Runnable(runnableObj)); +thread.start();