tsort 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/sh
  2. . ./Common
  3. ###############################################################################
  4. fped "tsort: total order" <<EOF
  5. %tsort {
  6. a b
  7. a c
  8. a d
  9. b c
  10. b d
  11. c d
  12. }
  13. EOF
  14. expect <<EOF
  15. a
  16. b
  17. c
  18. d
  19. EOF
  20. #------------------------------------------------------------------------------
  21. fped "tsort: partial order change (1)" <<EOF
  22. %tsort {
  23. a b
  24. a c
  25. a d
  26. d b
  27. }
  28. EOF
  29. expect <<EOF
  30. a
  31. c
  32. d
  33. b
  34. EOF
  35. #------------------------------------------------------------------------------
  36. fped "tsort: partial order change (2)" <<EOF
  37. %tsort {
  38. b c
  39. c d
  40. a b
  41. }
  42. EOF
  43. expect <<EOF
  44. a
  45. b
  46. c
  47. d
  48. EOF
  49. #------------------------------------------------------------------------------
  50. fped "tsort: old order differs from resolution order" <<EOF
  51. %tsort {
  52. +a +b +c +d
  53. a c
  54. a b
  55. a d
  56. }
  57. EOF
  58. expect <<EOF
  59. a
  60. b
  61. c
  62. d
  63. EOF
  64. #------------------------------------------------------------------------------
  65. fped "tsort: order change due to priority" <<EOF
  66. %tsort {
  67. a b
  68. a c 1
  69. a d
  70. }
  71. EOF
  72. expect <<EOF
  73. a
  74. c
  75. b
  76. d
  77. EOF
  78. #------------------------------------------------------------------------------
  79. fped "tsort: priority accumulation without decay" <<EOF
  80. %tsort {
  81. +a +b +c +d
  82. a b 1
  83. a d 1
  84. }
  85. EOF
  86. expect <<EOF
  87. a
  88. b
  89. d
  90. c
  91. EOF
  92. #------------------------------------------------------------------------------
  93. fped "tsort: priority accumulation with decay" <<EOF
  94. %tsort {
  95. +a -b +c +d
  96. a b 1
  97. a d 1
  98. }
  99. EOF
  100. expect <<EOF
  101. a
  102. b
  103. c
  104. d
  105. EOF
  106. #------------------------------------------------------------------------------
  107. fped_fail "tsort: cycle" <<EOF
  108. %tsort {
  109. a b
  110. b a
  111. }
  112. EOF
  113. expect_sed '/Aborted/d' <<EOF
  114. cycle detected in partial order
  115. EOF
  116. # The "Aborted" can be reported with or without "(core dumped)", and sometimes
  117. # not at all. So we just remove it. We already know that tsort has detected
  118. # the problem.
  119. ###############################################################################