diff mbox series

[v3,5/5] lib/test_sysctl: support testing of sysctl. boot parameter

Message ID 20200427180433.7029-6-vbabka@suse.cz (mailing list archive)
State New, archived
Headers show
Series support setting sysctl parameters from kernel command line | expand

Commit Message

Vlastimil Babka April 27, 2020, 6:04 p.m. UTC
Testing is done by a new parameter debug.test_sysctl.boot_int which defaults to
0 and it's expected that the tester passes a boot parameter that sets it to 1.
The test checks if it's set to 1. To distinguish true failure from parameter
not being set, the test checks /proc/cmdline for the expected parameter, and
whether test_sysctl is built-in and not a module.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 lib/test_sysctl.c                        | 13 +++++++++
 tools/testing/selftests/sysctl/sysctl.sh | 36 ++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

Comments

Luis Chamberlain April 27, 2020, 6:39 p.m. UTC | #1
On Mon, Apr 27, 2020 at 08:04:33PM +0200, Vlastimil Babka wrote:
> Testing is done by a new parameter debug.test_sysctl.boot_int which defaults to
> 0 and it's expected that the tester passes a boot parameter that sets it to 1.
> The test checks if it's set to 1. To distinguish true failure from parameter
> not being set, the test checks /proc/cmdline for the expected parameter, and
> whether test_sysctl is built-in and not a module.
> 
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  lib/test_sysctl.c                        | 13 +++++++++
>  tools/testing/selftests/sysctl/sysctl.sh | 36 ++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
> index 566dad3f4196..84eaae22d3a6 100644
> --- a/lib/test_sysctl.c
> +++ b/lib/test_sysctl.c
> @@ -44,6 +44,8 @@ struct test_sysctl_data {
>  	int int_0002;
>  	int int_0003[4];
>  
> +	int boot_int;
> +
>  	unsigned int uint_0001;
>  
>  	char string_0001[65];
> @@ -61,6 +63,8 @@ static struct test_sysctl_data test_data = {
>  	.int_0003[2] = 2,
>  	.int_0003[3] = 3,
>  
> +	.boot_int = 0,
> +
>  	.uint_0001 = 314,
>  
>  	.string_0001 = "(none)",
> @@ -91,6 +95,15 @@ static struct ctl_table test_table[] = {
>  		.mode		= 0644,
>  		.proc_handler	= proc_dointvec,
>  	},
> +	{
> +		.procname	= "boot_int",
> +		.data		= &test_data.boot_int,
> +		.maxlen		= sizeof(test_data.boot_int),
> +		.mode		= 0644,
> +		.proc_handler	= proc_dointvec,
> +		.extra1		= SYSCTL_ZERO,
> +		.extra2         = SYSCTL_ONE,
> +	},
>  	{
>  		.procname	= "uint_0001",
>  		.data		= &test_data.uint_0001,
> diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
> index ce1eeea6f769..ef6417b8067b 100755
> --- a/tools/testing/selftests/sysctl/sysctl.sh
> +++ b/tools/testing/selftests/sysctl/sysctl.sh
> @@ -39,6 +39,7 @@ ALL_TESTS="$ALL_TESTS 0003:1:1:int_0002"
>  ALL_TESTS="$ALL_TESTS 0004:1:1:uint_0001"
>  ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003"
>  ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001"
> +ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int"
>  
>  test_modprobe()
>  {
> @@ -752,6 +753,40 @@ sysctl_test_0006()
>  	run_bitmaptest
>  }
>  
> +sysctl_test_0007()
> +{
> +	TARGET="${SYSCTL}/boot_int"
> +	if [ -d $DIR ]; then
> +		echo "Boot param test only possible sysctl_test is built-in, not module:"
> +		cat $TEST_DIR/config >&2
> +		return 0
> +	fi

Nice, also we could just require

diff --git a/tools/testing/selftests/sysctl/config b/tools/testing/selftests/sysctl/config
index 6ca14800d755..34461cc99a2b 100644
--- a/tools/testing/selftests/sysctl/config
+++ b/tools/testing/selftests/sysctl/config
@@ -1 +1,3 @@
 CONFIG_TEST_SYSCTL=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y

tools/testing/selftests/firmware/fw_lib.sh then has a kconfig_has()
which can verify the exact config.

> +
> +	echo -n "Testing if $TARGET is set to 1 ..."
> +	ORIG=$(cat "${TARGET}")

This would fail if someone uses this script to test an older kernel, and
the scripts in selftests are supposed to work with older kernels. One
way to address this would be to just see if the file exists first and
ignore the test if the $SYSCTL directory exists but the file $TARGET
does not.

For now we can just do this:

if [ ! -d $TARGET ]; then
	echo "Skipping test for $TARGET as it is not present ..."
	return 0
fi

  Luis
Vlastimil Babka May 11, 2020, 11:05 a.m. UTC | #2
On 4/27/20 8:39 PM, Luis Chamberlain wrote:
> On Mon, Apr 27, 2020 at 08:04:33PM +0200, Vlastimil Babka wrote:
> Nice, also we could just require
> 
> diff --git a/tools/testing/selftests/sysctl/config b/tools/testing/selftests/sysctl/config
> index 6ca14800d755..34461cc99a2b 100644
> --- a/tools/testing/selftests/sysctl/config
> +++ b/tools/testing/selftests/sysctl/config
> @@ -1 +1,3 @@
>  CONFIG_TEST_SYSCTL=y
> +CONFIG_IKCONFIG=y
> +CONFIG_IKCONFIG_PROC=y
> 
> tools/testing/selftests/firmware/fw_lib.sh then has a kconfig_has()
> which can verify the exact config.

Hmm but it also has a (firmware area specific) fallback for case where
IKCONFIG_PROC doesn't exist. So it's simpler to just keep checking the module
dir, IMHO, as that would be the fallback. 

>> +
>> +	echo -n "Testing if $TARGET is set to 1 ..."
>> +	ORIG=$(cat "${TARGET}")
> 
> This would fail if someone uses this script to test an older kernel, and
> the scripts in selftests are supposed to work with older kernels.

Oh, I didn't know that it's supposed to.

> One
> way to address this would be to just see if the file exists first and
> ignore the test if the $SYSCTL directory exists but the file $TARGET
> does not.
> 
> For now we can just do this:
> 
> if [ ! -d $TARGET ]; then
> 	echo "Skipping test for $TARGET as it is not present ..."
> 	return 0
> fi

OK, just the -d test needs to be fixed :) Andrew can you please apply:

----8<----
From a999e993a89e521b152bbd4b1466f69e62879c30 Mon Sep 17 00:00:00 2001
From: Vlastimil Babka <vbabka@suse.cz>
Date: Mon, 11 May 2020 12:59:49 +0200
Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
 fix

Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
"This would fail if someone uses this script to test an older kernel, and
the scripts in selftests are supposed to work with older kernels."

Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 tools/testing/selftests/sysctl/sysctl.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index ef6417b8067b..148704f465b5 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -756,6 +756,11 @@ sysctl_test_0006()
 sysctl_test_0007()
 {
 	TARGET="${SYSCTL}/boot_int"
+	if [ ! -f $TARGET ]; then
+		echo "Skipping test for $TARGET as it is not present ..."
+		return 0
+	fi
+
 	if [ -d $DIR ]; then
 		echo "Boot param test only possible sysctl_test is built-in, not module:"
 		cat $TEST_DIR/config >&2
Luis Chamberlain May 11, 2020, 6:31 p.m. UTC | #3
On Mon, May 11, 2020 at 01:05:22PM +0200, Vlastimil Babka wrote:
> 
> On 4/27/20 8:39 PM, Luis Chamberlain wrote:
> > On Mon, Apr 27, 2020 at 08:04:33PM +0200, Vlastimil Babka wrote:
> > Nice, also we could just require
> > 
> > diff --git a/tools/testing/selftests/sysctl/config b/tools/testing/selftests/sysctl/config
> > index 6ca14800d755..34461cc99a2b 100644
> > --- a/tools/testing/selftests/sysctl/config
> > +++ b/tools/testing/selftests/sysctl/config
> > @@ -1 +1,3 @@
> >  CONFIG_TEST_SYSCTL=y
> > +CONFIG_IKCONFIG=y
> > +CONFIG_IKCONFIG_PROC=y
> > 
> > tools/testing/selftests/firmware/fw_lib.sh then has a kconfig_has()
> > which can verify the exact config.
> 
> Hmm but it also has a (firmware area specific) fallback for case where
> IKCONFIG_PROC doesn't exist. So it's simpler to just keep checking the module
> dir, IMHO, as that would be the fallback. 

As you wish.

> >> +
> >> +	echo -n "Testing if $TARGET is set to 1 ..."
> >> +	ORIG=$(cat "${TARGET}")
> > 
> > This would fail if someone uses this script to test an older kernel, and
> > the scripts in selftests are supposed to work with older kernels.
> 
> Oh, I didn't know that it's supposed to.

Yeap, that's how they are used.

> > One
> > way to address this would be to just see if the file exists first and
> > ignore the test if the $SYSCTL directory exists but the file $TARGET
> > does not.
> > 
> > For now we can just do this:
> > 
> > if [ ! -d $TARGET ]; then
> > 	echo "Skipping test for $TARGET as it is not present ..."
> > 	return 0
> > fi
> 
> OK, just the -d test needs to be fixed :) Andrew can you please apply:
> 
> ----8<----
> From a999e993a89e521b152bbd4b1466f69e62879c30 Mon Sep 17 00:00:00 2001
> From: Vlastimil Babka <vbabka@suse.cz>
> Date: Mon, 11 May 2020 12:59:49 +0200
> Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
>  fix
> 
> Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
> "This would fail if someone uses this script to test an older kernel, and
> the scripts in selftests are supposed to work with older kernels."
> 
> Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
>  tools/testing/selftests/sysctl/sysctl.sh | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
> index ef6417b8067b..148704f465b5 100755
> --- a/tools/testing/selftests/sysctl/sysctl.sh
> +++ b/tools/testing/selftests/sysctl/sysctl.sh
> @@ -756,6 +756,11 @@ sysctl_test_0006()

You want to:

                                                                                
# Kselftest framework requirement - SKIP code is 4.                             
ksft_skip=4 

>  sysctl_test_0007()
>  {
>  	TARGET="${SYSCTL}/boot_int"
> +	if [ ! -f $TARGET ]; then
> +		echo "Skipping test for $TARGET as it is not present ..."
> +		return 0
> +	fi

And return 4 instead.

  Luis
> +
>  	if [ -d $DIR ]; then
>  		echo "Boot param test only possible sysctl_test is built-in, not module:"
>  		cat $TEST_DIR/config >&2
> -- 
> 2.26.2
>
Vlastimil Babka May 13, 2020, 8:58 a.m. UTC | #4
On 5/11/20 8:31 PM, Luis Chamberlain wrote:
> On Mon, May 11, 2020 at 01:05:22PM +0200, Vlastimil Babka wrote:
>> ----8<----
>> From a999e993a89e521b152bbd4b1466f69e62879c30 Mon Sep 17 00:00:00 2001
>> From: Vlastimil Babka <vbabka@suse.cz>
>> Date: Mon, 11 May 2020 12:59:49 +0200
>> Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
>>  fix
>> 
>> Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
>> "This would fail if someone uses this script to test an older kernel, and
>> the scripts in selftests are supposed to work with older kernels."
>> 
>> Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
>> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
>> ---
>>  tools/testing/selftests/sysctl/sysctl.sh | 5 +++++
>>  1 file changed, 5 insertions(+)
>> 
>> diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
>> index ef6417b8067b..148704f465b5 100755
>> --- a/tools/testing/selftests/sysctl/sysctl.sh
>> +++ b/tools/testing/selftests/sysctl/sysctl.sh
>> @@ -756,6 +756,11 @@ sysctl_test_0006()
> 
> You want to:
> 
>                                                                                 
> # Kselftest framework requirement - SKIP code is 4.                             
> ksft_skip=4 
> 
>>  sysctl_test_0007()
>>  {
>>  	TARGET="${SYSCTL}/boot_int"
>> +	if [ ! -f $TARGET ]; then
>> +		echo "Skipping test for $TARGET as it is not present ..."
>> +		return 0
>> +	fi
> 
> And return 4 instead.

If I return it from the function, nobody will care, AFAICS. If I 'exit
$ksft_skip', is that correct if it's just a single test out of 7? What's the
proper way?

Thanks

>   Luis
>> +
>>  	if [ -d $DIR ]; then
>>  		echo "Boot param test only possible sysctl_test is built-in, not module:"
>>  		cat $TEST_DIR/config >&2
>> -- 
>> 2.26.2
>> 
>
Luis Chamberlain May 13, 2020, 1:15 p.m. UTC | #5
On Wed, May 13, 2020 at 10:58:16AM +0200, Vlastimil Babka wrote:
> On 5/11/20 8:31 PM, Luis Chamberlain wrote:
> > On Mon, May 11, 2020 at 01:05:22PM +0200, Vlastimil Babka wrote:
> >> ----8<----
> >> From a999e993a89e521b152bbd4b1466f69e62879c30 Mon Sep 17 00:00:00 2001
> >> From: Vlastimil Babka <vbabka@suse.cz>
> >> Date: Mon, 11 May 2020 12:59:49 +0200
> >> Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
> >>  fix
> >> 
> >> Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
> >> "This would fail if someone uses this script to test an older kernel, and
> >> the scripts in selftests are supposed to work with older kernels."
> >> 
> >> Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
> >> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> >> ---
> >>  tools/testing/selftests/sysctl/sysctl.sh | 5 +++++
> >>  1 file changed, 5 insertions(+)
> >> 
> >> diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
> >> index ef6417b8067b..148704f465b5 100755
> >> --- a/tools/testing/selftests/sysctl/sysctl.sh
> >> +++ b/tools/testing/selftests/sysctl/sysctl.sh
> >> @@ -756,6 +756,11 @@ sysctl_test_0006()
> > 
> > You want to:
> > 
> >                                                                                 
> > # Kselftest framework requirement - SKIP code is 4.                             
> > ksft_skip=4 
> > 
> >>  sysctl_test_0007()
> >>  {
> >>  	TARGET="${SYSCTL}/boot_int"
> >> +	if [ ! -f $TARGET ]; then
> >> +		echo "Skipping test for $TARGET as it is not present ..."
> >> +		return 0
> >> +	fi
> > 
> > And return 4 instead.
> 
> If I return it from the function, nobody will care, AFAICS. If I 'exit
> $ksft_skip', is that correct if it's just a single test out of 7?

yes please do that.

  Luis
Luis Chamberlain May 13, 2020, 1:17 p.m. UTC | #6
On Wed, May 13, 2020 at 7:15 AM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> On Wed, May 13, 2020 at 10:58:16AM +0200, Vlastimil Babka wrote:
> > On 5/11/20 8:31 PM, Luis Chamberlain wrote:
> > > On Mon, May 11, 2020 at 01:05:22PM +0200, Vlastimil Babka wrote:
> > >> ----8<----
> > >> From a999e993a89e521b152bbd4b1466f69e62879c30 Mon Sep 17 00:00:00 2001
> > >> From: Vlastimil Babka <vbabka@suse.cz>
> > >> Date: Mon, 11 May 2020 12:59:49 +0200
> > >> Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
> > >>  fix
> > >>
> > >> Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
> > >> "This would fail if someone uses this script to test an older kernel, and
> > >> the scripts in selftests are supposed to work with older kernels."
> > >>
> > >> Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
> > >> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> > >> ---
> > >>  tools/testing/selftests/sysctl/sysctl.sh | 5 +++++
> > >>  1 file changed, 5 insertions(+)
> > >>
> > >> diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
> > >> index ef6417b8067b..148704f465b5 100755
> > >> --- a/tools/testing/selftests/sysctl/sysctl.sh
> > >> +++ b/tools/testing/selftests/sysctl/sysctl.sh
> > >> @@ -756,6 +756,11 @@ sysctl_test_0006()
> > >
> > > You want to:
> > >
> > >
> > > # Kselftest framework requirement - SKIP code is 4.
> > > ksft_skip=4
> > >
> > >>  sysctl_test_0007()
> > >>  {
> > >>    TARGET="${SYSCTL}/boot_int"
> > >> +  if [ ! -f $TARGET ]; then
> > >> +          echo "Skipping test for $TARGET as it is not present ..."
> > >> +          return 0
> > >> +  fi
> > >
> > > And return 4 instead.
> >
> > If I return it from the function, nobody will care, AFAICS. If I 'exit
> > $ksft_skip', is that correct if it's just a single test out of 7?
>
> yes please do that.

Ah but once we add test_0008() it may be supported.. so I think return
would be OK
Vlastimil Babka May 15, 2020, 4:02 p.m. UTC | #7
On 5/13/20 3:17 PM, Luis Chamberlain wrote:
> On Wed, May 13, 2020 at 7:15 AM Luis Chamberlain <mcgrof@kernel.org> wrote:
>> > >
>> > > You want to:
>> > >
>> > >
>> > > # Kselftest framework requirement - SKIP code is 4.
>> > > ksft_skip=4
>> > >
>> > >>  sysctl_test_0007()
>> > >>  {
>> > >>    TARGET="${SYSCTL}/boot_int"
>> > >> +  if [ ! -f $TARGET ]; then
>> > >> +          echo "Skipping test for $TARGET as it is not present ..."
>> > >> +          return 0
>> > >> +  fi
>> > >
>> > > And return 4 instead.
>> >
>> > If I return it from the function, nobody will care, AFAICS. If I 'exit
>> > $ksft_skip', is that correct if it's just a single test out of 7?
>>
>> yes please do that.
> 
> Ah but once we add test_0008() it may be supported.. so I think return
> would be OK

OK

----8<----
From 4311b356f177aaa4e21bd3d2a2169e5bd50ab62d Mon Sep 17 00:00:00 2001
From: Vlastimil Babka <vbabka@suse.cz>
Date: Mon, 11 May 2020 12:59:49 +0200
Subject: [PATCH] lib/test_sysctl: support testing of sysctl. boot parameter -
 fix

Skip the new test if boot_int sysctl is not present, otherwise, per Luis,
"This would fail if someone uses this script to test an older kernel, and
the scripts in selftests are supposed to work with older kernels."

Suggested-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
 tools/testing/selftests/sysctl/sysctl.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index ef6417b8067b..ab44d3e65986 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -756,10 +756,15 @@ sysctl_test_0006()
 sysctl_test_0007()
 {
 	TARGET="${SYSCTL}/boot_int"
+	if [ ! -f $TARGET ]; then
+		echo "Skipping test for $TARGET as it is not present ..."
+		return $ksft_skip
+	fi
+
 	if [ -d $DIR ]; then
 		echo "Boot param test only possible sysctl_test is built-in, not module:"
 		cat $TEST_DIR/config >&2
-		return 0
+		return $ksft_skip
 	fi
 
 	echo -n "Testing if $TARGET is set to 1 ..."
@@ -785,6 +790,7 @@ sysctl_test_0007()
 
 	echo "Skipping test, expected kernel parameter missing."
 	echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
+	return $ksft_skip
 }
 
 list_tests()
diff mbox series

Patch

diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c
index 566dad3f4196..84eaae22d3a6 100644
--- a/lib/test_sysctl.c
+++ b/lib/test_sysctl.c
@@ -44,6 +44,8 @@  struct test_sysctl_data {
 	int int_0002;
 	int int_0003[4];
 
+	int boot_int;
+
 	unsigned int uint_0001;
 
 	char string_0001[65];
@@ -61,6 +63,8 @@  static struct test_sysctl_data test_data = {
 	.int_0003[2] = 2,
 	.int_0003[3] = 3,
 
+	.boot_int = 0,
+
 	.uint_0001 = 314,
 
 	.string_0001 = "(none)",
@@ -91,6 +95,15 @@  static struct ctl_table test_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+	{
+		.procname	= "boot_int",
+		.data		= &test_data.boot_int,
+		.maxlen		= sizeof(test_data.boot_int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+		.extra1		= SYSCTL_ZERO,
+		.extra2         = SYSCTL_ONE,
+	},
 	{
 		.procname	= "uint_0001",
 		.data		= &test_data.uint_0001,
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index ce1eeea6f769..ef6417b8067b 100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
@@ -39,6 +39,7 @@  ALL_TESTS="$ALL_TESTS 0003:1:1:int_0002"
 ALL_TESTS="$ALL_TESTS 0004:1:1:uint_0001"
 ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003"
 ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001"
+ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int"
 
 test_modprobe()
 {
@@ -752,6 +753,40 @@  sysctl_test_0006()
 	run_bitmaptest
 }
 
+sysctl_test_0007()
+{
+	TARGET="${SYSCTL}/boot_int"
+	if [ -d $DIR ]; then
+		echo "Boot param test only possible sysctl_test is built-in, not module:"
+		cat $TEST_DIR/config >&2
+		return 0
+	fi
+
+	echo -n "Testing if $TARGET is set to 1 ..."
+	ORIG=$(cat "${TARGET}")
+
+	if [ x$ORIG = "x1" ]; then
+		echo "ok"
+		return 0
+	fi
+	echo "FAIL"
+	echo "Checking if /proc/cmdline contains setting of the expected parameter ..."
+	if [ ! -f /proc/cmdline ]; then
+		echo "/proc/cmdline does not exist, test inconclusive"
+		return 0
+	fi
+
+	FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline)
+	if [ $FOUND = "1" ]; then
+		echo "Kernel param found but $TARGET is not 1, TEST FAILED"
+		rc=1
+		test_rc
+	fi
+
+	echo "Skipping test, expected kernel parameter missing."
+	echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
+}
+
 list_tests()
 {
 	echo "Test ID list:"
@@ -766,6 +801,7 @@  list_tests()
 	echo "0004 x $(get_test_count 0004) - tests proc_douintvec()"
 	echo "0005 x $(get_test_count 0005) - tests proc_douintvec() array"
 	echo "0006 x $(get_test_count 0006) - tests proc_do_large_bitmap()"
+	echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param"
 }
 
 usage()