diff mbox series

[2/6] selftests/clone3: add a check for invalid exit_signal

Message ID f5c715164c87a226afca711559e7ed72a70426a4.1568116761.git.esyr@redhat.com (mailing list archive)
State New
Headers show
Series Update clone3 self-tests | expand

Commit Message

Eugene Syromiatnikov Sept. 10, 2019, 12:03 p.m. UTC
Check that the kernel fails calls with exit_signal with non-zero highest
32 bits.

* tools/testing/selftests/clone3/clone3.c (enum test_mode): Add
CLONE3_ARGS_BIG_EXIT_SIGNAL.
(call_clone3): Add args.exit_signal initialisation in case
test_mode == CLONE3_ARGS_BIG_EXIT_SIGNAL.
(main): Add test_clone3 clone check with
test_mode == CLONE3_ARGS_BIG_EXIT_SIGNAL.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 tools/testing/selftests/clone3/clone3.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Shuah Sept. 16, 2019, 4:37 p.m. UTC | #1
On 9/10/19 6:03 AM, Eugene Syromiatnikov wrote:
> Check that the kernel fails calls with exit_signal with non-zero highest
> 32 bits.
> 

Describe what you are testing:

"Add a test case for clone3() non-zero highest 32 bits behavior. It
should fail with exit_signal value??"

Add checks for unsupported cases. Handle unsupported architectures
and configurations with skip

> * tools/testing/selftests/clone3/clone3.c (enum test_mode): Add
> CLONE3_ARGS_BIG_EXIT_SIGNAL.
> (call_clone3): Add args.exit_signal initialisation in case
> test_mode == CLONE3_ARGS_BIG_EXIT_SIGNAL.
> (main): Add test_clone3 clone check with
> test_mode == CLONE3_ARGS_BIG_EXIT_SIGNAL.

Please don't include pseudo code in the commit log.

> 
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>   tools/testing/selftests/clone3/clone3.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
> index 7b65ee5..4f23a0c 100644
> --- a/tools/testing/selftests/clone3/clone3.c
> +++ b/tools/testing/selftests/clone3/clone3.c
> @@ -28,6 +28,7 @@ enum test_mode {
>   	CLONE3_ARGS_NO_TEST,
>   	CLONE3_ARGS_ALL_0,
>   	CLONE3_ARGS_ALL_1,
> +	CLONE3_ARGS_BIG_EXIT_SIGNAL,
>   };
>   
>   static pid_t raw_clone(struct clone_args *args, size_t size)
> @@ -72,6 +73,10 @@ static int call_clone3(int flags, size_t size, enum test_mode test_mode)
>   		args.tls = 1;
>   		args.set_tid = 1;
>   		break;
> +
> +	case CLONE3_ARGS_BIG_EXIT_SIGNAL:
> +		args.exit_signal = 0xbadc0ded00000000;

Please add a comment to indicate what this is. I am assuming
this bad sig val.

> +		break;
>   	}
>   
>   	pid = raw_clone(&args, size);
> @@ -146,6 +151,10 @@ int main(int argc, char *argv[])
>   	/* Do a clone3() with all members set to 1 */
>   	if (test_clone3(0, CLONE3_ARGS_SIZE_V0, -EINVAL, CLONE3_ARGS_ALL_1))
>   		goto on_error;
> +	/* Do a clone3() with exit_signal having highest 32 bits non-zero */
> +	if (test_clone3(0, CLONE3_ARGS_SIZE_V0, -EINVAL,
> +			CLONE3_ARGS_BIG_EXIT_SIGNAL))
> +		goto on_error;
>   	/*
>   	 * Do a clone3() with sizeof(struct clone_args) + 8
>   	 * and all members set to 0.
> 

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
index 7b65ee5..4f23a0c 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -28,6 +28,7 @@  enum test_mode {
 	CLONE3_ARGS_NO_TEST,
 	CLONE3_ARGS_ALL_0,
 	CLONE3_ARGS_ALL_1,
+	CLONE3_ARGS_BIG_EXIT_SIGNAL,
 };
 
 static pid_t raw_clone(struct clone_args *args, size_t size)
@@ -72,6 +73,10 @@  static int call_clone3(int flags, size_t size, enum test_mode test_mode)
 		args.tls = 1;
 		args.set_tid = 1;
 		break;
+
+	case CLONE3_ARGS_BIG_EXIT_SIGNAL:
+		args.exit_signal = 0xbadc0ded00000000;
+		break;
 	}
 
 	pid = raw_clone(&args, size);
@@ -146,6 +151,10 @@  int main(int argc, char *argv[])
 	/* Do a clone3() with all members set to 1 */
 	if (test_clone3(0, CLONE3_ARGS_SIZE_V0, -EINVAL, CLONE3_ARGS_ALL_1))
 		goto on_error;
+	/* Do a clone3() with exit_signal having highest 32 bits non-zero */
+	if (test_clone3(0, CLONE3_ARGS_SIZE_V0, -EINVAL,
+			CLONE3_ARGS_BIG_EXIT_SIGNAL))
+		goto on_error;
 	/*
 	 * Do a clone3() with sizeof(struct clone_args) + 8
 	 * and all members set to 0.