selftests/ftrace: skip ftrace test if FTRACE was not enabled
diff mbox series

Message ID 20190702062358.7330-1-po-hsu.lin@canonical.com
State New
Headers show
Series
  • selftests/ftrace: skip ftrace test if FTRACE was not enabled
Related show

Commit Message

Po-Hsu Lin July 2, 2019, 6:23 a.m. UTC
The ftrace test will need to have CONFIG_FTRACE enabled to make the
ftrace directory available.

Add an additional check to skip this test if the CONFIG_FTRACE was not
enabled.

This will be helpful to avoid a false-positive test result when testing
it directly with the following commad against a kernel that does not
have CONFIG_FTRACE enabled:
    make -C tools/testing/selftests TARGETS=ftrace run_tests

The test result on an Ubuntu KVM kernel will be changed from:
    selftests: ftrace: ftracetest
    ========================================
    Error: No ftrace directory found
    not ok 1..1 selftests: ftrace: ftracetest [FAIL]
To:
    selftests: ftrace: ftracetest
    ========================================
    CONFIG_FTRACE was not enabled, test skipped.
    not ok 1..1 selftests: ftrace: ftracetest [SKIP]

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

shuah July 2, 2019, 7:22 p.m. UTC | #1
Hi Po-Hsu Lin,

On 7/2/19 12:23 AM, Po-Hsu Lin wrote:
> The ftrace test will need to have CONFIG_FTRACE enabled to make the
> ftrace directory available.
> 
> Add an additional check to skip this test if the CONFIG_FTRACE was not
> enabled.
> 
> This will be helpful to avoid a false-positive test result when testing
> it directly with the following commad against a kernel that does not
> have CONFIG_FTRACE enabled:
>      make -C tools/testing/selftests TARGETS=ftrace run_tests
> 
> The test result on an Ubuntu KVM kernel will be changed from:
>      selftests: ftrace: ftracetest
>      ========================================
>      Error: No ftrace directory found
>      not ok 1..1 selftests: ftrace: ftracetest [FAIL]
> To:

Thanks for the patch.

Check patch fails with the above To:

WARNING: Use a single space after To:
#107:
To:

ERROR: Unrecognized email address: ''
#107:
To:

total: 1 errors, 1 warnings, 23 lines checked


Please fix and send v2.

>      selftests: ftrace: ftracetest
>      ========================================
>      CONFIG_FTRACE was not enabled, test skipped.
>      not ok 1..1 selftests: ftrace: ftracetest [SKIP]
> 
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>   tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> index 6d5e9e8..6c8322e 100755
> --- a/tools/testing/selftests/ftrace/ftracetest
> +++ b/tools/testing/selftests/ftrace/ftracetest
> @@ -7,6 +7,9 @@
>   #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
>   #

Hmm. You havem't cc'ed Masami on this. Adding Masami.

I would think Masami should be on the Signed-off-by as well,
since he is the author.

