3
0

leak_all1.tests 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. # "Check many leaks" test #1
  2. # Cramming all kinds of weird commands in here.
  3. # As you find leaks, please create separate, small test
  4. # for each leak.
  5. # Narrowing down the leak using this large test may be difficult.
  6. # It is intended to be a blanket "is everything ok?" test
  7. echo "Warm up"
  8. i=1
  9. l=1
  10. t=1
  11. export t
  12. while test $i != 99; do
  13. t=value1_$i; t=value2_$i true; t=value3_$i /bin/true; t=value4_$i exec 1>&1
  14. { t=value3_$i /bin/true; } </dev/null
  15. if true; t=valueA_$i false >>/dev/null; true; then
  16. : << HERE >/dev/null; true <<HERE
  17. Hello builtin :
  18. HERE
  19. Hello $i true
  20. HERE
  21. elif false; then
  22. true; echo Doesnt run
  23. else
  24. { true; }; echo Doesnt run too >>/foo/bar
  25. fi
  26. { : /bin/*; }
  27. unset var
  28. echo >/dev/null ${var#}
  29. echo >/dev/null ${var##}
  30. echo >/dev/null ${var#*}
  31. echo >/dev/null ${var##*}
  32. echo >/dev/null ${var%}
  33. echo >/dev/null ${var%%}
  34. echo >/dev/null ${var%*}
  35. echo >/dev/null ${var%%*}
  36. var=
  37. echo >/dev/null ${var#}
  38. echo >/dev/null ${var##}
  39. echo >/dev/null ${var#*}
  40. echo >/dev/null ${var##*}
  41. echo >/dev/null ${var%}
  42. echo >/dev/null ${var%%}
  43. echo >/dev/null ${var%*}
  44. echo >/dev/null ${var%%*}
  45. var=ababcdcd
  46. echo >/dev/null ${var#ab}
  47. echo >/dev/null ${var##ab}
  48. echo >/dev/null ${var#a*b}
  49. echo >/dev/null ${var##a*b}
  50. echo >/dev/null ${var#?}
  51. echo >/dev/null ${var##?}
  52. echo >/dev/null ${var#*}
  53. echo >/dev/null ${var##*}
  54. echo >/dev/null ${var%cd}
  55. echo >/dev/null ${var%%cd}
  56. echo >/dev/null ${var%c*d}
  57. echo >/dev/null ${var%%c*d}
  58. echo >/dev/null ${var%?}
  59. echo >/dev/null ${var%%?}
  60. echo >/dev/null ${var%*}
  61. echo >/dev/null ${var%%*}
  62. set -- par1_$i par2_$i par3_$i par4_$i
  63. trap "echo trap$i" WINCH
  64. f() { true; true; true; true; true; true; true; true; }
  65. f() { true; true; true; true; true; true; true; true; echo $1; }
  66. i=iii$i t=ttt$i z=zzz$i f >/dev/null
  67. : $((i++))
  68. done
  69. unset i l t
  70. unset -f f
  71. memleak
  72. echo "Measuring memory leak..."
  73. # Please copy the entire block from above verbatim
  74. i=1
  75. l=1
  76. t=1
  77. export t
  78. while test $i != 99; do
  79. t=value1_$i; t=value2_$i true; t=value3_$i /bin/true; t=value4_$i exec 1>&1
  80. { t=value3_$i /bin/true; } </dev/null
  81. if true; t=valueA_$i false >>/dev/null; true; then
  82. : << HERE >/dev/null; true <<HERE
  83. Hello builtin :
  84. HERE
  85. Hello $i true
  86. HERE
  87. elif false; then
  88. true; echo Doesnt run
  89. else
  90. { true; }; echo Doesnt run too >>/foo/bar
  91. fi
  92. { : /bin/*; }
  93. unset var
  94. echo >/dev/null ${var#}
  95. echo >/dev/null ${var##}
  96. echo >/dev/null ${var#*}
  97. echo >/dev/null ${var##*}
  98. echo >/dev/null ${var%}
  99. echo >/dev/null ${var%%}
  100. echo >/dev/null ${var%*}
  101. echo >/dev/null ${var%%*}
  102. var=
  103. echo >/dev/null ${var#}
  104. echo >/dev/null ${var##}
  105. echo >/dev/null ${var#*}
  106. echo >/dev/null ${var##*}
  107. echo >/dev/null ${var%}
  108. echo >/dev/null ${var%%}
  109. echo >/dev/null ${var%*}
  110. echo >/dev/null ${var%%*}
  111. var=ababcdcd
  112. echo >/dev/null ${var#ab}
  113. echo >/dev/null ${var##ab}
  114. echo >/dev/null ${var#a*b}
  115. echo >/dev/null ${var##a*b}
  116. echo >/dev/null ${var#?}
  117. echo >/dev/null ${var##?}
  118. echo >/dev/null ${var#*}
  119. echo >/dev/null ${var##*}
  120. echo >/dev/null ${var%cd}
  121. echo >/dev/null ${var%%cd}
  122. echo >/dev/null ${var%c*d}
  123. echo >/dev/null ${var%%c*d}
  124. echo >/dev/null ${var%?}
  125. echo >/dev/null ${var%%?}
  126. echo >/dev/null ${var%*}
  127. echo >/dev/null ${var%%*}
  128. set -- par1_$i par2_$i par3_$i par4_$i
  129. trap "echo trap$i" WINCH
  130. f() { true; true; true; true; true; true; true; true; }
  131. f() { true; true; true; true; true; true; true; true; echo $1; }
  132. i=iii$i t=ttt$i z=zzz$i f >/dev/null
  133. : $((i++))
  134. done
  135. unset i l t
  136. unset -f f
  137. memleak
  138. kb=$?
  139. if test $kb -le 4; then
  140. echo Ok #$kb
  141. else
  142. echo "Bad: $kb kb leaked"
  143. fi