grub_script_return.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #! @builddir@/grub-shell-tester
  2. # Run GRUB script in a Qemu instance
  3. # Copyright (C) 2010 Free Software Foundation, Inc.
  4. #
  5. # GRUB is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # GRUB is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. function f1 {
  18. return
  19. echo one
  20. }
  21. f1
  22. function f2 {
  23. true
  24. return
  25. echo one
  26. }
  27. if f2; then echo true; else echo false; fi
  28. function f3 {
  29. false
  30. return
  31. echo one
  32. }
  33. if f3; then echo true; else echo false; fi
  34. function f4 {
  35. true
  36. return 1;
  37. echo one
  38. }
  39. if f4; then echo true; else echo false; fi
  40. function f5 {
  41. false
  42. return 0;
  43. echo one
  44. }
  45. if f5; then echo true; else echo false; fi
  46. function f6 {
  47. echo one
  48. if true; then
  49. echo two
  50. return 0
  51. else
  52. echo three
  53. return 1
  54. fi
  55. echo four
  56. }
  57. if f6; then echo true; else echo false; fi
  58. function f7 {
  59. if return 1; then
  60. echo one
  61. else
  62. echo no
  63. fi
  64. }
  65. if f7; then echo true; else echo false; fi
  66. function f8 {
  67. echo one
  68. for v in 1 2 3 4 5; do
  69. echo $v
  70. if test $v = 3; then return 1; fi
  71. done
  72. echo two
  73. }
  74. if f8; then echo true; else echo false; fi
  75. function f9 {
  76. x=1
  77. echo one
  78. until test x = 11111111; do
  79. echo $x
  80. x="1$x"
  81. if test $x = 1111; then return 0; fi
  82. done
  83. echo two
  84. }
  85. if f9; then echo true; else echo false; fi
  86. function f10 {
  87. echo one
  88. while return 0; do
  89. echo two
  90. done
  91. echo three
  92. }
  93. if f10; then echo true; else echo false; fi
  94. function f11 {
  95. f1
  96. f2
  97. f3
  98. f4
  99. f5
  100. f6
  101. f7
  102. f8
  103. f9
  104. f10
  105. }
  106. if f11; then echo true; else echo false; fi
  107. function f12 {
  108. echo one
  109. f11
  110. return 1
  111. echo two
  112. }
  113. if f12; then echo true; else echo false; fi
  114. function f13 {
  115. echo one
  116. f12
  117. echo two
  118. return 0
  119. }
  120. if f13; then echo true; else echo false; fi