Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8cab69b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'linux-kselftest-4.20-rc1' of...

Merge tag 'linux-kselftest-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:
 "This Kselftest update for Linux 4.20-rc1 consists of:

   - Improvements to ftrace test suite from Masami Hiramatsu.

   - Color coded ftrace PASS / FAIL results from Steven Rostedt (VMware)
     to improve readability of reports.

   - watchdog Fixes and enhancement to add gettimeout and get|set
     pretimeout options from Jerry Hoemann.

   - Several fixes to warnings and spelling etc"

* tag 'linux-kselftest-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (40 commits)
  selftests/ftrace: Strip escape sequences for log file
  selftests/ftrace: Use colored output when available
  selftests: fix warning: "_GNU_SOURCE" redefined
  selftests: kvm: Fix -Wformat warnings
  selftests/ftrace: Add color to the PASS / FAIL results
  kvm: selftests: fix spelling mistake "Insufficent" -> "Insufficient"
  selftests: gpio: Fix OUTPUT directory in Makefile
  selftests: gpio: restructure Makefile
  selftests: watchdog: Fix ioctl SET* error paths to take oneshot exit path
  selftests: watchdog: Add gettimeout and get|set pretimeout
  selftests: watchdog: Fix error message.
  selftests: watchdog: fix message when /dev/watchdog open fails
  selftests/ftrace: Add ftrace cpumask testcase
  selftests/ftrace: Add wakeup_rt tracer testcase
  selftests/ftrace: Add wakeup tracer testcase
  selftests/ftrace: Add stacktrace ftrace filter command testcase
  selftests/ftrace: Add trace_pipe testcase
  selftests/ftrace: Add function filter on module testcase
  selftests/ftrace: Add max stack tracer testcase
  selftests/ftrace: Add function profiling stat testcase
  ...
parents dad4f140 f73581f8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4,6 +4,12 @@ CONFIG_FUNCTION_PROFILER=y
CONFIG_TRACER_SNAPSHOT=y
CONFIG_STACK_TRACER=y
CONFIG_HIST_TRIGGERS=y
CONFIG_SCHED_TRACER=y
CONFIG_PREEMPT_TRACER=y
CONFIG_IRQSOFF_TRACER=y
CONFIG_PREEMPTIRQ_DELAY_TEST=m
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_SAMPLES=y
CONFIG_SAMPLE_TRACE_PRINTK=m
CONFIG_KALLSYMS_ALL=y
+60 −12
Original line number Diff line number Diff line
@@ -60,15 +60,29 @@ parse_opts() { # opts
      shift 1
    ;;
    --verbose|-v|-vv|-vvv)
      if [ $VERBOSE -eq -1 ]; then
	usage "--console can not use with --verbose"
      fi
      VERBOSE=$((VERBOSE + 1))
      [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1))
      [ $1 = '-vvv' ] && VERBOSE=$((VERBOSE + 2))
      shift 1
    ;;
    --console)
      if [ $VERBOSE -ne 0 ]; then
	usage "--console can not use with --verbose"
      fi
      VERBOSE=-1
      shift 1
    ;;
    --debug|-d)
      DEBUG=1
      shift 1
    ;;
    --stop-fail)
      STOP_FAILURE=1
      shift 1
    ;;
    --fail-unsupported)
      UNSUPPORTED_RESULT=1
      shift 1
@@ -117,6 +131,7 @@ KEEP_LOG=0
DEBUG=0
VERBOSE=0
UNSUPPORTED_RESULT=0
STOP_FAILURE=0
# Parse command-line options
parse_opts $*

@@ -137,11 +152,33 @@ else
  date > $LOG_FILE
fi

# Define text colors
# Check available colors on the terminal, if any
ncolors=`tput colors 2>/dev/null`
color_reset=
color_red=
color_green=
color_blue=
# If stdout exists and number of colors is eight or more, use them
if [ -t 1 -a "$ncolors" -a "$ncolors" -ge 8 ]; then
  color_reset="\e[0m"
  color_red="\e[31m"
  color_green="\e[32m"
  color_blue="\e[34m"
fi

strip_esc() {
  # busybox sed implementation doesn't accept "\x1B", so use [:cntrl:] instead.
  sed -E "s/[[:cntrl:]]\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"
}

prlog() { # messages
  [ -z "$LOG_FILE" ] && echo "$@" || echo "$@" | tee -a $LOG_FILE
  echo -e "$@"
  [ "$LOG_FILE" ] && echo -e "$@" | strip_esc >> $LOG_FILE
}
catlog() { #file
  [ -z "$LOG_FILE" ] && cat $1 || cat $1 | tee -a $LOG_FILE
  cat $1
  [ "$LOG_FILE" ] && cat $1 | strip_esc >> $LOG_FILE
}
prlog "=== Ftrace unit tests ==="

