updated threaded contiki test scripts

This commit is contained in:
fros4943 2009-01-08 17:11:06 +00:00
parent 17fa4513dc
commit 000fd29f4c
10 changed files with 178 additions and 274 deletions

View file

@ -1,34 +1,25 @@
/* Only handle receive messages */ TIMEOUT(120000);
if (!msg.contains('received')) {
return; var nr_packets = new Array();
for (i=1; i <= 10; i++) {
nr_packets[i] = 0;
} }
/* Log receiver */ while (true) {
count = global.get("count_" + id);
if (count == null) {
count = 0;
}
count++;
global.put("count_" + id, count);
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? */ /* Log receiving node */
for (i = 1; i <= 10; i++) { nr_packets[id] ++;
result = global.get("count_" + i); log.log("Node " + id + " received message: " + nr_packets[id] + "\n");
if (result == null || result == 0) {
log.log("Node " + i + " did not yet receive a message\n");
return;
} }
}
/* Report test info */ /* Did all nodes (1-10) receive at least one message? */
log.log("TEST INFO: "); for (i = 1; i <= 10; i++) {
for (i = 1; i <= 10; i++) { if (nr_packets[id] < 1) break;
result = global.get("count_" + i); if (nr_packets[id] == 10) log.testOK();
log.log(java.lang.Integer.toString(result) + " "); }
}
log.log("\n");
log.log("TEST OK\n"); /* Report test success */ YIELD();
mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/ }

View file

