gcc-simulate-thread.exp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright (C) 2011-2015 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with GCC; see the file COPYING3. If not see
  14. # <http://www.gnu.org/licenses/>.
  15. load_lib timeout.exp
  16. # Utility for running a given test through the simulate-thread harness
  17. # using gdb. This is invoked via dg-final.
  18. #
  19. # Adapted from the guality harness.
  20. #
  21. # Call 'fail' if a given test printed "FAIL:", otherwise call 'pass'.
  22. proc simulate-thread { args } {
  23. if { ![isnative] || [is_remote target] } { return }
  24. if { [llength $args] == 1 } {
  25. switch [dg-process-target [lindex $args 0]] {
  26. "F" { setup_xfail "*-*-*" }
  27. }
  28. }
  29. # This assumes that we are three frames down from dg-test, and that
  30. # it still stores the filename of the testcase in a local variable "name".
  31. # A cleaner solution would require a new DejaGnu release.
  32. upvar 2 name testcase
  33. upvar 2 prog prog
  34. upvar 2 srcdir testsuite_dir
  35. set gdb_name $::env(GDB_FOR_GCC_TESTING)
  36. set exec_file "[file rootname [file tail $prog]].exe"
  37. set cmd_file "$testsuite_dir/gcc.dg/simulate-thread/simulate-thread.gdb"
  38. if ![file exists $exec_file] {
  39. return
  40. }
  41. set message "thread simulation test"
  42. send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$exec_file\n"
  43. set res [remote_spawn target "$gdb_name -nx -nw -x $cmd_file ./$exec_file"]
  44. if { $res < 0 || $res == "" } {
  45. unsupported "$testcase $message"
  46. return
  47. }
  48. set gdb_worked 0
  49. remote_expect target [timeout_value] {
  50. # Too old GDB
  51. -re "Unhandled dwarf expression|Error in sourced command file" {
  52. unsupported "$testcase $message"
  53. remote_close target
  54. return
  55. }
  56. -re "FAIL:" {
  57. fail "$testcase $message"
  58. remote_close target
  59. return
  60. }
  61. # If the gdb output contained simulate_thread_done, assume
  62. # that at the very least, we had a working gdb that was able
  63. # to break in simulate_thread_done.
  64. -re "simulate_thread_done" {
  65. set gdb_worked 1
  66. exp_continue
  67. }
  68. timeout {
  69. fail "$testcase $message"
  70. remote_close target
  71. return
  72. }
  73. }
  74. remote_close target
  75. if {$gdb_worked} {
  76. pass "$testcase $message"
  77. } else {
  78. # Unsupported in the absence of a sane GDB.
  79. unsupported "$testcase $message"
  80. }
  81. return
  82. }