From a4bc10edfa2f44230b2fca2ce6654ed448436c28 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Fri, 26 Jun 2009 13:26:48 +0000 Subject: [PATCH] + verifies the base64 encoded executable stored in flash --- .../contiki_tests/sky_shell_exec_serial.csc | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/cooja/contiki_tests/sky_shell_exec_serial.csc b/tools/cooja/contiki_tests/sky_shell_exec_serial.csc index dc06f1f87..3218742cb 100644 --- a/tools/cooja/contiki_tests/sky_shell_exec_serial.csc +++ b/tools/cooja/contiki_tests/sky_shell_exec_serial.csc @@ -112,15 +112,17 @@ YIELD_THEN_WAIT_UNTIL(msg.equals("continue")); log.log("Uploading hello-world.b64:\n"); cmdarr = "sh -c xxx".split(" "); cmdarr[2] = "../../tools/base64-encode < hello-world.ce"; +sb = new java.lang.StringBuilder(); process = new java.lang.Runtime.getRuntime().exec(cmdarr, null, helloworld.getParentFile()); stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream())); while ((line = stdIn.readLine()) != null) { write(mote, line + "\n"); + sb.append(line); YIELD(); if (msg.startsWith(line)) { - log.log("UPLOADED: " + line + "\n"); + log.log("UPLOADED: " + msg + "\n"); } else { log.log("Serial port upload failed:\n" + line + "\n" + msg + "\n"); log.testFailed(); @@ -133,6 +135,28 @@ write(mote, "~K\n"); GENERATE_MSG(500, "continue"); YIELD_THEN_WAIT_UNTIL(msg.equals("continue")); +log.log("Reading and verifying hello-world.b64 from flash\n"); +write(mote, "read hello-world.b64"); +YIELD(); +while (!msg.contains("Contiki>")) { + if (!sb.toString().startsWith(msg.trim())) { + log.log("Verify failed: '" + msg + "' does not start '" + sb.toString() + "'\n"); + log.testFailed(); + } else { + log.log("VERIFIED: " + msg + "\n"); + sb.replace(0, msg.length()-1, new String("")); + } + + YIELD(); +} +if (sb.length()>0) { + log.log("Verify failed: remaining buffer: " + sb); + log.testFailed(); +} +GENERATE_MSG(500, "continue"); +YIELD_THEN_WAIT_UNTIL(msg.equals("continue")); + + log.log("Converting base64 to binary hello-world.ce\n"); write(mote, "read hello-world.b64 | dec64 | write hello-world.ce | null"); GENERATE_MSG(3000, "continue");