leak_all2.tests 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # "Check many leaks" test #2
  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. local_var="local val"
  9. export dev_null="/dev/null"
  10. >$dev_null
  11. echo hi1 $local_var `echo ho` >>/dev/null
  12. echo hi2 $local_var </dev/null | echo 2>&- | cat 1<>/dev/null
  13. { echo hi4 $local_var `echo ho` 1<>/dev/null; }
  14. ( echo hi4 $local_var `echo ho` 1<>/dev/null )
  15. if echo $local_var; false
  16. then echo not run
  17. elif false <$dev_null
  18. then none
  19. else cat 0<>$dev_null 1<>"$dev_null"
  20. fi >>/dev/null
  21. {
  22. if echo $local_var; then cat <<HERE
  23. Hi cat
  24. HERE
  25. fi >>/dev/null
  26. } 1<>/dev/null
  27. while { echo $dev_null >>$dev_null; }; do cat <"$dev_null"; break; done
  28. ( until { echo $dev_null >>$dev_null | false; }; do cat <"$dev_null"; break; done ) <$dev_null
  29. f() { echo $1; }
  30. f >/dev/null
  31. memleak
  32. echo "Measuring memory leak..."
  33. # Please copy the entire block from above verbatim
  34. local_var="local val"
  35. export dev_null="/dev/null"
  36. >$dev_null
  37. echo hi1 $local_var `echo ho` >>/dev/null
  38. echo hi2 $local_var </dev/null | echo 2>&- | cat 1<>/dev/null
  39. { echo hi4 $local_var `echo ho` 1<>/dev/null; }
  40. ( echo hi4 $local_var `echo ho` 1<>/dev/null )
  41. if echo $local_var; false
  42. then echo not run
  43. elif false <$dev_null
  44. then none
  45. else cat 0<>$dev_null 1<>"$dev_null"
  46. fi >>/dev/null
  47. {
  48. if echo $local_var; then cat <<HERE
  49. Hi cat
  50. HERE
  51. fi >>/dev/null
  52. } 1<>/dev/null
  53. while { echo $dev_null >>$dev_null; }; do cat <"$dev_null"; break; done
  54. ( until { echo $dev_null >>$dev_null | false; }; do cat <"$dev_null"; break; done ) <$dev_null
  55. f() { echo $1; }
  56. f >/dev/null
  57. # And same again
  58. local_var="local val"
  59. export dev_null="/dev/null"
  60. >$dev_null
  61. echo hi1 $local_var `echo ho` >>/dev/null
  62. echo hi2 $local_var </dev/null | echo 2>&- | cat 1<>/dev/null
  63. { echo hi4 $local_var `echo ho` 1<>/dev/null; }
  64. ( echo hi4 $local_var `echo ho` 1<>/dev/null )
  65. if echo $local_var; false
  66. then echo not run
  67. elif false <$dev_null
  68. then none
  69. else cat 0<>$dev_null 1<>"$dev_null"
  70. fi >>/dev/null
  71. {
  72. if echo $local_var; then cat <<HERE
  73. Hi cat
  74. HERE
  75. fi >>/dev/null
  76. } 1<>/dev/null
  77. while { echo $dev_null >>$dev_null; }; do cat <"$dev_null"; break; done
  78. ( until { echo $dev_null >>$dev_null | false; }; do cat <"$dev_null"; break; done ) <$dev_null
  79. f() { echo $1; }
  80. f >/dev/null
  81. memleak
  82. kb=$?
  83. if test $kb -le 4; then
  84. echo Ok #$kb
  85. else
  86. echo "Bad: $kb kb (or more) leaked"
  87. fi