updated threaded contiki test scripts
This commit is contained in:
parent
17fa4513dc
commit
000fd29f4c
|
@ -1,34 +1,25 @@
|
|||
/* Only handle receive messages */
|
||||
if (!msg.contains('received')) {
|
||||
return;
|
||||
TIMEOUT(120000);
|
||||
|
||||
var nr_packets = new Array();
|
||||
for (i=1; i <= 10; i++) {
|
||||
nr_packets[i] = 0;
|
||||
}
|
||||
|
||||
/* Log receiver */
|
||||
count = global.get("count_" + id);
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
global.put("count_" + id, count);
|
||||
while (true) {
|
||||
|
||||
log.log("Node " + id + " received message: " + count + "\n");
|
||||
/* Listen for receive notifications */
|
||||
if (msg.contains('abc message received')) {
|
||||
|
||||
/* Did all nodes (1-10) receive a message? */
|
||||
for (i = 1; i <= 10; i++) {
|
||||
result = global.get("count_" + i);
|
||||
if (result == null || result == 0) {
|
||||
log.log("Node " + i + " did not yet receive a message\n");
|
||||
return;
|
||||
/* Log receiving node */
|
||||
nr_packets[id] ++;
|
||||
log.log("Node " + id + " received message: " + nr_packets[id] + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Report test info */
|
||||
log.log("TEST INFO: ");
|
||||
for (i = 1; i <= 10; i++) {
|
||||
result = global.get("count_" + i);
|
||||
log.log(java.lang.Integer.toString(result) + " ");
|
||||
}
|
||||
log.log("\n");
|
||||
/* Did all nodes (1-10) receive at least one message? */
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if (nr_packets[id] < 1) break;
|
||||
if (nr_packets[id] == 10) log.testOK();
|
||||
}
|
||||
|
||||
log.log("TEST OK\n"); /* Report test success */
|
||||
mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/
|
||||
YIELD();
|
||||
}
|
||||
|
|
|
@ -1,28 +1,22 @@
|
|||
/* Only handle receive messages */
|
||||
if (!msg.contains('received')) {
|
||||
return;
|
||||
}
|
||||
TIMEOUT(100000, log.log("Node 1: " + nr_packets[1] + ".\nNode 2: " + nr_packets[2] + ".\n"));
|
||||
|
||||
/* Count received packets */
|
||||
result = global.get("recv_" + id);
|
||||
if (result == null) {
|
||||
result = 0;
|
||||
}
|
||||
result++;
|
||||
global.put("recv_" + id, result);
|
||||
log.log(id + " received " + result + " messages\n");
|
||||
nr_packets = new Array();
|
||||
nr_packets[1] = 0;
|
||||
nr_packets[2] = 0;
|
||||
|
||||
/* Did all nodes (1 and 2) receive a message? */
|
||||
for (i = 1; i <= 2; i++) {
|
||||
result = global.get("recv_" + i);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
if (result < 30) {
|
||||
return;
|
||||
while (true) {
|
||||
/* Only handle receive messages */
|
||||
YIELD_THEN_WAIT_UNTIL(msg.contains('received'));
|
||||
|
||||
/* Count received packets */
|
||||
nr_packets[id]++;
|
||||
//log.log("Node " + id + " received " + nr_packets[id] + " messages\n");
|
||||
|
||||
if (nr_packets[1] >= 30 && nr_packets[2] >= 30) {
|
||||
log.log("Node 1: " + nr_packets[1] + ".\nNode 2: " + nr_packets[2] + ".\n");
|
||||
log.testOK(); /* Report test success */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
log.log("Node 1 received " + global.get("recv_1") + " messages\n");
|
||||
log.log("Node 2 received " + global.get("recv_2") + " messages\n");
|
||||
log.testOK(); /* Report test success */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if (msg.startsWith('Completion time')) {
|
||||
log.log(msg + "\n");
|
||||
log.testOK(); /* Report test success and quit */
|
||||
}
|
||||
TIMEOUT(120000);
|
||||
|
||||
WAIT_UNTIL(msg.startsWith('Completion time'));
|
||||
log.testOK();
|
||||
|
|
|
@ -1,63 +1,46 @@
|
|||
TIMEOUT(120000);
|
||||
|
||||
nr_recv = 0;
|
||||
nr_timedout = 0;
|
||||
nr_sent = 0;
|
||||
|
||||
while (nr_sent < 10) {
|
||||
|
||||
/* Count received packets */
|
||||
if (msg.contains('received')) {
|
||||
result = global.get("recv");
|
||||
if (result == null) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result++;
|
||||
global.put("recv", result);
|
||||
log.log("Received packets count now: " + result + "\n");
|
||||
nr_recv++;
|
||||
log.log("Received packets count now: " + nr_recv + "\n");
|
||||
}
|
||||
|
||||
/* Count timed out packets */
|
||||
if (msg.contains('timed out')) {
|
||||
result = global.get("timeout");
|
||||
if (result == null) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result++;
|
||||
global.put("timeout", result);
|
||||
log.log("Timed out packets count now: " + result + "\n");
|
||||
else if (msg.contains('timed out')) {
|
||||
nr_timedout++;
|
||||
log.log("Timed out packets count now: " + nr_timedout + "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Count sent packets */
|
||||
if (msg.contains('sent to')) {
|
||||
result = global.get("sent");
|
||||
if (result == null) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result++;
|
||||
global.put("sent", result);
|
||||
log.log("Sent packets count now: " + result + "\n");
|
||||
else if (msg.contains('sent to')) {
|
||||
nr_sent++;
|
||||
log.log("Sent packets count now: " + nr_sent + "\n");
|
||||
}
|
||||
|
||||
/* Look for test completion */
|
||||
countSent = global.get("sent");
|
||||
if (countSent >= 10) {
|
||||
|
||||
/* Make sure received counter matches sent counter */
|
||||
countReceived = global.get("recv");
|
||||
if (countReceived < countSent) {
|
||||
log.log("Received < Sent: " + countReceived + " < " + countSent + "\n");
|
||||
log.log("Received packets less than acked sent packets!\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
/* Make sure some packets timed out (all from node 4) */
|
||||
countTimedOut = global.get("timeout");
|
||||
if (countTimedOut == null || countTimedOut < 2) {
|
||||
log.log("Timed out: " + countTimedOut + "\n");
|
||||
log.log("Too few packets timed out!\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
log.log("Received / Sent: " + countReceived + " / " + countSent + "\n");
|
||||
log.log("Timed out: " + countTimedOut + "\n");
|
||||
log.testOK();
|
||||
YIELD();
|
||||
}
|
||||
|
||||
/* Make sure received counter matches sent counter */
|
||||
if (nr_recv < nr_sent) {
|
||||
log.log("Received < Sent: " + nr_recv + " < " + nr_sent + "\n");
|
||||
log.log("Received packets less than acked sent packets!\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
/* Make sure some packets timed out (all from node 4) */
|
||||
if (nr_timedout < 2) {
|
||||
log.log("Timed out: " + nr_timedout + "\n");
|
||||
log.log("Too few packets timed out!\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
log.log("Received / Sent: " + nr_recv + " / " + nr_sent + "\n");
|
||||
log.log("Timed out: " + nr_timedout + "\n");
|
||||
log.testOK();
|
||||
|
|
|
@ -1,36 +1,25 @@
|
|||
/* Initiate trickle from node 1 by clicking button (once) */
|
||||
result = global.get("recv_1");
|
||||
if (result == null) {
|
||||
if (id != 1) {
|
||||
return;
|
||||
}
|
||||
TIMEOUT(120000, log.log(nr_packets[1] + ", " + nr_packets[2] + ", " + nr_packets[3] + ", " + nr_packets[4] + ", " + nr_packets[5] + ", " + nr_packets[6] + ", " + nr_packets[7] + ", " + nr_packets[8] + ", " + nr_packets[9] + ", " + nr_packets[10] + "\n"));
|
||||
|
||||
if (!msg.contains('Starting')) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.log("Clicking node 1 button\n");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
global.put("recv_1", "ok");
|
||||
return;
|
||||
nr_packets = new Array();
|
||||
for (i=1; i <= 10; i++) {
|
||||
nr_packets[i] = 0;
|
||||
}
|
||||
|
||||
/* Only handle receive messages */
|
||||
if (!msg.contains('received')) {
|
||||
return;
|
||||
}
|
||||
WAIT_UNTIL(id == 1 && msg.contains('Starting'));
|
||||
log.log("Node 1 started. Clicking node button.\n");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
|
||||
/* Remember receiver */
|
||||
global.put("recv_" + id, "ok");
|
||||
log.log(id + " received a message\n");
|
||||
while (true) {
|
||||
/* Only handle receive messages */
|
||||
WAIT_UNTIL(msg.contains('received'));
|
||||
|
||||
/* Did all nodes (1-10) receive a message? */
|
||||
for (i = 1; i <= 10; i++) {
|
||||
result = global.get("recv_" + i);
|
||||
if (result == null) {
|
||||
return;
|
||||
/* Remember receiving node */
|
||||
log.log(id + " received a message\n");
|
||||
nr_packets[id]++;
|
||||
|
||||
/* Did all nodes (2-10) receive a message? */
|
||||
for (i = 2; i <= 10; i++) {
|
||||
if (nr_packets[i] < 1) break;
|
||||
if (i == 10) log.log("TEST OK\n"); /* Report test success */
|
||||
}
|
||||
}
|
||||
|
||||
log.log("TEST OK\n"); /* Report test success */
|
||||
mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
if (msg.startsWith('Coffee file test: 0')) {
|
||||
global.put("coffee_file_test", true);
|
||||
} else if (msg.startsWith('Coffee file test')) {
|
||||
global.put("coffee_file_test", false);
|
||||
} else if (msg.startsWith('Coffee garbage collection test: 0')) {
|
||||
global.put("coffee_gc_test", true);
|
||||
} else if (msg.startsWith('Coffee garbage collection test')) {
|
||||
global.put("coffee_gc_test", false);
|
||||
TIMEOUT(60000);
|
||||
|
||||
fileOK = null;
|
||||
gcOK = null;
|
||||
|
||||
while (fileOK == null || gcOK == null) {
|
||||
YIELD();
|
||||
|
||||
if (msg.startsWith('Coffee file test: 0')) {
|
||||
fileOK = true;
|
||||
} else if (msg.startsWith('Coffee file test')) {
|
||||
fileOK = false;
|
||||
} else if (msg.startsWith('Coffee garbage collection test: 0')) {
|
||||
gcOK = true;
|
||||
} else if (msg.startsWith('Coffee garbage collection test')) {
|
||||
gcOK = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (global.get("coffee_file_test") == null) {
|
||||
//log.log("file test not finished yet\n");
|
||||
return;
|
||||
}
|
||||
if (global.get("coffee_gc_test") == null) {
|
||||
//log.log("gc test not finished yet\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (global.get("coffee_gc_test") == false) {
|
||||
if (gcOK == false) {
|
||||
log.log("coffee garbage collection failed\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
if (global.get("coffee_file_test") == false) {
|
||||
if (fileOK == false) {
|
||||
log.log("coffee file test failed\n");
|
||||
log.testFailed();
|
||||
}
|
||||
|
||||
log.testOK();
|
||||
if (!fileOK || !gcOK) {
|
||||
log.testFailed();
|
||||
} else {
|
||||
log.testOK();
|
||||
}
|
||||
|
|
|
@ -1,60 +1,51 @@
|
|||
/* Wait until all nodes have booted */
|
||||
if (msg.startsWith('Starting')) {
|
||||
log.log("Node " + id + " booted\n");
|
||||
global.put("boot_" + id, true);
|
||||
TIMEOUT(120000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
|
||||
|
||||
/* Conf. */
|
||||
booted = new Array();
|
||||
count = new Array();
|
||||
nrNodes = 7;
|
||||
nodes_starting = true;
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
booted[i] = false;
|
||||
count[i] = 0;
|
||||
}
|
||||
for (i = 1; i <= 7; i++) {
|
||||
result = global.get("boot_" + i);
|
||||
if (result == null || result == false) {
|
||||
/*log.log("Node " + i + " did not yet boot\n");*/
|
||||
return;
|
||||
|
||||
/* Wait until all nodes have started */
|
||||
while (nodes_starting) {
|
||||
WAIT_UNTIL(msg.startsWith('Starting'));
|
||||
log.log("Node " + id + " booted\n");
|
||||
booted[id] = true;
|
||||
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (!booted[i]) break;
|
||||
if (i == nrNodes) nodes_starting = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create sink */
|
||||
result = global.get("created_sink");
|
||||
if (result == null || result == false) {
|
||||
log.log("All nodes booted, creating sink at node " + id + "\n");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
global.put("created_sink", true);
|
||||
return;
|
||||
}
|
||||
log.log("All nodes booted, creating sink at node " + id + "\n");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
|
||||
/* Log incoming sensor data */
|
||||
source = msg.split(" ")[0];
|
||||
count = global.get("count_" + source);
|
||||
log.log("Got data from node " + source + "\n");
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
global.put("count_" + source, count);
|
||||
while (true) {
|
||||
YIELD();
|
||||
|
||||
/* Fail if any node has transmitted more than 20 packets */
|
||||
for (i = 1; i <= 7; i++) {
|
||||
result = global.get("count_" + i);
|
||||
if (result > 20) {
|
||||
/* Count sensor data packets */
|
||||
source = msg.split(" ")[0];
|
||||
log.log("Got data from node " + source + "\n");
|
||||
count[source]++;
|
||||
|
||||
log.log("FAILED: received/node: " +
|
||||
global.get("count_1") + " " +
|
||||
global.get("count_2") + " " +
|
||||
global.get("count_3") + " " +
|
||||
global.get("count_4") + " " +
|
||||
global.get("count_5") + " " +
|
||||
global.get("count_6") + " " +
|
||||
global.get("count_7") + "\n");
|
||||
log.testFailed(); /* We are done! */
|
||||
return;
|
||||
/* Fail if any node has transmitted more than 20 packets */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] > 20) {
|
||||
log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
|
||||
log.testFailed(); /* We are done! */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait until we have received data from all nodes */
|
||||
for (i = 1; i <= 7; i++) {
|
||||
result = global.get("count_" + i);
|
||||
if (result < 5) {
|
||||
/*log.log("Node " + i + " only sent " + result + " messages yet\n");*/
|
||||
return;
|
||||
/* Wait until we have received data from all nodes */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] < 5) break;
|
||||
if (i == nrNodes) log.testOK();
|
||||
}
|
||||
}
|
||||
|
||||
log.testOK(); /* We are done! */
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/* Script is called once for every node log output. */
|
||||
/* Input variables: Mote mote, int id, String msg. */
|
||||
TIMEOUT(2000, log.log("last message: " + msg + "\n"));
|
||||
|
||||
if (msg.startsWith('Hello, world')) {
|
||||
log.log('TEST OK\n'); /* Report test success */
|
||||
mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/
|
||||
}
|
||||
WAIT_UNTIL(msg.equals('Hello, world'));
|
||||
log.testOK();
|
||||
|
|
|
@ -1,52 +1,15 @@
|
|||
TIMEOUT(2000, log.log("last message: " + msg + "\n"));
|
||||
|
||||
/* Wait until node has booted */
|
||||
if (msg.startsWith('Starting')) {
|
||||
log.log("Shell started\n");
|
||||
global.put("started", true);
|
||||
}
|
||||
result = global.get("started");
|
||||
if (result == null || result == false) {
|
||||
/*log.log("Shell did not yet start\n");*/
|
||||
return;
|
||||
}
|
||||
WAIT_UNTIL(msg.startsWith('Starting'));
|
||||
log.log("Shell started\n");
|
||||
|
||||
/* Send command ps */
|
||||
result = global.get("command_ps");
|
||||
if (result == null || result == false) {
|
||||
log.log("Sending 'ps'\n");
|
||||
global.put("command_ps", true);
|
||||
node.write("ps");
|
||||
return;
|
||||
}
|
||||
/* Test command: ps */
|
||||
node.write("ps");
|
||||
WAIT_UNTIL(msg.startsWith('Event timer'));
|
||||
|
||||
/* Wait for ps response */
|
||||
if (msg.startsWith('Event timer')) {
|
||||
log.log("Reponse from 'ps'\n");
|
||||
global.put("response_ps", true);
|
||||
}
|
||||
result = global.get("response_ps");
|
||||
if (result == null || result == false) {
|
||||
/*log.log("Waiting for 'ps' response\n");*/
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send command help */
|
||||
result = global.get("command_help");
|
||||
if (result == null || result == false) {
|
||||
log.log("Sending 'help'\n");
|
||||
global.put("command_help", true);
|
||||
node.write("help");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Wait for help response */
|
||||
if (msg.startsWith('write <filename>')) {
|
||||
log.log("Reponse from 'help'\n");
|
||||
global.put("response_help", true);
|
||||
}
|
||||
result = global.get("response_help");
|
||||
if (result == null || result == false) {
|
||||
/*log.log("Waiting for 'help' response\n");*/
|
||||
return;
|
||||
}
|
||||
/* Test command: help */
|
||||
node.write("help");
|
||||
WAIT_UNTIL(msg.startsWith('write <filename>'));
|
||||
|
||||
log.testOK(); /* We are done! */
|
|
@ -1,9 +1,4 @@
|
|||
/* Script is called once for every node log output. */
|
||||
/* Input variables: Mote mote, int id, String msg. */
|
||||
TIMEOUT(2000, log.log("last message: " + msg + "\n"));
|
||||
|
||||
/* Contiki test script example */
|
||||
if (msg.startsWith('Contiki')) {
|
||||
log.testOK(); /* Report test success */
|
||||
} else {
|
||||
log.testFailed(); /* Report test failure */
|
||||
}
|
||||
WAIT_UNTIL(msg.startsWith('Contiki'));
|
||||
log.testOK();
|
||||
|
|
Loading…
Reference in a new issue