>   
> +# Kselftest framework requirement - SKIP code is 4.
> +ksft_skip=4
> +
>   usage() { # errno [message]
>   [ ! -z "$2" ] && echo $2
>   echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
> @@ -139,7 +142,13 @@ parse_opts $*
>   
>   # Verify parameters
>   if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
> -  errexit "No ftrace directory found"
> +  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
> +  if [ -z "$ftrace_enabled" ]; then
> +    echo "CONFIG_FTRACE was not enabled, test skipped."
> +    exit $ksft_skip
> +  else
> +    errexit "No ftrace directory found"
> +  fi
>   fi
>   
>   # Preparing logs
> 

thanks,
-- Shuah
Masami Hiramatsu July 3, 2019, 12:11 a.m. UTC | #2
Hi Po-Hsu Lin,

On Tue, 2 Jul 2019 13:22:26 -0600
shuah <shuah@kernel.org> wrote:

> Hi Po-Hsu Lin,
> 
> On 7/2/19 12:23 AM, Po-Hsu Lin wrote:
> > The ftrace test will need to have CONFIG_FTRACE enabled to make the
> > ftrace directory available.
> > 
> > Add an additional check to skip this test if the CONFIG_FTRACE was not
> > enabled.

Sorry, NAK for config check.

> > 
> > This will be helpful to avoid a false-positive test result when testing
> > it directly with the following commad against a kernel that does not
> > have CONFIG_FTRACE enabled:

Would you know tools/testing/selftests/ftrace/config (and other config files
in each tests) ?

Since each selftest depends specific configurations, those configs are
written in config file, and tester must enable it using 
"scripts/kconfig/merge_config.sh".

We can not check the kernel config in some cases, e.g. distro kernel,
cross-build kernel, remote build kernel etc. Also, the .config file
can be a config file for another kernel build.

So please take care of your kernel configuration. If you find any test
failed even if you enable configs in config file under that test, please
report it, since that is a bug.


Thank you,

> >      make -C tools/testing/selftests TARGETS=ftrace run_tests
> > 
> > The test result on an Ubuntu KVM kernel will be changed from:
> >      selftests: ftrace: ftracetest
> >      ========================================
> >      Error: No ftrace directory found
> >      not ok 1..1 selftests: ftrace: ftracetest [FAIL]
> > To:
> 
> Thanks for the patch.
> 
> Check patch fails with the above To:
> 
> WARNING: Use a single space after To:
> #107:
> To:
> 
> ERROR: Unrecognized email address: ''
> #107:
> To:
> 
> total: 1 errors, 1 warnings, 23 lines checked
> 
> 
> Please fix and send v2.
> 
> >      selftests: ftrace: ftracetest
> >      ========================================
> >      CONFIG_FTRACE was not enabled, test skipped.
> >      not ok 1..1 selftests: ftrace: ftracetest [SKIP]
> > 
> > Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> > ---
> >   tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
> >   1 file changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> > index 6d5e9e8..6c8322e 100755
> > --- a/tools/testing/selftests/ftrace/ftracetest
> > +++ b/tools/testing/selftests/ftrace/ftracetest
> > @@ -7,6 +7,9 @@
> >   #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> >   #
> 
> Hmm. You havem't cc'ed Masami on this. Adding Masami.
> 
> I would think Masami should be on the Signed-off-by as well,
> since he is the author.
> 
> >   
> > +# Kselftest framework requirement - SKIP code is 4.
> > +ksft_skip=4
> > +
> >   usage() { # errno [message]
> >   [ ! -z "$2" ] && echo $2
> >   echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
> > @@ -139,7 +142,13 @@ parse_opts $*
> >   
> >   # Verify parameters
> >   if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
> > -  errexit "No ftrace directory found"
> > +  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
> > +  if [ -z "$ftrace_enabled" ]; then
> > +    echo "CONFIG_FTRACE was not enabled, test skipped."
> > +    exit $ksft_skip
> > +  else
> > +    errexit "No ftrace directory found"
> > +  fi
> >   fi
> >   
> >   # Preparing logs
> > 
> 
> thanks,
> -- Shuah
Steven Rostedt July 3, 2019, 1:07 a.m. UTC | #3
On Wed, 3 Jul 2019 09:11:47 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Hi Po-Hsu Lin,
> 
> On Tue, 2 Jul 2019 13:22:26 -0600
> shuah <shuah@kernel.org> wrote:
> 
> > Hi Po-Hsu Lin,
> > 
> > On 7/2/19 12:23 AM, Po-Hsu Lin wrote:  
> > > The ftrace test will need to have CONFIG_FTRACE enabled to make the
> > > ftrace directory available.
> > > 
> > > Add an additional check to skip this test if the CONFIG_FTRACE was not
> > > enabled.  
> 
> Sorry, NAK for config check.

Agreed, as  my test boxes do not hold the source code of the kernel
they are running.

> 
> > > 
> > > This will be helpful to avoid a false-positive test result when testing
> > > it directly with the following commad against a kernel that does not
> > > have CONFIG_FTRACE enabled:  
> 
> Would you know tools/testing/selftests/ftrace/config (and other config files
> in each tests) ?
> 
> Since each selftest depends specific configurations, those configs are
> written in config file, and tester must enable it using 
> "scripts/kconfig/merge_config.sh".
> 
> We can not check the kernel config in some cases, e.g. distro kernel,
> cross-build kernel, remote build kernel etc. Also, the .config file
> can be a config file for another kernel build.
> 
> So please take care of your kernel configuration. If you find any test
> failed even if you enable configs in config file under that test, please
> report it, since that is a bug.
> 
> 
> Thank you,
> 
> > >      make -C tools/testing/selftests TARGETS=ftrace run_tests
> > > 
> > > The test result on an Ubuntu KVM kernel will be changed from:
> > >      selftests: ftrace: ftracetest
> > >      ========================================
> > >      Error: No ftrace directory found
> > >      not ok 1..1 selftests: ftrace: ftracetest [FAIL]
> > > To:  
> > 
> > Thanks for the patch.
> > 
> > Check patch fails with the above To:
> > 
> > WARNING: Use a single space after To:
> > #107:
> > To:
> > 
> > ERROR: Unrecognized email address: ''
> > #107:
> > To:
> > 
> > total: 1 errors, 1 warnings, 23 lines checked
> > 
> > 
> > Please fix and send v2.
> >   
> > >      selftests: ftrace: ftracetest
> > >      ========================================
> > >      CONFIG_FTRACE was not enabled, test skipped.
> > >      not ok 1..1 selftests: ftrace: ftracetest [SKIP]
> > > 
> > > Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> > > ---
> > >   tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
> > >   1 file changed, 10 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> > > index 6d5e9e8..6c8322e 100755
> > > --- a/tools/testing/selftests/ftrace/ftracetest
> > > +++ b/tools/testing/selftests/ftrace/ftracetest
> > > @@ -7,6 +7,9 @@
> > >   #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> > >   #  
> > 
> > Hmm. You havem't cc'ed Masami on this. Adding Masami.
> > 
> > I would think Masami should be on the Signed-off-by as well,
> > since he is the author.
> >   
> > >   
> > > +# Kselftest framework requirement - SKIP code is 4.
> > > +ksft_skip=4
> > > +
> > >   usage() { # errno [message]
> > >   [ ! -z "$2" ] && echo $2
> > >   echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
> > > @@ -139,7 +142,13 @@ parse_opts $*
> > >   
> > >   # Verify parameters
> > >   if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then

I'm thinking if we didn't find the TRACING_DIR (-z "$TRACING_DIR"
returns true), then we exit with the skip. I don't believe we should be
testing ftrace if tracefs isn't even loaded. Or something like:

	err_ret=1
	err_skip=4

	errexit() {
	  echo "Error: $1" 1>&2
	  exit $err_ret
	}

	[..]

	if [ -z "$TRACING_DIR" ]; then
	  save_err=$err_ret
	  err_ret=$err_skip
	  mount -t tracefs nodev /sys/kernel/tracing ||
	    errexit "kernel does not have tracefs"
	  err_ret=$save_err
	  TRACING_DIR="/sys/kernel/tracing"
	fi
	if [ ! -d "$TRACING_DIR" ]; then
	  errexit "tracefs is not a directory?"
	fi

Would something like that work?

-- Steve


> > > -  errexit "No ftrace directory found"
> > > +  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
> > > +  if [ -z "$ftrace_enabled" ]; then
> > > +    echo "CONFIG_FTRACE was not enabled, test skipped."
> > > +    exit $ksft_skip
> > > +  else
> > > +    errexit "No ftrace directory found"
> > > +  fi
> > >   fi
> > >   
> > >   # Preparing logs
> > >   
> > 
> > thanks,
> > -- Shuah  
> 
>
Masami Hiramatsu July 3, 2019, 3:09 a.m. UTC | #4
On Tue, 2 Jul 2019 21:07:30 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 3 Jul 2019 09:11:47 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > Hi Po-Hsu Lin,
> > 
> > On Tue, 2 Jul 2019 13:22:26 -0600
> > shuah <shuah@kernel.org> wrote:
> > 
> > > Hi Po-Hsu Lin,
> > > 
> > > On 7/2/19 12:23 AM, Po-Hsu Lin wrote:  
> > > > The ftrace test will need to have CONFIG_FTRACE enabled to make the
> > > > ftrace directory available.
> > > > 
> > > > Add an additional check to skip this test if the CONFIG_FTRACE was not
> > > > enabled.  
> > 
> > Sorry, NAK for config check.
> 
> Agreed, as  my test boxes do not hold the source code of the kernel
> they are running.
> 
> > 
> > > > 
> > > > This will be helpful to avoid a false-positive test result when testing
> > > > it directly with the following commad against a kernel that does not
> > > > have CONFIG_FTRACE enabled:  
> > 
> > Would you know tools/testing/selftests/ftrace/config (and other config files
> > in each tests) ?
> > 
> > Since each selftest depends specific configurations, those configs are
> > written in config file, and tester must enable it using 
> > "scripts/kconfig/merge_config.sh".
> > 
> > We can not check the kernel config in some cases, e.g. distro kernel,
> > cross-build kernel, remote build kernel etc. Also, the .config file
> > can be a config file for another kernel build.
> > 
> > So please take care of your kernel configuration. If you find any test
> > failed even if you enable configs in config file under that test, please
> > report it, since that is a bug.
> > 
> > 
> > Thank you,
> > 
> > > >      make -C tools/testing/selftests TARGETS=ftrace run_tests
> > > > 
> > > > The test result on an Ubuntu KVM kernel will be changed from:
> > > >      selftests: ftrace: ftracetest
> > > >      ========================================
> > > >      Error: No ftrace directory found
> > > >      not ok 1..1 selftests: ftrace: ftracetest [FAIL]
> > > > To:  
> > > 
> > > Thanks for the patch.
> > > 
> > > Check patch fails with the above To:
> > > 
> > > WARNING: Use a single space after To:
> > > #107:
> > > To:
> > > 
> > > ERROR: Unrecognized email address: ''
> > > #107:
> > > To:
> > > 
> > > total: 1 errors, 1 warnings, 23 lines checked
> > > 
> > > 
> > > Please fix and send v2.
> > >   
> > > >      selftests: ftrace: ftracetest
> > > >      ========================================
> > > >      CONFIG_FTRACE was not enabled, test skipped.
> > > >      not ok 1..1 selftests: ftrace: ftracetest [SKIP]
> > > > 
> > > > Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> > > > ---
> > > >   tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
> > > >   1 file changed, 10 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> > > > index 6d5e9e8..6c8322e 100755
> > > > --- a/tools/testing/selftests/ftrace/ftracetest
> > > > +++ b/tools/testing/selftests/ftrace/ftracetest
> > > > @@ -7,6 +7,9 @@
> > > >   #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> > > >   #  
> > > 
> > > Hmm. You havem't cc'ed Masami on this. Adding Masami.
> > > 
> > > I would think Masami should be on the Signed-off-by as well,
> > > since he is the author.
> > >   
> > > >   
> > > > +# Kselftest framework requirement - SKIP code is 4.
> > > > +ksft_skip=4
> > > > +
> > > >   usage() { # errno [message]
> > > >   [ ! -z "$2" ] && echo $2
> > > >   echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
> > > > @@ -139,7 +142,13 @@ parse_opts $*
> > > >   
> > > >   # Verify parameters
> > > >   if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
> 
> I'm thinking if we didn't find the TRACING_DIR (-z "$TRACING_DIR"
> returns true), then we exit with the skip. I don't believe we should be
> testing ftrace if tracefs isn't even loaded. Or something like:

Yeah, it should be skipped.

> 
> 	err_ret=1
> 	err_skip=4
> 
> 	errexit() {
> 	  echo "Error: $1" 1>&2
> 	  exit $err_ret
> 	}
> 
> 	[..]
> 
> 	if [ -z "$TRACING_DIR" ]; then
> 	  save_err=$err_ret
> 	  err_ret=$err_skip
> 	  mount -t tracefs nodev /sys/kernel/tracing ||
> 	    errexit "kernel does not have tracefs"
> 	  err_ret=$save_err
> 	  TRACING_DIR="/sys/kernel/tracing"
> 	fi
> 	if [ ! -d "$TRACING_DIR" ]; then
> 	  errexit "tracefs is not a directory?"
> 	fi
> 
> Would something like that work?

For older kernel, I think we'd better try to mount debugfs first.

Thank you,
Steven Rostedt July 3, 2019, 3:18 a.m. UTC | #5
On Wed, 3 Jul 2019 12:09:53 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > Would something like that work?  
> 
> For older kernel, I think we'd better try to mount debugfs first.

Sure, that's pretty trivial to do. Or what I was thinking, try it if it
fails:

 	if [ -z "$TRACING_DIR" ]; then
 	  save_err=$err_ret
 	  err_ret=$err_skip
	  if mount -t tracefs nodev /sys/kernel/tracing; then
 	    TRACING_DIR="/sys/kernel/tracing"
	  elif mount -t debugfs nodev /sys/kernel/debug; then
 	    TRACING_DIR="/sys/kernel/debug/tracing"
	  else
	    errexit "debugfs is not configured in this kernel"
	  fi
	  if [ ! -d "$TRACING_DIR" ]; then
	    errexit "ftrace is not configured in this kernel"
	  fi
 	  err_ret=$save_err
 	fi

-- Steve
Masami Hiramatsu July 3, 2019, 8:20 a.m. UTC | #6
On Tue, 2 Jul 2019 23:18:08 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Wed, 3 Jul 2019 12:09:53 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> > > Would something like that work?  
> > 
> > For older kernel, I think we'd better try to mount debugfs first.
> 
> Sure, that's pretty trivial to do. Or what I was thinking, try it if it
> fails:
> 
>  	if [ -z "$TRACING_DIR" ]; then
>  	  save_err=$err_ret
>  	  err_ret=$err_skip
> 	  if mount -t tracefs nodev /sys/kernel/tracing; then
>  	    TRACING_DIR="/sys/kernel/tracing"
> 	  elif mount -t debugfs nodev /sys/kernel/debug; then
>  	    TRACING_DIR="/sys/kernel/debug/tracing"
> 	  else
> 	    errexit "debugfs is not configured in this kernel"
> 	  fi
> 	  if [ ! -d "$TRACING_DIR" ]; then
> 	    errexit "ftrace is not configured in this kernel"
> 	  fi
>  	  err_ret=$save_err
>  	fi

This looks good to me :)

Thank you,

> 
> -- Steve
Po-Hsu Lin July 4, 2019, 12:14 p.m. UTC | #7
Hello,
Thanks all for your feedback!

On Wed, Jul 3, 2019 at 8:11 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> Hi Po-Hsu Lin,
>
> On Tue, 2 Jul 2019 13:22:26 -0600
> shuah <shuah@kernel.org> wrote:
>
> > Hi Po-Hsu Lin,
> >
> > On 7/2/19 12:23 AM, Po-Hsu Lin wrote:
> > > The ftrace test will need to have CONFIG_FTRACE enabled to make the
> > > ftrace directory available.
> > >
> > > Add an additional check to skip this test if the CONFIG_FTRACE was not
> > > enabled.
>
> Sorry, NAK for config check.
>
> > >
> > > This will be helpful to avoid a false-positive test result when testing
> > > it directly with the following commad against a kernel that does not
> > > have CONFIG_FTRACE enabled:
>
> Would you know tools/testing/selftests/ftrace/config (and other config files
> in each tests) ?
>
> Since each selftest depends specific configurations, those configs are
> written in config file, and tester must enable it using
> "scripts/kconfig/merge_config.sh".
>
> We can not check the kernel config in some cases, e.g. distro kernel,
> cross-build kernel, remote build kernel etc. Also, the .config file
> can be a config file for another kernel build.
>
> So please take care of your kernel configuration. If you find any test
> failed even if you enable configs in config file under that test, please
> report it, since that is a bug.
>
Yes I'm aware the config file.

People can still run a test directly without enabling corresponding
configs, so I think it's better to skip it if possible, directory
checking proposed by Steven looks better for this.

And thank you the explanation about the possible issue for a config check.

>
> Thank you,
>
> > >      make -C tools/testing/selftests TARGETS=ftrace run_tests
> > >
> > > The test result on an Ubuntu KVM kernel will be changed from:
> > >      selftests: ftrace: ftracetest
> > >      ========================================
> > >      Error: No ftrace directory found
> > >      not ok 1..1 selftests: ftrace: ftracetest [FAIL]
> > > To:
> >
> > Thanks for the patch.
> >
> > Check patch fails with the above To:
> >
> > WARNING: Use a single space after To:
> > #107:
> > To:
> >
> > ERROR: Unrecognized email address: ''
> > #107:
> > To:
> >
> > total: 1 errors, 1 warnings, 23 lines checked
> >

This is an interesting error here,
it looks like this checkpatch.pl script cannot identify the "To:" is
actually located inside the commit message.
I have to change this into something else to avoid this error.


> >
> > Please fix and send v2.
> >
> > >      selftests: ftrace: ftracetest
> > >      ========================================
> > >      CONFIG_FTRACE was not enabled, test skipped.
> > >      not ok 1..1 selftests: ftrace: ftracetest [SKIP]
> > >
> > > Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> > > ---
> > >   tools/testing/selftests/ftrace/ftracetest | 11 ++++++++++-
> > >   1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
> > > index 6d5e9e8..6c8322e 100755
> > > --- a/tools/testing/selftests/ftrace/ftracetest
> > > +++ b/tools/testing/selftests/ftrace/ftracetest
> > > @@ -7,6 +7,9 @@
> > >   #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> > >   #
> >
> > Hmm. You havem't cc'ed Masami on this. Adding Masami.
> >
> > I would think Masami should be on the Signed-off-by as well,
> > since he is the author.
> >
> > >
> > > +# Kselftest framework requirement - SKIP code is 4.
> > > +ksft_skip=4
> > > +
> > >   usage() { # errno [message]
> > >   [ ! -z "$2" ] && echo $2
> > >   echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
> > > @@ -139,7 +142,13 @@ parse_opts $*
> > >
> > >   # Verify parameters
> > >   if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
> > > -  errexit "No ftrace directory found"
> > > +  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
> > > +  if [ -z "$ftrace_enabled" ]; then
> > > +    echo "CONFIG_FTRACE was not enabled, test skipped."
> > > +    exit $ksft_skip
> > > +  else
> > > +    errexit "No ftrace directory found"
> > > +  fi
> > >   fi
> > >
> > >   # Preparing logs
> > >
> >
> > thanks,
> > -- Shuah
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>

Patch
diff mbox series

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 6d5e9e8..6c8322e 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -7,6 +7,9 @@ 
 #  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
 #
 
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
 usage() { # errno [message]
 [ ! -z "$2" ] && echo $2
 echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
@@ -139,7 +142,13 @@  parse_opts $*
 
 # Verify parameters
 if [ -z "$TRACING_DIR" -o ! -d "$TRACING_DIR" ]; then
-  errexit "No ftrace directory found"
+  ftrace_enabled=`grep "^CONFIG_FTRACE=y" /lib/modules/$(uname -r)/build/.config`
+  if [ -z "$ftrace_enabled" ]; then
+    echo "CONFIG_FTRACE was not enabled, test skipped."
+    exit $ksft_skip
+  else
+    errexit "No ftrace directory found"
+  fi
 fi
 
 # Preparing logs