mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-11-08 23:08:29 +00:00
better example test script
This commit is contained in:
parent
15738c9fe3
commit
c74687ee48
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: ScriptRunner.java,v 1.4 2008/09/29 13:03:29 fros4943 Exp $
|
* $Id: ScriptRunner.java,v 1.5 2008/09/29 13:24:41 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.plugins;
|
package se.sics.cooja.plugins;
|
||||||
@ -86,13 +86,17 @@ public class ScriptRunner extends VisPlugin {
|
|||||||
"log.log('TIME=' + mote.getSimulation().getSimulationTime() + '\\n');\n" +
|
"log.log('TIME=' + mote.getSimulation().getSimulationTime() + '\\n');\n" +
|
||||||
"log.log('MSG=' + msg + '\\n');\n" +
|
"log.log('MSG=' + msg + '\\n');\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
|
"/* Hashtable global may be used to store state across script invokes */\n" +
|
||||||
"log.log('STORED VAR=' + global.get('storedVar') + '\\n');\n" +
|
"log.log('STORED VAR=' + global.get('storedVar') + '\\n');\n" +
|
||||||
"global.put('storedVar', msg);\n" +
|
"global.put('storedVar', msg);\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"log.log('TEST OK\\n'); /* Report test success */\n" +
|
"/* Contiki test script example */\n" +
|
||||||
"\n" +
|
"if (msg.startsWith('Hello, world')) {\n" +
|
||||||
"/* To increase test run speed, close the simulator when done */\n" +
|
" log.log('TEST OK\\n'); /* Report test success */\n" +
|
||||||
"//mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/\n" +
|
" \n" +
|
||||||
|
" /* To increase test run speed, close the simulator when done */\n" +
|
||||||
|
" //mote.getSimulation().getGUI().doQuit(false); /* Quit simulator (to end test run)*/\n" +
|
||||||
|
"}\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"//mote.getSimulation().getGUI().reloadCurrentSimulation(true); /* Reload simulation */\n";
|
"//mote.getSimulation().getGUI().reloadCurrentSimulation(true); /* Reload simulation */\n";
|
||||||
|
|
||||||
@ -183,17 +187,20 @@ public class ScriptRunner extends VisPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void importContikiTest() {
|
private void importContikiTest() {
|
||||||
Simulation simulation = ScriptRunner.this.gui.getSimulation();
|
|
||||||
|
|
||||||
/* Load config from test directory */
|
|
||||||
final File proposedDir = new File(GUI.getExternalToolsSetting("PATH_CONTIKI") + "/tools/cooja/contiki_tests");
|
|
||||||
if (!proposedDir.exists()) {
|
|
||||||
logger.fatal("Test directory does not exist: " + proposedDir.getPath());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Simulation simulation = ScriptRunner.this.gui.getSimulation();
|
||||||
|
|
||||||
|
/* Load config from test directory */
|
||||||
|
final File proposedDir = new File(GUI.getExternalToolsSetting("PATH_CONTIKI") + "/tools/cooja/contiki_tests");
|
||||||
|
if (!proposedDir.exists()) {
|
||||||
|
logger.fatal("Test directory does not exist: " + proposedDir.getPath());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptTextArea.setText("");
|
||||||
|
logTextArea.setText("");
|
||||||
|
|
||||||
gui.doLoadConfig(false, true, proposedDir);
|
gui.doLoadConfig(false, true, proposedDir);
|
||||||
Vector<File> history = gui.getFileHistory();
|
Vector<File> history = gui.getFileHistory();
|
||||||
|
|
||||||
@ -217,7 +224,6 @@ public class ScriptRunner extends VisPlugin {
|
|||||||
|
|
||||||
/* Import .js */
|
/* Import .js */
|
||||||
try {
|
try {
|
||||||
scriptTextArea.setText("");
|
|
||||||
BufferedReader reader =
|
BufferedReader reader =
|
||||||
new BufferedReader(new InputStreamReader(new FileInputStream(jsFile)));
|
new BufferedReader(new InputStreamReader(new FileInputStream(jsFile)));
|
||||||
String line;
|
String line;
|
||||||
|
Loading…
Reference in New Issue
Block a user