@ -1,28 +1,22 @@
/* Only handle receive messages */ TIMEOUT(100000, log.log("Node 1: " + nr_packets[1] + ".\nNode 2: " + nr_packets[2] + ".\n"));
if (!msg.contains('received')) {
return;
}
/* Count received packets */ nr_packets = new Array();
result = global.get("recv_" + id); nr_packets[1] = 0;
if (result == null) { nr_packets[2] = 0;
result = 0;
}
result++;
global.put("recv_" + id, result);
log.log(id + " received " + result + " messages\n");
/* Did all nodes (1 and 2) receive a message? */ while (true) {
for (i = 1; i <= 2; i++) { /* Only handle receive messages */
result = global.get("recv_" + i); YIELD_THEN_WAIT_UNTIL(msg.contains('received'));
if (result == null) {
return; /* Count received packets */
} nr_packets[id]++;
if (result < 30) { //log.log("Node " + id + " received " + nr_packets[id] + " messages\n");
return;
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 */

View file

@ -1,4 +1,4 @@
if (msg.startsWith('Completion time')) { TIMEOUT(120000);
log.log(msg + "\n");
log.testOK(); /* Report test success and quit */ WAIT_UNTIL(msg.startsWith('Completion time'));
} log.testOK();

View file

@ -1,63 +1,46 @@
TIMEOUT(120000);
nr_recv = 0;
nr_timedout = 0;
nr_sent = 0;
while (nr_sent < 10) {
/* Count received packets */ /* Count received packets */
if (msg.contains('received')) { if (msg.contains('received')) {
result = global.get("recv"); nr_recv++;
if (result == null) { log.log("Received packets count now: " + nr_recv + "\n");
result = 0;
}
result++;
global.put("recv", result);
log.log("Received packets count now: " + result + "\n");
} }
/* Count timed out packets */ /* Count timed out packets */
if (msg.contains('timed out')) { else if (msg.contains('timed out')) {
result = global.get("timeout"); nr_timedout++;
if (result == null) { log.log("Timed out packets count now: " + nr_timedout + "\n");
result = 0;
}
result++;
global.put("timeout", result);
log.log("Timed out packets count now: " + result + "\n");
} }
/* Count sent packets */ /* Count sent packets */
if (msg.contains('sent to')) { else if (msg.contains('sent to')) {
result = global.get("sent"); nr_sent++;
if (result == null) { log.log("Sent packets count now: " + nr_sent + "\n");
result = 0;
}
result++;
global.put("sent", result);
log.log("Sent packets count now: " + result + "\n");
} }
/* Look for test completion */ YIELD();
countSent = global.get("sent"); }
if (countSent >= 10) {
/* Make sure received counter matches sent counter */ /* Make sure received counter matches sent counter */
countReceived = global.get("recv"); if (nr_recv < nr_sent) {
if (countReceived < countSent) { log.log("Received < Sent: " + nr_recv + " < " + nr_sent + "\n");
log.log("Received < Sent: " + countReceived + " < " + countSent + "\n");
log.log("Received packets less than acked sent packets!\n"); log.log("Received packets less than acked sent packets!\n");
log.testFailed(); log.testFailed();
} }
/* Make sure some packets timed out (all from node 4) */ /* Make sure some packets timed out (all from node 4) */
countTimedOut = global.get("timeout"); if (nr_timedout < 2) {
if (countTimedOut == null || countTimedOut < 2) { log.log("Timed out: " + nr_timedout + "\n");
log.log("Timed out: " + countTimedOut + "\n");
log.log("Too few packets timed out!\n"); log.log("Too few packets timed out!\n");
log.testFailed(); log.testFailed();
}
log.log("Received / Sent: " + countReceived + " / " + countSent + "\n");
log.log("Timed out: " + countTimedOut + "\n");
log.testOK();
} }
log.log("Received / Sent: " + nr_recv + " / " + nr_sent + "\n");
log.log("Timed out: " + nr_timedout + "\n");
log.testOK();

View file

@ -1,36 +1,25 @@
/* Initiate trickle from node 1 by clicking button (once) */ 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"));
result = global.get("recv_1");
if (result == null) {
if (id != 1) {
return;
}
if (!msg.contains('Starting')) { nr_packets = new Array();
return; for (i=1; i <= 10; i++) {
} nr_packets[i] = 0;
log.log("Clicking node 1 button\n");
mote.getInterfaces().getButton().clickButton()
global.put("recv_1", "ok");
return;
} }
/* Only handle receive messages */ WAIT_UNTIL(id == 1 && msg.contains('Starting'));
if (!msg.contains('received')) { log.log("Node 1 started. Clicking node button.\n");
return; mote.getInterfaces().getButton().clickButton()
}
/* Remember receiver */ while (true) {
global.put("recv_" + id, "ok"); /* Only handle receive messages */
log.log(id + " received a message\n"); WAIT_UNTIL(msg.contains('received'));
/* Did all nodes (1-10) receive a message? */ /* Remember receiving node */
for (i = 1; i <= 10; i++) { log.log(id + " received a message\n");
result = global.get("recv_" + i); nr_packets[id]++;
if (result == null) {
return; /* 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)*/

View file

@ -1,30 +1,31 @@
if (msg.startsWith('Coffee file test: 0')) { TIMEOUT(60000);
global.put("coffee_file_test", true);
} else if (msg.startsWith('Coffee file test')) { fileOK = null;
global.put("coffee_file_test", false); gcOK = null;
} else if (msg.startsWith('Coffee garbage collection test: 0')) {
global.put("coffee_gc_test", true); while (fileOK == null || gcOK == null) {
} else if (msg.startsWith('Coffee garbage collection test')) { YIELD();
global.put("coffee_gc_test", false);
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) { if (gcOK == false) {
//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) {
log.log("coffee garbage collection failed\n"); log.log("coffee garbage collection failed\n");
log.testFailed();
} }
if (fileOK == false) {
if (global.get("coffee_file_test") == false) {
log.log("coffee file test failed\n"); log.log("coffee file test failed\n");
log.testFailed();
} }
if (!fileOK || !gcOK) {
log.testOK(); log.testFailed();
} else {
log.testOK();
}

View file

@ -1,60 +1,51 @@
/* Wait until all nodes have booted */ TIMEOUT(120000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
if (msg.startsWith('Starting')) {
log.log("Node " + id + " booted\n"); /* Conf. */
global.put("boot_" + id, true); 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); /* Wait until all nodes have started */
if (result == null || result == false) { while (nodes_starting) {
/*log.log("Node " + i + " did not yet boot\n");*/ WAIT_UNTIL(msg.startsWith('Starting'));
return; 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 */ /* Create sink */
result = global.get("created_sink"); log.log("All nodes booted, creating sink at node " + id + "\n");
if (result == null || result == false) { mote.getInterfaces().getButton().clickButton()
log.log("All nodes booted, creating sink at node " + id + "\n");
mote.getInterfaces().getButton().clickButton()
global.put("created_sink", true);
return;
}
/* Log incoming sensor data */ while (true) {
source = msg.split(" ")[0]; YIELD();
count = global.get("count_" + source);
log.log("Got data from node " + source + "\n");
if (count == null) {
count = 0;
}
count++;
global.put("count_" + source, count);
/* Fail if any node has transmitted more than 20 packets */ /* Count sensor data packets */
for (i = 1; i <= 7; i++) { source = msg.split(" ")[0];
result = global.get("count_" + i); log.log("Got data from node " + source + "\n");
if (result > 20) { count[source]++;
log.log("FAILED: received/node: " + /* Fail if any node has transmitted more than 20 packets */
global.get("count_1") + " " + for (i = 1; i <= nrNodes; i++) {
global.get("count_2") + " " + if (count[i] > 20) {
global.get("count_3") + " " + log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
global.get("count_4") + " " +
global.get("count_5") + " " +
global.get("count_6") + " " +
global.get("count_7") + "\n");
log.testFailed(); /* We are done! */ log.testFailed(); /* We are done! */
return;
} }
}
/* 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;
} }
}
log.testOK(); /* We are done! */ /* 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();
}
}

View file

@ -1,7 +1,4 @@
/* Script is called once for every node log output. */ TIMEOUT(2000, log.log("last message: " + msg + "\n"));
/* Input variables: Mote mote, int id, String msg. */
if (msg.startsWith('Hello, world')) { WAIT_UNTIL(msg.equals('Hello, world'));
log.log('TEST OK\n'); /* Report test success */ log.testOK();
mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/
}

View file

@ -1,52 +1,15 @@
TIMEOUT(2000, log.log("last message: " + msg + "\n"));
/* Wait until node has booted */ /* Wait until node has booted */
if (msg.startsWith('Starting')) { WAIT_UNTIL(msg.startsWith('Starting'));
log.log("Shell started\n"); 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;
}
/* Send command ps */ /* Test command: ps */
result = global.get("command_ps"); node.write("ps");
if (result == null || result == false) { WAIT_UNTIL(msg.startsWith('Event timer'));
log.log("Sending 'ps'\n");
global.put("command_ps", true);
node.write("ps");
return;
}
/* Wait for ps response */ /* Test command: help */
if (msg.startsWith('Event timer')) { node.write("help");
log.log("Reponse from 'ps'\n"); WAIT_UNTIL(msg.startsWith('write <filename>'));
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;
}
log.testOK(); /* We are done! */ log.testOK(); /* We are done! */

View file

@ -1,9 +1,4 @@
/* Script is called once for every node log output. */ TIMEOUT(2000, log.log("last message: " + msg + "\n"));
/* Input variables: Mote mote, int id, String msg. */
/* Contiki test script example */ WAIT_UNTIL(msg.startsWith('Contiki'));
if (msg.startsWith('Contiki')) { log.testOK();
log.testOK(); /* Report test success */
} else {
log.testFailed(); /* Report test failure */
}