@@ -180,37 +217,37 @@ test_on_instance() { # testfile
eval_result() { # sigval
  case $1 in
    $PASS)
      prlog "	[PASS]"
      prlog "	[${color_green}PASS${color_reset}]"
      PASSED_CASES="$PASSED_CASES $CASENO"
      return 0
    ;;
    $FAIL)
      prlog "	[FAIL]"
      prlog "	[${color_red}FAIL${color_reset}]"
      FAILED_CASES="$FAILED_CASES $CASENO"
      return 1 # this is a bug.
    ;;
    $UNRESOLVED)
      prlog "	[UNRESOLVED]"
      prlog "	[${color_blue}UNRESOLVED${color_reset}]"
      UNRESOLVED_CASES="$UNRESOLVED_CASES $CASENO"
      return 1 # this is a kind of bug.. something happened.
    ;;
    $UNTESTED)
      prlog "	[UNTESTED]"
      prlog "	[${color_blue}UNTESTED${color_reset}]"
      UNTESTED_CASES="$UNTESTED_CASES $CASENO"
      return 0
    ;;
    $UNSUPPORTED)
      prlog "	[UNSUPPORTED]"
      prlog "	[${color_blue}UNSUPPORTED${color_reset}]"
      UNSUPPORTED_CASES="$UNSUPPORTED_CASES $CASENO"
      return $UNSUPPORTED_RESULT # depends on use case
    ;;
    $XFAIL)
      prlog "	[XFAIL]"
      prlog "	[${color_red}XFAIL${color_reset}]"
      XFAILED_CASES="$XFAILED_CASES $CASENO"
      return 0
    ;;
    *)
      prlog "	[UNDEFINED]"
      prlog "	[${color_blue}UNDEFINED${color_reset}]"
      UNDEFINED_CASES="$UNDEFINED_CASES $CASENO"
      return 1 # this must be a test bug
    ;;
@@ -269,16 +306,18 @@ __run_test() { # testfile
# Run one test case
run_test() { # testfile
  local testname=`basename $1`
  testcase $1
  if [ ! -z "$LOG_FILE" ] ; then
    local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
    local testlog=`mktemp $LOG_DIR/${CASENO}-${testname}-log.XXXXXX`
  else
    local testlog=/proc/self/fd/1
  fi
  export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
  testcase $1
  echo "execute$INSTANCE: "$1 > $testlog
  SIG_RESULT=0
  if [ -z "$LOG_FILE" ]; then
  if [ $VERBOSE -eq -1 ]; then
    __run_test $1
  elif [ -z "$LOG_FILE" ]; then
    __run_test $1 2>&1
  elif [ $VERBOSE -ge 3 ]; then
    __run_test $1 | tee -a $testlog 2>&1
@@ -304,6 +343,10 @@ run_test() { # testfile
# Main loop
for t in $TEST_CASES; do
  run_test $t
  if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then
    echo "A failure detected. Stop test."
    exit 1
  fi
done

# Test on instance loop
@@ -315,7 +358,12 @@ for t in $TEST_CASES; do
  run_test $t
  rmdir $TRACING_DIR
  TRACING_DIR=$SAVED_TRACING_DIR
  if [ $STOP_FAILURE -ne 0 -a $TOTAL_RESULT -ne 0 ]; then
    echo "A failure detected. Stop test."
    exit 1
  fi
done
(cd $TRACING_DIR; initialize_ftrace) # for cleanup

prlog ""
prlog "# of passed: " `echo $PASSED_CASES | wc -w`
+22 −0
Original line number Diff line number Diff line
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Change the ringbuffer size
# flags: instance

rb_size_test() {
ORIG=`cat buffer_size_kb`

expr $ORIG / 2 > buffer_size_kb

expr $ORIG \* 2 > buffer_size_kb

echo $ORIG > buffer_size_kb
}

rb_size_test

: "If per-cpu buffer is supported, imbalance it"
if [ -d per_cpu/cpu0 ]; then
  cd per_cpu/cpu0
  rb_size_test
fi
+16 −0
Original line number Diff line number Diff line
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: trace_pipe and trace_marker
# flags: instance

[ ! -f trace_marker ] && exit_unsupported

echo "test input 1" > trace_marker

: "trace interface never consume the ring buffer"
grep -q "test input 1" trace
grep -q "test input 1" trace

: "trace interface never consume the ring buffer"
head -n 1 trace_pipe | grep -q "test input 1"
! grep -q "test input 1" trace
+0 −10
Original line number Diff line number Diff line
@@ -9,23 +9,15 @@ do_reset() {
}

fail() { #msg
    do_reset
    echo $1
    exit_fail
}

yield() {
    ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
}

if [ ! -f set_event -o ! -d events/sched ]; then
    echo "event tracing is not supported"
    exit_unsupported
fi

reset_tracer
do_reset

echo 'sched:sched_switch' > set_event

yield
@@ -57,6 +49,4 @@ if [ $count -ne 0 ]; then
    fail "sched_switch events should not be recorded"
fi

do_reset

exit 0
Loading