test_basic.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # test_basic of perf_probe test
  5. # Author: Michael Petlan <mpetlan@redhat.com>
  6. # Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
  7. #
  8. # Description:
  9. #
  10. # This test tests basic functionality of perf probe command.
  11. #
  12. # include working environment
  13. . ../common/init.sh
  14. TEST_RESULT=0
  15. if ! check_kprobes_available; then
  16. print_overall_skipped
  17. exit 0
  18. fi
  19. ### help message
  20. if [ "$PARAM_GENERAL_HELP_TEXT_CHECK" = "y" ]; then
  21. # test that a help message is shown and looks reasonable
  22. $CMD_PERF probe --help > $LOGS_DIR/basic_helpmsg.log 2> $LOGS_DIR/basic_helpmsg.err
  23. PERF_EXIT_CODE=$?
  24. ../common/check_all_patterns_found.pl "PERF-PROBE" "NAME" "SYNOPSIS" "DESCRIPTION" "OPTIONS" "PROBE\s+SYNTAX" "PROBE\s+ARGUMENT" "LINE\s+SYNTAX" < $LOGS_DIR/basic_helpmsg.log
  25. CHECK_EXIT_CODE=$?
  26. ../common/check_all_patterns_found.pl "LAZY\s+MATCHING" "FILTER\s+PATTERN" "EXAMPLES" "SEE\s+ALSO" < $LOGS_DIR/basic_helpmsg.log
  27. (( CHECK_EXIT_CODE += $? ))
  28. ../common/check_all_patterns_found.pl "vmlinux" "module=" "source=" "verbose" "quiet" "add=" "del=" "list.*EVENT" "line=" "vars=" "externs" < $LOGS_DIR/basic_helpmsg.log
  29. (( CHECK_EXIT_CODE += $? ))
  30. ../common/check_all_patterns_found.pl "no-inlines" "funcs.*FILTER" "filter=FILTER" "force" "dry-run" "max-probes" "exec=" "demangle-kernel" < $LOGS_DIR/basic_helpmsg.log
  31. (( CHECK_EXIT_CODE += $? ))
  32. ../common/check_no_patterns_found.pl "No manual entry for" < $LOGS_DIR/basic_helpmsg.err
  33. (( CHECK_EXIT_CODE += $? ))
  34. print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "help message"
  35. (( TEST_RESULT += $? ))
  36. else
  37. print_testcase_skipped "help message"
  38. fi
  39. ### usage message
  40. # without any args perf-probe should print usage
  41. $CMD_PERF probe 2> $LOGS_DIR/basic_usage.log > /dev/null
  42. ../common/check_all_patterns_found.pl "[Uu]sage" "perf probe" "verbose" "quiet" "add" "del" "force" "line" "vars" "externs" "range" < $LOGS_DIR/basic_usage.log
  43. CHECK_EXIT_CODE=$?
  44. print_results 0 $CHECK_EXIT_CODE "usage message"
  45. (( TEST_RESULT += $? ))
  46. ### quiet switch
  47. # '--quiet' should mute all output
  48. $CMD_PERF probe --quiet --add vfs_read > $LOGS_DIR/basic_quiet01.log 2> $LOGS_DIR/basic_quiet01.err
  49. PERF_EXIT_CODE=$?
  50. $CMD_PERF probe --quiet --del vfs_read > $LOGS_DIR/basic_quiet03.log 2> $LOGS_DIR/basic_quiet02.err
  51. (( PERF_EXIT_CODE += $? ))
  52. test "`cat $LOGS_DIR/basic_quiet*log $LOGS_DIR/basic_quiet*err | wc -l`" -eq 0
  53. CHECK_EXIT_CODE=$?
  54. print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "quiet switch"
  55. (( TEST_RESULT += $? ))
  56. # print overall results
  57. print_overall_results "$TEST_RESULT"
  58. exit $?