run_freezer.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/bin/bash
  2. # Copyright (c) International Business Machines Corp., 2008
  3. # Author: Matt Helsley <matthltc@us.ibm.com>
  4. #
  5. # This library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. #
  10. # This library 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 GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public
  16. # License along with this library; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #set -x
  20. P='ltp-cgroup-freezer'
  21. export EXIT_GOOD=0
  22. export EXIT_TERMINATE=-1
  23. trap "exit ${EXIT_TERMINATE}" ERR
  24. #
  25. # Run tests for freezer and signal controllers
  26. #
  27. # TODO add:
  28. #vfork_freeze.sh
  29. # write signal/send_invalid_sig.sh
  30. # write signal/read_signal.kill.sh
  31. FREEZER_TEST_SCRIPTS=( write_freezing.sh
  32. freeze_write_freezing.sh
  33. freeze_thaw.sh
  34. freeze_sleep_thaw.sh
  35. freeze_kill_thaw.sh
  36. freeze_move_thaw.sh
  37. freeze_cancel.sh
  38. freeze_self_thaw.sh
  39. stop_freeze_thaw_cont.sh
  40. stop_freeze_sleep_thaw_cont.sh
  41. fork_freeze.sh )
  42. TEST_SCRIPTS=( )
  43. function test_setup()
  44. {
  45. if [ -z "${LTPROOT}" ]; then
  46. CGROUPS_TESTROOT="$(pwd)"
  47. . libltp
  48. else
  49. CGROUPS_TESTROOT="${LTPROOT}/testcases/bin"
  50. fi
  51. #######################################################################
  52. ## Initialize some LTP variables -- Set _COUNT and _TOTAL to fake values
  53. ## else LTP complains.
  54. #######################################################################
  55. TCID="$0"
  56. TST_COUNT=1
  57. TST_TOTAL=$(( ${#TEST_SCRIPTS[@]} + 0 ))
  58. TMPDIR="${TMPDIR:-/tmp}"
  59. export LTPBIN PATH TCID TST_COUNT TST_TOTAL CGROUPS_TESTROOT
  60. tst_resm TINFO "Preparing to run: ${P} $@"
  61. # this is not require here
  62. #make all
  63. }
  64. function test_prereqs()
  65. {
  66. cat /proc/filesystems | grep -E '\bcgroup\b' > /dev/null 2>&1 || {
  67. tst_resm TINFO "Kernel does not support cgroups. Skipping."
  68. exit ${EXIT_GOOD} # 0
  69. }
  70. tst_resm TINFO " Testing prereqs for cgroup freezer tests."
  71. if [ ! -f /proc/cgroups ]; then
  72. tst_resm TINFO "Tests require cgroup freezer support in the kernel."
  73. exit 1
  74. fi
  75. if [ "$(grep -w freezer /proc/cgroups | cut -f1)" != "freezer" ]; then
  76. tst_resm TINFO "Tests require cgroup freezer support in the kernel."
  77. exit 1
  78. fi
  79. . "${CGROUPS_TESTROOT}/libcgroup_freezer"
  80. tst_resm TINFO " It's ok if there's an ERROR before the next INFO."
  81. mount_freezer && umount_freezer && {
  82. TEST_SCRIPTS=( "${TEST_SCRIPTS[@]}" "${FREEZER_TEST_SCRIPTS[@]}" )
  83. }
  84. tst_resm TINFO " OK, resume worrying about ERRORS."
  85. export TST_TOTAL=$(( ${#TEST_SCRIPTS[@]} + 0 ))
  86. }
  87. function main()
  88. {
  89. local rc=0
  90. for TEST in "${TEST_SCRIPTS[@]}" ; do
  91. export TCID="${TEST}"
  92. tst_resm TINFO " running ${TEST}"
  93. ((TST_COUNT++))
  94. export TST_COUNT
  95. "${CGROUPS_TESTROOT}/${TEST}"
  96. rc=$?
  97. if [ $rc != 0 ]; then
  98. tst_resm TFAIL "${TEST} $rc"
  99. break
  100. else
  101. tst_resm TPASS "${TEST}"
  102. fi
  103. done
  104. trap '' ERR
  105. return $rc
  106. }
  107. test_setup && \
  108. test_prereqs && \
  109. declare -r TST_TOTAL && \
  110. main
  111. rc=$?
  112. trap '' ERR
  113. exit $rc