#!/usr/bin/expect # Edit the first line to contain the correct path to expect. # Parameter dieses - Scripts: # 1.) AVR-Executable # 2.) Controllercode # 3.) Filename der Datei mit dem Inputpattern. # 4.) Filename der Datei mit dem Outputpattern. set prog [lindex $argv 0] set controller [lindex $argv 1] set inputpattern_filename [lindex $argv 2] set outputpattern_filename [lindex $argv 3] # Simulavr-gdb is very slow when using cygwin increase timeout to 60s. set timeout 60 puts "simulate binary $prog with $controller configuration" if ![file exists $prog] { puts "File to be excecuted does not exist." exit 1; } # Run the simulator # Run avr-gdb spawn avr-gdb $prog set pidGdb [exp_pid ] expect "*(gdb)" {puts "... spawned avr-gdb ..."} \ timeout {puts "... spawning avr-gdb failed ! "} set idGdb $spawn_id # We assume that someone has already started simulavr on the local machine # using the parameters # simulavr -d atmega128 -g -p 1212 # # Make avr-gdb connect to simulavr send "target remote localhost:1212\n" expect "*(gdb)*" {puts "... launched target remote localhost:1212"} \ timeout {puts "... gdb does not respond after target remote localhost:1212"} # OK the connection between gdb and simulavr is now established. # Let's now set the breakpoints and load the test patterns. send "break test_start\n" expect "*(gdb)*" {puts "breakpoint test_start set in avr-gdb"} send "break test_end\n" expect "*(gdb)*" {puts "breakpoint test_end set in avr-gdb"} send "load\n" expect "*(gdb)*" {puts "program loaded in avr-gdb"} # launch the program and wait for the result. send "continue\n" expect "*test_start*" {puts "test_start Breakpoint in $prog ist erreicht. \n" ; } \ timeout {puts "TIMEOUT when executing $prog \n"; }; expect "*(gdb)*" {send "restore $inputpattern_filename binary &inputdata 0 (sizeof (inputdata)) \n"} send "continue\n" expect "*test_end*" {puts "test_end Breakpoint in $prog ist erreicht. \n";} \ timeout {puts "Timeout beim Ausfuehren des Tests. \n"} expect "*(gdb)*" {send "dump binary memory $outputpattern_filename &resultat\[0\] &resultat\[1\] \n"} expect "*(gdb)*" {puts "Datei $outputpattern_filename wurde generiert.\n"} \ timeout {puts "Timeout beim Ablegen der Ausgabedaten. \n"} send "quit \n" #exec kill -9 $pidGdb