unix.exp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # every test should always be run and always return some status.
  2. # so, if we lose sync with a multi-test program, aborted will be used
  3. # to flag the remainder of the tests as untested.
  4. #set aborted 0
  5. # only match with color codes since "failed" / "OK" might otherwise
  6. # be part of the output...
  7. #set color 1
  8. set config_h [open "../config.h" "r"]
  9. set config_h_text [read $config_h]
  10. close $config_h
  11. set i [string first "#define HAVE_IPV6" $config_h_text]
  12. if { $i >= 0 } {
  13. set have_ipv6 1
  14. } else {
  15. set have_ipv6 0
  16. }
  17. send_user "IPv6 enabled: $have_ipv6\n"
  18. set xfail 0
  19. proc onetest { test_name note start } {
  20. global aborted
  21. global testprefix
  22. global verbose
  23. global color
  24. global xfail
  25. if { $aborted > 0 } {
  26. untested "$testprefix$test_name"
  27. return
  28. }
  29. if { $verbose > 0 } {
  30. send_user "$testprefix$test_name$note\n"
  31. }
  32. expect {
  33. "$start" { }
  34. eof { unresolved "$testprefix$test_name"; set aborted 1; }
  35. timeout { unresolved "$testprefix$test_name"; set aborted 1; }
  36. }
  37. if { $aborted > 0 } {
  38. send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
  39. return
  40. }
  41. if { $color } {
  42. set pat "(32mOK|31mfailed)"
  43. } else {
  44. set pat "(OK|failed)"
  45. }
  46. expect {
  47. # need this because otherwise expect will skip over a "failed" and
  48. # grab the next "OK" (or the other way around)
  49. -re "$pat" {
  50. if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
  51. pass "$testprefix$test_name"
  52. } else {
  53. if { $xfail } {
  54. xfail "$testprefix$test_name"
  55. } else {
  56. fail "$testprefix$test_name"
  57. }
  58. }
  59. return
  60. }
  61. eof { unresolved "$testprefix$test_name"; set aborted 1; }
  62. timeout { unresolved "$testprefix$test_name"; set aborted 1; }
  63. }
  64. if { $aborted > 0 } {
  65. send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
  66. return
  67. }
  68. }
  69. proc headerline { line } {
  70. global aborted
  71. if { $aborted > 0 } { return; }
  72. expect {
  73. $line { return; }
  74. eof { send_user "numbering mismatch!\n"; set aborted 1; }
  75. timeout { send_user "numbering mismatch!\n"; set aborted 1; }
  76. }
  77. }
  78. proc simpletest { start } {
  79. onetest "$start" "" "$start"
  80. }
  81. proc simpletest_nov6 { start } {
  82. global have_ipv6
  83. global xfail
  84. set xfail [expr 1-$have_ipv6]
  85. onetest "$start" "" "$start"
  86. set xfail 0
  87. }