From b2a1dd21563bed8200250e6ee4a9e07d61f0afe9 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Thu, 8 Jan 2009 16:41:48 +0000 Subject: [PATCH] updated threaded contiki test scripts --- tools/cooja/contiki_tests/cooja_helloworld.js | 9 ++++--- .../cooja/contiki_tests/ip_sky_telnet_ping.js | 24 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/tools/cooja/contiki_tests/cooja_helloworld.js b/tools/cooja/contiki_tests/cooja_helloworld.js index fc357937b..4f3fd415d 100644 --- a/tools/cooja/contiki_tests/cooja_helloworld.js +++ b/tools/cooja/contiki_tests/cooja_helloworld.js @@ -1,5 +1,4 @@ -if (msg.startsWith('Hello, world')) { - log.testOK(); -} else { - log.testFailed(); -} +TIMEOUT(2000, log.log("last message: " + msg + "\n")); + +WAIT_UNTIL(msg.equals('Hello, world')); +log.testOK(); diff --git a/tools/cooja/contiki_tests/ip_sky_telnet_ping.js b/tools/cooja/contiki_tests/ip_sky_telnet_ping.js index ea3306014..d61940b9c 100644 --- a/tools/cooja/contiki_tests/ip_sky_telnet_ping.js +++ b/tools/cooja/contiki_tests/ip_sky_telnet_ping.js @@ -1,7 +1,7 @@ -if (!msg.contains('Sky telnet process')) { - return; -} +TIMEOUT(120000); +/* conf */ +nrReplies = 0; ipAddress = "172.16.1.0"; osName = java.lang.System.getProperty("os.name").toLowerCase(); if (osName.startsWith("win")) { @@ -11,14 +11,10 @@ if (osName.startsWith("win")) { } replyMsg = "from " + ipAddress; -ok = global.get('started_ping'); -if (ok == true) { - //log.log("ping already started\n"); - return; -} -global.put('started_ping', true); -global.put('replies', ""); +/* mote startup */ +WAIT_UNTIL(msg.contains('Sky telnet process')); +/* start ping process */ var runnableObj = new Object(); runnableObj.run = function() { pingProcess = new java.lang.Runtime.getRuntime().exec(pingCmd); @@ -28,16 +24,16 @@ runnableObj.run = function() { while ((line = stdIn.readLine()) != null) { log.log("> " + line + "\n"); if (line.contains(replyMsg)) { - global.put('replies', global.get('replies') + "1"); - //log.log("reply #" + global.get('replies').length() + "\n"); + nrReplies++; + //log.log("reply #" + nrReplies + "\n"); } } pingProcess.destroy(); - if (global.get('replies').length() > 5) { + if (nrReplies > 5) { log.testOK(); /* Report test success and quit */ } else { - log.log("Only " + global.get('replies').length() + "/10 ping replies was received\n"); + log.log("Only " + nrReplies + "/10 ping replies was received\n"); log.testFailed(); } }