ftrace_stress_test.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #! /bin/sh
  2. ###########################################################################
  3. ## ##
  4. ## Copyright (c) 2010 FUJITSU LIMITED ##
  5. ## ##
  6. ## This program is free software: you can redistribute it and/or modify ##
  7. ## it under the terms of the GNU General Public License as published by ##
  8. ## the Free Software Foundation, either version 3 of the License, or ##
  9. ## (at your option) any later version. ##
  10. ## ##
  11. ## This program is distributed in the hope that it will be useful, ##
  12. ## but WITHOUT ANY WARRANTY; without even the implied warranty of ##
  13. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##
  14. ## GNU General Public License for more details. ##
  15. ## ##
  16. ## You should have received a copy of the GNU General Public License ##
  17. ## along with this program. If not, see <http://www.gnu.org/licenses/>. ##
  18. ## ##
  19. ## Author: Li Zefan <lizf@cn.fujitsu.com> ##
  20. ## ##
  21. ###########################################################################
  22. export TCID="ftrace-stress-test"
  23. export TST_TOTAL=1
  24. export TST_COUNT=1
  25. . ftrace_lib.sh
  26. test_targets=" \
  27. trace_pipe current_tracer ftrace_enabled function_profile_enabled \
  28. set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
  29. trace_options trace_stat tracing_enabled tracing_max_latency \
  30. tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
  31. set_ftrace_filter"
  32. get_skip_targets()
  33. {
  34. NR_PIDS=0
  35. for target in ${test_targets}; do
  36. if [ ! -e $TRACING_PATH/$target ] &&
  37. [ ! -e /proc/sys/kernel/$target ]; then
  38. eval skip_$target=1
  39. tst_resm TINFO "$target is not supported. Skip it."
  40. else
  41. eval skip_$target=0
  42. NR_PIDS=$((NR_PIDS + 1))
  43. fi
  44. done
  45. # Export it before sub case is lanuched.
  46. export NR_PIDS
  47. }
  48. should_skip_target()
  49. {
  50. local skip_var=skip_$1
  51. eval local skip_val=\$${skip_var}
  52. [ "$skip_val" = 1 ]
  53. }
  54. test_kill()
  55. {
  56. tst_resm TINFO "killing ${pid0}"
  57. kill -USR1 ${pid0}
  58. wait ${pid0}
  59. local p=1;
  60. while [ $p -lt $NR_PIDS ]; do
  61. local pid_var=pid${p}
  62. eval local kill_pid=\$${pid_var}
  63. tst_resm TINFO "killing ${kill_pid}"
  64. kill -KILL $kill_pid
  65. wait ${kill_pid}
  66. p=$((p + 1))
  67. done
  68. }
  69. test_stress()
  70. {
  71. local index=0;
  72. tst_resm TINFO "Test targets: ${test_targets}"
  73. get_skip_targets
  74. for target in ${test_targets}; do
  75. if should_skip_target $target; then
  76. continue
  77. fi
  78. sh ftrace_${target}.sh &
  79. eval pid${index}=$!
  80. tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh"
  81. index=$((index + 1))
  82. done
  83. export_pids
  84. }
  85. export_pids()
  86. {
  87. local p=0
  88. while [ $p -lt $NR_PIDS ]; do
  89. export pid${p}
  90. p=$((p + 1))
  91. done
  92. }
  93. cd ftrace_stress/
  94. # ----------------------------
  95. tst_resm TINFO "Ftrace Stress Test Begin"
  96. test_begin
  97. test_stress
  98. test_wait
  99. test_kill
  100. tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs"
  101. tst_exit