torture-options.exp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # Copyright (C) 2008-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. # Prepare to use a new set of torture options.
  16. #
  17. # Letting options leak from one set of tests to another can be confusing.
  18. # Make sure variables are not set at the time we're called, because that
  19. # would mean they were set without being cleared.
  20. proc torture-init { args } {
  21. global torture_without_loops global_with_loops
  22. if [info exists torture_without_loops] {
  23. error "torture-init: torture_without_loops is not empty as expected"
  24. }
  25. if [info exists torture_with_loops] {
  26. error "torture-init: torture_with_loops is not empty as expected"
  27. }
  28. }
  29. # Return 1 if torture options have already been set, 0 otherwise.
  30. proc torture-options-exist { args } {
  31. global torture_with_loops
  32. return [info exists torture_with_loops]
  33. }
  34. # Return 1 if compiler option ARG only affects loops, 0 otherwise.
  35. proc contains-loop-option-p { arg } {
  36. switch -glob -- $arg {
  37. "*loop*" { return 1 }
  38. default { return 0 }
  39. }
  40. }
  41. # Set torture options variables for tests with and without loops.
  42. #
  43. # Argument 0 is the list to use as torture options
  44. # Argument 1 is the list to combine with the torture options.
  45. # Argument 2 is the list to be appended to the torture options after
  46. # combining argument 0 and 1.
  47. proc set-torture-options { args } {
  48. global torture_with_loops torture_without_loops
  49. set torture_list [lindex $args 0]
  50. if { [llength $args] > 1 } {
  51. set other_list [lindex $args 1]
  52. } else {
  53. set other_list [list {}]
  54. }
  55. set torture_with_loops ""
  56. set torture_without_loops ""
  57. foreach torture_opts $torture_list {
  58. foreach other_opts $other_list {
  59. # Remove trailing space[s] to match previous output.
  60. set torture_opts [string trimright $torture_opts]
  61. if ![contains-loop-option-p $torture_opts] {
  62. lappend torture_without_loops "$torture_opts $other_opts"
  63. }
  64. lappend torture_with_loops "$torture_opts $other_opts"
  65. }
  66. }
  67. if { [llength $args] > 2 } {
  68. set append_list [lindex $args 2]
  69. append torture_with_loops " $append_list"
  70. append torture_without_loops " $append_list"
  71. }
  72. }
  73. # Finish up after using a set of torture options.
  74. #
  75. # Letting options leak from one set of tests to another can be confusing.
  76. # Make sure variables are set at the time we're called, and then unset
  77. # them to prevent interference with other sets of tests.
  78. proc torture-finish { args } {
  79. global torture_without_loops torture_with_loops
  80. if [info exists torture_without_loops] {
  81. unset torture_without_loops
  82. } else {
  83. error "torture-finish: torture_without_loops is not defined"
  84. }
  85. if [info exists torture_with_loops] {
  86. unset torture_with_loops
  87. } else {
  88. error "torture-finish: torture_with_loops is not defined"
  89. }
  90. }
  91. # Useful for debugging .exp files.
  92. proc dump-torture-options { args } {
  93. global torture_without_loops torture_with_loops
  94. if [info exists torture_without_loops] {
  95. verbose "torture_without_loops = \"${torture_without_loops}\"" 1
  96. } else {
  97. verbose "torture_without_loops is not defined" 1
  98. }
  99. if [info exists torture_with_loops] {
  100. verbose "torture_with_loops = \"${torture_with_loops}\"" 1
  101. } else {
  102. verbose "torture_with_loops is not defined" 1
  103. }
  104. }