func_profiler.tc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. # description: ftrace - function profiler with function tracing
  4. # requires: function_profile_enabled set_ftrace_filter function_graph:tracer
  5. # There was a bug after a rewrite of the ftrace infrastructure that
  6. # caused the function_profiler not to be able to run with the function
  7. # tracer, because the function_profiler used the function_graph tracer
  8. # and it was assumed the two could not run simultaneously.
  9. #
  10. # There was another related bug where the solution to the first bug
  11. # broke the way filtering of the function tracer worked.
  12. #
  13. # This test triggers those bugs on those kernels.
  14. #
  15. # We need function_graph and profiling to to run this test
  16. fail() { # mesg
  17. echo $1
  18. exit_fail
  19. }
  20. echo "Testing function tracer with profiler:"
  21. echo "enable function tracer"
  22. echo function > current_tracer
  23. echo "enable profiler"
  24. echo 1 > function_profile_enabled
  25. sleep 1
  26. echo "Now filter on just schedule"
  27. echo '*schedule' > set_ftrace_filter
  28. clear_trace
  29. echo "Now disable function profiler"
  30. echo 0 > function_profile_enabled
  31. sleep 1
  32. # make sure only schedule functions exist
  33. echo "testing if only schedule is being traced"
  34. if grep -v -e '^#' -e 'schedule' trace; then
  35. fail "more than schedule was found"
  36. fi
  37. echo "Make sure schedule was traced"
  38. if ! grep -e 'schedule' trace > /dev/null; then
  39. cat trace
  40. fail "can not find schedule in trace"
  41. fi
  42. echo > set_ftrace_filter
  43. clear_trace
  44. sleep 1
  45. echo "make sure something other than scheduler is being traced"
  46. if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
  47. cat trace
  48. fail "no other functions besides schedule was found"
  49. fi
  50. exit 0