| 1 | |
| 2 | |
| 3 | |
| 4 |
|
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 |
|
| 15 | DIR_PATH="$(dirname $0)"
|
| 16 | TEST_RESULT=0
|
| 17 |
|
| 18 | |
| 19 | . "$DIR_PATH/../common/init.sh"
|
| 20 |
|
| 21 | if ! check_kprobes_available; then
|
| 22 | print_overall_skipped
|
| 23 | exit 2
|
| 24 | fi
|
| 25 |
|
| 26 | |
| 27 | $CMD_PERF check feature -q dwarf
|
| 28 | [ $? -ne 0 ] && HINT_FAIL="Some of the tests need DWARF to run"
|
| 29 |
|
| 30 | |
| 31 |
|
| 32 | |
| 33 | for opt in '-a' '-d' '-L' '-V'; do
|
| 34 | ! $CMD_PERF probe $opt 2> $LOGS_DIR/invalid_options_missing_argument$opt.err
|
| 35 | PERF_EXIT_CODE=$?
|
| 36 |
|
| 37 | "$DIR_PATH/../common/check_all_patterns_found.pl" \
|
| 38 | "Error: switch .* requires a value" \
|
| 39 | < $LOGS_DIR/invalid_options_missing_argument$opt.err
|
| 40 | CHECK_EXIT_CODE=$?
|
| 41 |
|
| 42 | print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "missing argument for $opt"
|
| 43 | (( TEST_RESULT += $? ))
|
| 44 | done
|
| 45 |
|
| 46 |
|
| 47 | |
| 48 |
|
| 49 | |
| 50 | for opt in '-F' '-l'; do
|
| 51 | $CMD_PERF probe -F > /dev/null 2> $LOGS_DIR/invalid_options_unnecessary_argument$opt.err
|
| 52 | PERF_EXIT_CODE=$?
|
| 53 |
|
| 54 | test ! -s $LOGS_DIR/invalid_options_unnecessary_argument$opt.err
|
| 55 | CHECK_EXIT_CODE=$?
|
| 56 |
|
| 57 | print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "unnecessary argument for $opt"
|
| 58 | (( TEST_RESULT += $? ))
|
| 59 | done
|
| 60 |
|
| 61 |
|
| 62 | |
| 63 |
|
| 64 | |
| 65 | test -e $LOGS_DIR/invalid_options_mutually_exclusive.log && rm -f $LOGS_DIR/invalid_options_mutually_exclusive.log
|
| 66 | for opt in '-a xxx -d xxx' '-a xxx -L foo' '-a xxx -V foo' '-a xxx -l' '-a xxx -F' \
|
| 67 | '-d xxx -L foo' '-d xxx -V foo' '-d xxx -l' '-d xxx -F' \
|
| 68 | '-L foo -V bar' '-L foo -l' '-L foo -F' '-V foo -l' '-V foo -F' '-l -F'; do
|
| 69 | ! $CMD_PERF probe $opt > /dev/null 2> $LOGS_DIR/aux.log
|
| 70 | PERF_EXIT_CODE=$?
|
| 71 |
|
| 72 | "$DIR_PATH/../common/check_all_patterns_found.pl" \
|
| 73 | "Error: switch .+ cannot be used with switch .+" < $LOGS_DIR/aux.log
|
| 74 | CHECK_EXIT_CODE=$?
|
| 75 |
|
| 76 | print_results $PERF_EXIT_CODE $CHECK_EXIT_CODE "mutually exclusive options :: $opt"
|
| 77 | (( TEST_RESULT += $? ))
|
| 78 |
|
| 79 | |
| 80 | cat $LOGS_DIR/aux.log | grep "Error" >> $LOGS_DIR/invalid_options_mutually_exclusive.log
|
| 81 | done
|
| 82 |
|
| 83 |
|
| 84 | |
| 85 | print_overall_results "$TEST_RESULT" $HINT_FAIL
|
| 86 | exit $?
|