@@ -1,7 +1,12 @@
-current=`cut -d'[' -f2 /sys/kernel/tracing/trace_clock | cut -d']' -f1`
-for clock in `cat /sys/kernel/tracing/trace_clock | sed -e 's/[][]//g'`; do
+DIR=`dirname $0`
+. $DIR/functions
+
+TRACE_CLOCK="$TRACING_DIR/trace_clock"
+
+current=`cut -d'[' -f2 $TRACE_CLOCK | cut -d']' -f1`
+for clock in `cat $TRACE_CLOCK | sed -e 's/[][]//g'`; do
echo " TESTING $clock"
- echo $clock > /sys/kernel/tracing/trace_clock
- ./ftrace-test-tracers sleep 1 || exit 1
+ echo $clock > $TRACE_CLOCK
+ $DIR/ftrace-test-tracers sleep 1 || exit 1
done
exit 0
@@ -2,27 +2,9 @@
# fixed by "ring-buffer: Fix first commit on sub-buffer having non-zero delta"
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-DEBUGFS="$debugfs/tracing"
-trace_clock=$DEBUGFS/trace_clock
+DIR=`dirname $0`
+. $DIR/functions
+trace_clock=$TRACING_DIR/trace_clock
if ! grep -q counter $trace_clock ; then
echo "counter clock is not defined in this kernel"
exit 0
@@ -1,27 +1,9 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-DEBUGFS="$debugfs/tracing"
+DIR=`dirname $0`
+. $DIR/functions
-save_cpumask=`cat $DEBUGFS/tracing_cpumask`
+save_cpumask=`cat $TRACING_DIR/tracing_cpumask`
MAXCPUS=6
@@ -106,27 +88,27 @@ let MSKCNT=$MSKCNT-1
for i in `seq $MSKCNT`; do
echo "get_bits $i"
bits=`get_bits $i`
- run_cmd "" $DEBUGFS $i $bits
+ run_cmd "" $TRACING_DIR $i $bits
done
trace-cmd start -p nop -M $save_cpumask
-if [ ! -d $DEBUGFS/instances ]; then
+if [ ! -d $TRACING_DIR/instances ]; then
exit 0
fi
-rmdir $DEBUGFS/instances/foo
-mkdir $DEBUGFS/instances/foo
-if [ ! -f $DEBUGFS/instances/foo/tracing_cpumask ]; then
+rmdir $TRACING_DIR/instances/foo
+mkdir $TRACING_DIR/instances/foo
+if [ ! -f $TRACING_DIR/instances/foo/tracing_cpumask ]; then
echo "instances do not have cpumask"
- rmdir $DEBUGFS/instances/foo
+ rmdir $TRACING_DIR/instances/foo
exit 0
fi
-rmdir $DEBUGFS/instances/foo
+rmdir $TRACING_DIR/instances/foo
for i in `seq $MSKCNT`; do
bits=`get_bits $i`
- run_cmd "-B foo" $DEBUGFS/instances/foo $i $bits
+ run_cmd "-B foo" $TRACING_DIR/instances/foo $i $bits
done
-rmdir $DEBUGFS/instances/foo
+rmdir $TRACING_DIR/instances/foo
exit 0
@@ -1,31 +1,14 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debugfs=`find_debugfs`
-TRACEDIR="$debugfs/tracing"
-EVENTDIR=$TRACEDIR/events
+EVENTDIR=$TRACING_DIR/events
EVENT=$EVENTDIR/sched/sched_switch
EVENT_ENABLE=$EVENT/enable
TRIGGER_FILE=$EVENT/trigger
-TRACE_FILE=$TRACEDIR/trace
-TRACING_ON=$TRACEDIR/tracing_on
+TRACE_FILE=$TRACING_DIR/trace
+TRACING_ON=$TRACING_DIR/tracing_on
# set -x
@@ -92,8 +75,8 @@ function check_events() {
function do_reset() {
clear_triggers
- echo nop > $TRACEDIR/current_tracer || exit -1
- echo 0 > $TRACEDIR/events/enable || exit -1
+ echo nop > $TRACING_DIR/current_tracer || exit -1
+ echo 0 > $TRACING_DIR/events/enable || exit -1
echo > $TRACE_FILE || exit -1
echo 1 > $TRACING_ON || exit -1
}
@@ -1,26 +1,9 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debugfs=`find_debugfs`
-TRACEDIR="$debugfs/tracing"
-EVENTDIR=$TRACEDIR/events
+EVENTDIR=$TRACING_DIR/events
if [ ! -f $EVENTDIR/sched/sched_switch/trigger ]; then
echo "triggers are not set for this kernel"
@@ -28,12 +11,12 @@ if [ ! -f $EVENTDIR/sched/sched_switch/trigger ]; then
fi
function cnt_trace() {
- grep -v '^#' $TRACEDIR/trace | head -10000| wc -l
+ grep -v '^#' $TRACING_DIR/trace | head -10000| wc -l
}
function check_traceon() {
val=$1
- cur=`cat $TRACEDIR/tracing_on`
+ cur=`cat $TRACING_DIR/tracing_on`
if [ $val -ne $cur ]; then
echo "traceon expected to be $val but was $cur"
exit 1
@@ -43,8 +26,8 @@ function check_traceon() {
set -x
echo '** DISABLE TRACING'
-echo 0 > $TRACEDIR/tracing_on || exit -1
-echo > $TRACEDIR/trace || exit -1
+echo 0 > $TRACING_DIR/tracing_on || exit -1
+echo > $TRACING_DIR/trace || exit -1
check_traceon 0
@@ -56,10 +39,10 @@ fi
echo '** ENABLE FUNCTION TRACING'
-echo function > $TRACEDIR/current_tracer || exit -1
+echo function > $TRACING_DIR/current_tracer || exit -1
echo '** ENABLE TRACING'
-echo 1 > $TRACEDIR/tracing_on || exit -1
+echo 1 > $TRACING_DIR/tracing_on || exit -1
cnt=`cnt_trace`
if [ $cnt -eq 0 ]; then
@@ -81,15 +64,15 @@ if [ $cnt -ne $cnt2 ]; then
exit -1;
fi
-line1=`cat $TRACEDIR/trace | tail -1`
+line1=`cat $TRACING_DIR/trace | tail -1`
sleep 1
-line2=`cat $TRACEDIR/trace | tail -1`
+line2=`cat $TRACING_DIR/trace | tail -1`
if [ $line1 != $line2 ]; then
exit -1
fi
-echo > $TRACEDIR/trace || exit -1
+echo > $TRACING_DIR/trace || exit -1
check_traceon 0
@@ -122,17 +105,17 @@ echo '** TEST COUNT traceoff (3)'
echo "traceoff:3" >> $EVENTDIR/sched/sched_switch/trigger
check_sleep "0"
echo '** TEST COUNT traceoff (2)'
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "0"
echo '** TEST COUNT traceoff (1)'
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "0"
echo '** TEST COUNT traceoff (0)'
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "1"
echo "!traceoff:0" >> $EVENTDIR/sched/sched_switch/trigger
-echo nop > $TRACEDIR/current_tracer
+echo nop > $TRACING_DIR/current_tracer
echo '** SUCCESS'
@@ -1,31 +1,14 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debugfs=`find_debugfs`
-TRACEDIR="$debugfs/tracing"
-EVENTDIR=$TRACEDIR/events
+EVENTDIR=$TRACING_DIR/events
EVENT=$EVENTDIR/sched/sched_wakeup
EVENT_ENABLE=$EVENT/enable
TRIGGER_FILE=$EVENT/trigger
-TRACE_FILE=$TRACEDIR/trace
-TRACING_ON=$TRACEDIR/tracing_on
+TRACE_FILE=$TRACING_DIR/trace
+TRACING_ON=$TRACING_DIR/tracing_on
OTHER="sched:sched_switch"
OTHER_EVENT=$EVENTDIR/sched/sched_switch
@@ -102,8 +85,8 @@ function test_other_enabled() {
function do_reset() {
clear_triggers
- echo nop > $TRACEDIR/current_tracer || exit -1
- echo 0 > $TRACEDIR/events/enable || exit -1
+ echo nop > $TRACING_DIR/current_tracer || exit -1
+ echo 0 > $TRACING_DIR/events/enable || exit -1
echo > $TRACE_FILE || exit -1
echo 1 > $TRACING_ON || exit -1
}
@@ -1,27 +1,9 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debugfs=`find_debugfs`
-tracedir="$debugfs/tracing"
-
-echo 99999999 > $tracedir/buffer_size_kb&
+echo 99999999 > $TRACING_DIR/buffer_size_kb&
sleep 10
if dmesg | grep "unable to handle kernel NULL"; then
exit 1
@@ -1,6 +1,9 @@
#!/bin/bash
-cd /sys/kernel/tracing
+DIR=`dirname $0`
+. $DIR/functions
+
+cd $TRACING_DIR
if [ ! -f max_graph_depth ]; then
# only test if graph depth exists
@@ -1,26 +1,11 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`
+
+DIR=`dirname $0`
+. $DIR/functions
#set -x
-cd $debug/tracing || exit 1
+cd $TRACING_DIR || exit 1
if ! grep -q function_graph available_tracers; then
echo "no function graph tracer configured"
@@ -10,26 +10,10 @@
#
# This test triggers those bugs on those kernels.
#
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`
-
-cd $debug/tracing || exit 1
+DIR=`dirname $0`
+. $DIR/functions
+
+cd $TRACING_DIR || exit 1
# We need function_graph and profiling to to run this test
if ! grep -q function_graph available_tracers; then
@@ -1,33 +1,15 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-tracedir="$debugfs/tracing"
+DIR=`dirname $0`
+. $DIR/functions
tmpfile="/tmp/tmp.$$"
-if [ ! -d $tracedir/instances ]; then
+if [ ! -d $TRACING_DIR/instances ]; then
echo "instances not configured in this kernel"
exit 0
fi
-cd $tracedir/instances || exit -1
+cd $TRACING_DIR/instances || exit -1
# clear out instances
ls | while read t; do
@@ -166,14 +148,14 @@ if [ $# -gt 0 ]; then
arg="$@"
fi
-for tracer in `cat $tracedir/available_tracers`; do
+for tracer in `cat $TRACING_DIR/available_tracers`; do
if [ $tracer == "nop" ]; then
continue;
fi
echo "Testing tracer $tracer"
- echo $tracer > $tracedir/current_tracer
+ echo $tracer > $TRACING_DIR/current_tracer
echo "running $arg"
$arg
- cat $tracedir/trace
- echo nop > $tracedir/current_tracer
+ cat $TRACING_DIR/trace
+ echo nop > $TRACING_DIR/current_tracer
done
@@ -1,10 +1,13 @@
+DIR=`dirname $0`
+. $DIR/functions
+
test_tracer() {
tracer=$1
- if grep -q $tracer /sys/kernel/tracing/available_tracers; then
+ if grep -q $tracer $TRACING_DIR/available_tracers; then
trace-cmd start -p $tracer
- x=`wc -l /sys/kernel/tracing/trace | cut -d' ' -f1`
+ x=`wc -l $TRACING_DIR/trace | cut -d' ' -f1`
echo $x
if [ "$x" -lt 30 ]; then
exit 1
@@ -1,4 +1,7 @@
-cd /sys/kernel/tracing
+DIR=`dirname $0`
+. $DIR/functions
+
+cd $TRACING_DIR
if ! grep -q irqsoff available_tracers; then
echo irqsoff not configured
exit 0
@@ -1,6 +1,9 @@
#!/bin/bash
-cd /sys/kernel/tracing
+DIR=`dirname $0`
+. $DIR/functions
+
+cd $TRACING_DIR
if [ ! -f kprobe_events ]; then
echo "kprobe_events not defined"
@@ -1,12 +1,13 @@
-dir=/sys/kernel/tracing
-
-function=$dir/options/function-trace
-max=$dir/tracing_max_latency
-current=$dir/current_tracer
-trace=$dir/trace
-traceon=$dir/tracing_on
-available=$dir/available_tracers
+DIR=`dirname $0`
+. $DIR/functions
+
+function=$TRACING_DIR/options/function-trace
+max=$TRACING_DIR/tracing_max_latency
+current=$TRACING_DIR/current_tracer
+trace=$TRACING_DIR/trace
+traceon=$TRACING_DIR/tracing_on
+available=$TRACING_DIR/available_tracers
if [ ! -f $function ]; then
@@ -1,4 +1,7 @@
-overwrite=/sys/kernel/tracing/options/overwrite
+DIR=`dirname $0`
+. $DIR/functions
+
+overwrite=$TRACING_DIR/options/overwrite
if [ ! -f $overwrite ]; then
echo "overwrite option not defined"
exit 0
@@ -1,25 +1,7 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-tracedir="$debugfs/tracing"
+DIR=`dirname $0`
+. $DIR/functions
mcount=0
@@ -33,7 +15,7 @@ else
exit 1
fi
-cd $tracedir
+cd $TRACING_DIR
echo > trace
echo nop > current_tracer
@@ -1,18 +1,14 @@
#!/bin/bash
-tracefs=`cat /proc/mounts |grep tracefs| head -1 | cut -d' ' -f2`
+DIR=`dirname $0`
+. $DIR/functions
-if [ -z "$tracefs" ]; then
- echo "tracefs not mounted"
- exit 0
-fi
-
-if [ ! -d $tracefs/instances ]; then
+if [ ! -d $TRACING_DIR/instances ]; then
echo "No instances directory"
exit 0
fi
-cd $tracefs/instances
+cd $TRACING_DIR/instances
mkdir x
rmdir x
@@ -1,18 +1,14 @@
#!/bin/bash
-tracefs=`cat /proc/mounts |grep tracefs| head -1 | cut -d' ' -f2`
+DIR=`dirname $0`
+. $DIR/functions
-if [ -z "$tracefs" ]; then
- echo "tracefs not mounted"
- exit 0
-fi
-
-if [ ! -d $tracefs/instances ]; then
+if [ ! -d $TRACING_DIR/instances ]; then
echo "No instances directory"
exit 0
fi
-cd $tracefs/instances
+cd $TRACING_DIR/instances
instance_slam() {
while :; do
@@ -1,31 +1,8 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-if [ ! -f /proc/modules ]; then
- echo CONFIG_MODULES not enabled
- exit 0
-fi
-
-set -x
-debug=`find_debugfs`
+DIR=`dirname $0`
+. $DIR/functions
-tracing=$debug/tracing
version=`uname -r`
modules=`find /lib/modules/$version -name '*.ko' | sed -e 's,^.*/\([^/]*\)\.ko,\1,' -e 's/-/_/g'`
loaded=`lsmod | cut -d' ' -f1`
@@ -39,7 +16,7 @@ for mod in $modules; do
continue;
fi
# make sure there's functions to trace.
- func=`grep "\\[$mod\\]" $tracing/available_filter_functions | head -1 | cut -d' ' -f1`
+ func=`grep "\\[$mod\\]" $TRACING_DIR/available_filter_functions | head -1 | cut -d' ' -f1`
rmmod $mod
if [ -z "$func" ]; then
continue
@@ -54,13 +31,13 @@ module=$mod
modprobe $module
rmmod $module
-set_ftrace_filter=$tracing/set_ftrace_filter
-set_ftrace_notrace=$tracing/set_ftrace_notrace
+set_ftrace_filter=$TRACING_DIR/set_ftrace_filter
+set_ftrace_notrace=$TRACING_DIR/set_ftrace_notrace
> $set_ftrace_filter
> $set_ftrace_notrace
-echo function > $tracing/current_tracer || exit 1
+echo function > $TRACING_DIR/current_tracer || exit 1
echo "Testing function enabled"
found=0
@@ -69,7 +46,7 @@ modprobe $module
while :; do
loc=`grep "^$module " /proc/modules | cut -d' ' -f6`
if echo $locs | grep -q $loc ; then
- echo nop > $tracing/current_tracer || exit 1
+ echo nop > $TRACING_DIR/current_tracer || exit 1
> $set_ftrace_filter || exit 1
break
fi
@@ -87,20 +64,20 @@ modprobe $module
while :; do
loc=`grep "^$module " /proc/modules | cut -d' ' -f6`
if echo $locs | grep -q $loc ; then
- echo nop > $tracing/current_tracer || exit 1
+ echo nop > $TRACING_DIR/current_tracer || exit 1
> $set_ftrace_filter || exit 1
break
fi
locs="$locs $loc"
- echo nop > $tracing/current_tracer || exit 1
+ echo nop > $TRACING_DIR/current_tracer || exit 1
echo $func >> $set_ftrace_filter || exit 1
rmmod $module
- echo function > $tracing/current_tracer
+ echo function > $TRACING_DIR/current_tracer
modprobe $module
done
rmmod $module
echo " Success"
-echo nop > $tracing/current_tracer || exit 1
+echo nop > $TRACING_DIR/current_tracer || exit 1
locs=''
echo "Testing notrace set"
@@ -110,18 +87,18 @@ while :; do
if echo $locs | grep -q $loc ; then
#echo " done"
# exit 0
- echo nop > $tracing/current_tracer || exit 1
+ echo nop > $TRACING_DIR/current_tracer || exit 1
> $set_ftrace_filter || exit 1
break
fi
locs="$locs $loc"
- echo nop > $tracing/current_tracer || exit 1
+ echo nop > $TRACING_DIR/current_tracer || exit 1
echo $func >> $set_ftrace_notrace || exit 1
rmmod $module
- echo function > $tracing/current_tracer
+ echo function > $TRACING_DIR/current_tracer
modprobe $module
done
rmmod $module
echo " Success"
-echo nop > $tracing/current_tracer || exit 1
+echo nop > $TRACING_DIR/current_tracer || exit 1
exit 0
@@ -1,27 +1,13 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`
-x=`trace-cmd record -p function -l '*account_user_time' --func-stack cat $debug/tracing/options/func_stack_trace | head -1`
+
+DIR=`dirname $0`
+. $DIR/functions
+
+x=`trace-cmd record -p function -l '*account_user_time' --func-stack cat $TRACING_DIR/options/func_stack_trace | head -1`
# disable function stack trace option (trace-cmd should have done it itself)
trace-cmd start -p function -l '*account_user_time'
trace-cmd start -p nop
-echo > $debug/tracing/set_ftrace_filter
+echo > $TRACING_DIR/set_ftrace_filter
if [ "$x" -eq 1 ]; then
exit 0
fi
@@ -1,25 +1,9 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debug=`find_debugfs`
-cd $debug/tracing/
+cd $TRACING_DIR
if [ -f tracing_enabled ]; then
enable="tracing_enabled"
@@ -1,30 +1,15 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`
-TRACE_DIR=$debug/tracing
+
+DIR=`dirname $0`
+. $DIR/functions
+
file_name=saved_cmdlines_size
-SIZE_FILE=$TRACE_DIR/$file_name
+SIZE_FILE=$TRACING_DIR/$file_name
HIGHEST_PID=32768
let TOO_HIGH=$HIGHEST_PID+1
-TRACE_FILE=$TRACE_DIR/trace
-TRACING_ON=$TRACE_DIR/tracing_on
-EVENT_ENABLE=$TRACE_DIR/events/enable
+TRACE_FILE=$TRACING_DIR/trace
+TRACING_ON=$TRACING_DIR/tracing_on
+EVENT_ENABLE=$TRACING_DIR/events/enable
if [ ! -f $SIZE_FILE ]; then
echo "$file_name does not exist"
@@ -1,25 +1,9 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`/tracing
+DIR=`dirname $0`
+. $DIR/functions
-cd $debug || exit 1
+cd $TRACING_DIR || exit 1
if [ ! -f snapshot ]; then
echo "No snapshot, not running test"
@@ -1,32 +1,14 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-DEBUGFS="$debugfs/tracing"
+DIR=`dirname $0`
+. $DIR/functions
#set -x
trace-cmd start -b 1407 -p function || exit 1
let x=0
while [ $x -lt 1000 ]; do
- c=`grep '^overrun' $DEBUGFS/per_cpu/cpu0/stats | cut -d' ' -f2`
+ c=`grep '^overrun' $TRACING_DIR/per_cpu/cpu0/stats | cut -d' ' -f2`
if [ $c -gt 0 ]; then
break
fi
@@ -39,7 +21,7 @@ fi
trace-cmd stop
-c=`grep '^entries' $DEBUGFS/per_cpu/cpu0/stats | cut -d' ' -f2`
+c=`grep '^entries' $TRACING_DIR/per_cpu/cpu0/stats | cut -d' ' -f2`
if [ $c -eq 0 ]; then
echo "FAILED: No entries found"
exit 1
@@ -47,15 +29,15 @@ fi
echo set buffer to 1000kb
-echo 1000 > $DEBUGFS/buffer_size_kb || exit 1
+echo 1000 > $TRACING_DIR/buffer_size_kb || exit 1
echo spawn cat trace_pipe
-cat $DEBUGFS/trace_pipe > /dev/null &
+cat $TRACING_DIR/trace_pipe > /dev/null &
echo read trace
let x=0
while [ $x -lt 60 ]; do
- c=`grep -v '#' $DEBUGFS/trace |wc -l`
+ c=`grep -v '#' $TRACING_DIR/trace |wc -l`
if [ $c -eq 0 ]; then
break
fi
@@ -64,7 +46,7 @@ done
echo disable tracing
-echo 0 > $DEBUGFS/tracing_on
+echo 0 > $TRACING_DIR/tracing_on
echo wait for trace to become empty
@@ -73,7 +55,7 @@ last_c=2
while [ $c -gt 0 ]; do
sleep 1
- c=`grep -v '#' $DEBUGFS/trace | wc -l`
+ c=`grep -v '#' $TRACING_DIR/trace | wc -l`
if [ $c -eq $last_c ]; then
echo "trace_pipe stopped updating c=$c last_c=$last_c"
exit
@@ -89,11 +71,11 @@ if [ $x -eq 1000 ]; then
exit 1
fi
-c=`grep '^entries' $DEBUGFS/per_cpu/cpu0/stats | cut -d' ' -f2`
+c=`grep '^entries' $TRACING_DIR/per_cpu/cpu0/stats | cut -d' ' -f2`
if [ $c -ne 0 ]; then
echo "FAILED: entries should be zero"
exit 1
fi
-echo 1 > $DEBUGFS/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
echo 0
@@ -1,4 +1,7 @@
-cd /sys/kernel/tracing
+DIR=`dirname $0`
+. $DIR/functions
+
+cd $TRACING_DIR
if [ ! -f kprobe_events ]; then
echo "no kprobes in this kernel"
exit 0
@@ -1,36 +1,19 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
+DIR=`dirname $0`
+. $DIR/functions
-debugfs=`find_debugfs`
-TRACEDIR="$debugfs/tracing"
-EVENTDIR=$TRACEDIR/events
+EVENTDIR=$TRACING_DIR/events
function cnt_trace() {
- grep -v '^#' $TRACEDIR/trace | head -10000 | wc -l
+ grep -v '^#' $TRACING_DIR/trace | head -10000 | wc -l
}
#set -x
echo '** DISABLE TRACING'
-echo 0 > $TRACEDIR/tracing_on || exit -1
-echo > $TRACEDIR/trace || exit -1
+echo 0 > $TRACING_DIR/tracing_on || exit -1
+echo > $TRACING_DIR/trace || exit -1
cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
@@ -43,7 +26,7 @@ echo '** ENABLE EVENTS'
echo 1 > $EVENTDIR/enable || exit -1
echo '** ENABLE TRACING'
-echo 1 > $TRACEDIR/tracing_on || exit -1
+echo 1 > $TRACING_DIR/tracing_on || exit -1
cnt=`cnt_trace`
if [ $cnt -eq 0 ]; then
@@ -59,9 +42,9 @@ fi
echo '** SET TRACEOFF'
-echo "$func:traceoff" > $TRACEDIR/set_ftrace_filter
+echo "$func:traceoff" > $TRACING_DIR/set_ftrace_filter
-cnt=`grep schedule $TRACEDIR/set_ftrace_filter | wc -l`
+cnt=`grep schedule $TRACING_DIR/set_ftrace_filter | wc -l`
if [ $cnt -ne 1 ]; then
exit -1
fi
@@ -74,41 +57,41 @@ if [ $cnt -ne $cnt2 ]; then
exit -1;
fi
-on=`cat $TRACEDIR/tracing_on`
+on=`cat $TRACING_DIR/tracing_on`
if [ $on != "0" ]; then
exit -1
fi
-line1=`cat $TRACEDIR/trace | tail -1`
+line1=`cat $TRACING_DIR/trace | tail -1`
sleep 1
-line2=`cat $TRACEDIR/trace | tail -1`
+line2=`cat $TRACING_DIR/trace | tail -1`
if [ "$line1" != "$line2" ]; then
exit -1
fi
-echo > $TRACEDIR/trace || exit -1
+echo > $TRACING_DIR/trace || exit -1
cnt=`cnt_trace`
if [ $cnt -ne 0 ]; then
exit -1
fi
-echo "!$func:traceoff" >> $TRACEDIR/set_ftrace_filter
+echo "!$func:traceoff" >> $TRACING_DIR/set_ftrace_filter
-cnt=`grep schedule $TRACEDIR/set_ftrace_filter | wc -l`
+cnt=`grep schedule $TRACING_DIR/set_ftrace_filter | wc -l`
if [ $cnt -ne 0 ]; then
exit -1
fi
-on=`cat $TRACEDIR/tracing_on`
+on=`cat $TRACING_DIR/tracing_on`
if [ $on != "0" ]; then
exit -1
fi
-echo "$func:traceon" > $TRACEDIR/set_ftrace_filter
+echo "$func:traceon" > $TRACING_DIR/set_ftrace_filter
-cnt=`grep schedule $TRACEDIR/set_ftrace_filter | wc -l`
+cnt=`grep schedule $TRACING_DIR/set_ftrace_filter | wc -l`
if [ $cnt -ne 1 ]; then
exit -1
fi
@@ -118,15 +101,15 @@ if [ $cnt -eq 0 ]; then
exit -1
fi
-on=`cat $TRACEDIR/tracing_on`
+on=`cat $TRACING_DIR/tracing_on`
if [ $on != "1" ]; then
exit -1
fi
-echo "!$func:traceon" >> $TRACEDIR/set_ftrace_filter
+echo "!$func:traceon" >> $TRACING_DIR/set_ftrace_filter
-cnt=`grep schedule $TRACEDIR/set_ftrace_filter | wc -l`
+cnt=`grep schedule $TRACING_DIR/set_ftrace_filter | wc -l`
if [ $cnt -ne 0 ]; then
exit -1
fi
@@ -134,25 +117,25 @@ fi
check_sleep() {
val=$1
sleep 1
- cat $TRACEDIR/set_ftrace_filter
- on=`cat $TRACEDIR/tracing_on`
+ cat $TRACING_DIR/set_ftrace_filter
+ on=`cat $TRACING_DIR/tracing_on`
if [ $on != "$val" ]; then
exit -1
fi
}
-echo "$func:traceoff:3" > $TRACEDIR/set_ftrace_filter
+echo "$func:traceoff:3" > $TRACING_DIR/set_ftrace_filter
check_sleep "0"
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "0"
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "0"
-echo 1 > $TRACEDIR/tracing_on
+echo 1 > $TRACING_DIR/tracing_on
check_sleep "1"
-echo "!$func:traceoff:0" > $TRACEDIR/set_ftrace_filter
+echo "!$func:traceoff:0" > $TRACING_DIR/set_ftrace_filter
-if grep -e traceon -e traceoff $TRACEDIR/set_ftrace_filter; then
+if grep -e traceon -e traceoff $TRACING_DIR/set_ftrace_filter; then
exit -1
fi
@@ -1,25 +1,7 @@
#!/bin/bash
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-tracedir="$debugfs/tracing"
+DIR=`dirname $0`
+. $DIR/functions
arg="sleep 10"
if [ $# -gt 0 ]; then
@@ -28,17 +10,17 @@ fi
tmpfile=/tmp/tmpfile.$$
-for tracer in `cat $tracedir/available_tracers`; do
+for tracer in `cat $TRACING_DIR/available_tracers`; do
if [ $tracer == "nop" ]; then
continue;
fi
echo "Testing tracer $tracer"
- echo $tracer > $tracedir/current_tracer
+ echo $tracer > $TRACING_DIR/current_tracer
echo "running $arg"
$arg
- echo 0 > $tracedir/tracing_on
- cat $tracedir/trace > $tmpfile
- echo nop > $tracedir/current_tracer
+ echo 0 > $TRACING_DIR/tracing_on
+ cat $TRACING_DIR/trace > $tmpfile
+ echo nop > $TRACING_DIR/current_tracer
cnt=`wc -l $tmpfile | cut -d ' ' -f1`
if [ $cnt -gt 300 ]; then
head -100 $tmpfile
@@ -47,5 +29,5 @@ for tracer in `cat $tracedir/available_tracers`; do
else
cat $tmpfile
fi
- echo 1 > $tracedir/tracing_on
+ echo 1 > $TRACING_DIR/tracing_on
done
@@ -8,26 +8,10 @@
#
# This test triggers that bug on those kernels.
#
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $mount == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-debug=`find_debugfs`
+DIR=`dirname $0`
+. $DIR/functions
-cd $debug/tracing || exit 1
+cd $TRACING_DIR || exit 1
# We need function_graph, instances that do function tracing and stack trace
# to run this test
new file mode 100644
@@ -0,0 +1,20 @@
+
+tracefs=`cat /proc/mounts |grep tracefs| head -1 | cut -d' ' -f2`
+
+if [ -z "$tracefs" ]; then
+ if mount -t tracefs tracefs /sys/kernel/tracing; then
+ tracefs=/sys/kernel/tracing
+ elif mount -t debugfs tracefs /sys/kernel/debug; then
+ tracefs=/sys/kernel/debug/tracing
+ else
+ echo "Failed to find or mount tracefs"
+ exit 1
+ fi
+fi
+
+if [ ! -d $tracefs ]; then
+ echo "$tracefs is not a directory"
+ exit 1
+fi
+
+export TRACING_DIR=$tracefs
@@ -1,6 +1,5 @@
-TRACE_DIR="/sys/kernel/tracing"
-
DIR=`dirname $0`
+. $DIR/functions
m=`uname -m`
if [ "$m" == "x86_64" ]; then
@@ -26,7 +25,7 @@ run() {
sleep 1;
}
-echo 1 > ${TRACE_DIR}/options/pause-on-trace
+echo 1 > ${TRACING_DIR}/options/pause-on-trace
run "TESTING MCOUNT" ftrace-test-mcount
@@ -1,9 +1,12 @@
+DIR=`dirname $0`
+$DIR/functions
+
echo "insmod"
insmod /lib/modules/`uname -r`/kernel/samples/trace_events/trace-events-sample.ko
rm -f /tmp/fifo
mkfifo /tmp/fifo
echo "open filter"
-cat /tmp/fifo | /work/c/read-wait /sys/kernel/tracing/events/sample/filter &
+cat /tmp/fifo | /work/c/read-wait $TRACING_DIR/events/sample/filter &
sleep 1
echo "rmmod"
rmmod trace-events-sample.ko
@@ -1,5 +1,8 @@
#!/bin/bash
+DIR=`dirname $0`
+$DIR/functions
+
TRACECMD=trace-cmd
TIME=2
@@ -10,27 +13,6 @@ if [ $nosplice -ne 0 ]; then
echo " --nosplice not supported"
fi
-find_debugfs() {
- debugfs=`cat /proc/mounts | while read mount dir type opts a b; do
- if [ $type == "debugfs" ]; then
- echo $dir;
- break
- fi
- done`
- if [ -z "$debugfs" ]; then
- if ! mount -t debugfs nodev /sys/kernel/debug; then
- echo "FAILED to mount debugfs"
- exit -1
- fi
- echo "/sys/kernel/debug"
- else
- echo $debugfs
- fi
-}
-
-debugfs=`find_debugfs`
-tracedir="$debugfs/tracing"
-
# test plugins
run_plugin_test() {
@@ -49,7 +31,7 @@ run_plugin_test() {
head -500 /tmp/test-trace.out
}
-plugins=`cat $tracedir/available_tracers`;
+plugins=`cat $TRACING_DIR/available_tracers`;
for p in $plugins; do
run_plugin_test $p || exit 1
if [ $nosplice -eq 0 ]; then
@@ -131,7 +131,7 @@ read_pids() {
get_tracing_dir() {
debug=`grep debugfs /proc/mounts | awk '{ print $2 }'`
- echo -n "$debug/tracing"
+ echo -n "$TRACING_DIR"
}
ors() {