# This unit is intended to ensure that signal handling is working properly. # At best, it is not. This is just a sanity check. # Signal handling needs to be implemented in a more generic way and safe way. # 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" delete_breakpoints # Load the program to test into gdb set test "load file" if [gdb_file_cmd ${file}] then { exit 1 } # testing the ^c signal, "abc^c" set test "priming for signal" send "abc" expect { -re "^abc$" { } timeout { fail "timeout $test" } } set test "priming for signal 2" send "\3" expect { -re "Quit\[\r\n\]+$tgdb_prompt$" { pass "control_c passed" } timeout { fail "timeout $test" } } # Make sure a following signal also works. set test "priming for signal 3" send "\3" expect { -re "Quit\[\r\n\]+$tgdb_prompt$" { pass "control_c passed" } timeout { fail "timeout $test" } } # Test that 'b main^c' will work. Also, make sure the data didn't go # into the history. set test "priming for signal 4" send "b main" expect { -re "^b main$" { } timeout { fail "timeout $test" } } set test "priming for signal 5" send "\3" expect { -re "Quit\[\r\n\]+$tgdb_prompt$" { pass "control_c passed"} timeout { fail "timeout $test" } } # 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" } } # The next few test are to make sure that if you # 1. run a command # 2. type another command, but interupt it with ^c # 3. Run "\n" to make sure the original command is the command run, # The command that was interuppted should go away forever. # Run "info address" send "info address\n"; expect { -re "info address\[\r\n\]+Argument required\.\[\r\n\]+$tgdb_prompt$" {} timeout { fail "timeout $test" } } # Send "b nex^c", make sure it doesn't go into history. send "b nex" expect { -re "^b nex$" { } timeout { fail "timeout $test" } } send "\3" expect { -re "Quit\[\r\n\]+$tgdb_prompt$" {} timeout { fail "timeout $test" } } # This makes sure that the previous command that was interupted by a signal did # not make it into readline's history send "\n" expect { -re "\[\r\n\]+Argument required\.\[\r\n\]+$tgdb_prompt$" { pass "interuppted command did not enter history" } timeout { fail "timeout $test" } }