# Load the tgdb library load_lib tgdb.exp # Don't wait for more than 10 seconds set timeout 10 # Some basic constants set tgdb_dir "tgdb.base" set source_file_name "basic" set file "$tgdb_dir/$source_file_name" set source_file "$source_file_name.c" # Load the program to test into gdb set test "load file" if [gdb_file_cmd ${file}] then { exit 1 } # Set a breakpoint at main and run set function "main" if [gdb_breakpoint ${function}] then { exit 1 } # Run the program set test "run" send "r\n" expect { -re "Starting program.*$source_file_name.*$tgdb_prompt" { pass "$test" } -re ".*No executable file specified.*$tgdb_prompt" { fail "$test" } timeout { fail "timeout $test" } } # Test out buffering of commands # This is kind of crazy, look at the command to see what is sent. It makes sure that # each of the commands were buffered and sent in order. It also makes sure that # when the proper command was run, the correct command was put on the GDB prompt. # Also, it leaves the nex, at the end. set test "starting buffering commands" send "n\n\n" expect { -re ".*$tgdb_prompt.*$tgdb_prompt$" { pass "$test"} timeout { fail "timeout $test" } } set test "buffering commands" send "\n\n\nnext\nn\n\n\nnex" expect { -re "^\[\r\n\]+next\[\r\n\]+n\[\r\n\]+nex$tgdb_prompt\[\r\n\]+ABCDEFGHI\[\r\n\]+$tgdb_prompt\[\r\n\]+ABCDEFGH\[\r\n\]+${tgdb_prompt}next\[\r\n\]+ABCDEFG\[\r\n\]+${tgdb_prompt}n\[\r\n\]+ABCDEF\[\r\n\]+$tgdb_prompt\[\r\n\]+ABCDE\[\r\n\]+$tgdb_prompt\[\r\n\]+ABCD\[\r\n\]+${tgdb_prompt}nex$" { pass $test } timeout { fail "timeout $test" } } send "t\n" expect { -re "t\[\r\n\]+ABC\[\r\n\]+$tgdb_prompt$" { pass "$test"} timeout { fail "timeout $test" } } set test "sink_after_buffered_commands" send "next\n" expect { -re "next\[\r\n\]+AB\[\r\n\]+$tgdb_prompt$" { pass "$test"} timeout { fail "timeout $test" } }