unix.exp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 onesimple { test_name match } {
  20. global verbose
  21. global aborted
  22. global testprefix
  23. if { $aborted > 0 } {
  24. untested "$testprefix$test_name"
  25. return
  26. }
  27. if { $verbose > 0 } {
  28. send_user "$testprefix$test_name$note\n"
  29. }
  30. expect {
  31. "$match" { pass "$testprefix$test_name"; }
  32. eof { fail "$testprefix$test_name"; set aborted 1; }
  33. timeout { unresolved "$testprefix$test_name"; set aborted 1; }
  34. }
  35. }
  36. proc onetest { test_name note start } {
  37. global aborted
  38. global testprefix
  39. global verbose
  40. global color
  41. global xfail
  42. if { $aborted > 0 } {
  43. untested "$testprefix$test_name"
  44. return
  45. }
  46. if { $verbose > 0 } {
  47. send_user "$testprefix$test_name$note\n"
  48. }
  49. expect {
  50. "$start" { }
  51. eof { unresolved "$testprefix$test_name"; set aborted 1; }
  52. timeout { unresolved "$testprefix$test_name"; set aborted 1; }
  53. }
  54. if { $aborted > 0 } {
  55. send_user "sync failed: $testprefix$test_name$note -- $testprefix aborted!\n"
  56. return
  57. }
  58. if { $color } {
  59. set pat "(32mOK|31mfailed)"
  60. } else {
  61. set pat "(OK|failed)"
  62. }
  63. expect {
  64. # need this because otherwise expect will skip over a "failed" and
  65. # grab the next "OK" (or the other way around)
  66. -re "$pat" {
  67. if { "$expect_out(0,string)" == "32mOK" || "$expect_out(0,string)" == "OK" } {
  68. pass "$testprefix$test_name"
  69. } else {
  70. if { $xfail } {
  71. xfail "$testprefix$test_name"
  72. } else {
  73. fail "$testprefix$test_name"
  74. }
  75. }
  76. return
  77. }
  78. eof { unresolved "$testprefix$test_name"; set aborted 1; }
  79. timeout { unresolved "$testprefix$test_name"; set aborted 1; }
  80. }
  81. if { $aborted > 0 } {
  82. send_user "failed: $testprefix$test_name$note -- $testprefix aborted!\n"
  83. return
  84. }
  85. }
  86. proc headerline { line } {
  87. global aborted
  88. if { $aborted > 0 } { return; }
  89. expect {
  90. $line { return; }
  91. eof { send_user "numbering mismatch!\n"; set aborted 1; }
  92. timeout { send_user "numbering mismatch!\n"; set aborted 1; }
  93. }
  94. }
  95. proc simpletest { start } {
  96. onetest "$start" "" "$start"
  97. }
  98. proc simpletest_nov6 { start } {
  99. global have_ipv6
  100. global xfail
  101. set xfail [expr 1-$have_ipv6]
  102. onetest "$start" "" "$start"
  103. set xfail 0
  104. }