linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] selftests/user_events: Fix abi_test for BE archs
@ 2023-10-05 21:57 Beau Belgrave
  2023-10-17 20:38 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Beau Belgrave @ 2023-10-05 21:57 UTC (permalink / raw)
  To: rostedt, shuah, mhiramat
  Cc: linux-kernel, linux-kselftest, linux-trace-kernel

The abi_test currently uses a long sized test value for enablement
checks. On LE this works fine, however, on BE this results in inaccurate
assert checks due to a bit being used and assuming it's value is the
same on both LE and BE.

Use int type for 32-bit values and long type for 64-bit values to ensure
appropriate behavior on both LE and BE.

Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
---
V3 Changes:
Fix missing cast in clone_check().

V2 Changes:
Rebase to linux-kselftest/fixes.

 tools/testing/selftests/user_events/abi_test.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
index 8202f1327c39..f5575ef2007c 100644
--- a/tools/testing/selftests/user_events/abi_test.c
+++ b/tools/testing/selftests/user_events/abi_test.c
@@ -47,7 +47,7 @@ static int change_event(bool enable)
 	return ret;
 }
 
-static int reg_enable(long *enable, int size, int bit)
+static int reg_enable(void *enable, int size, int bit)
 {
 	struct user_reg reg = {0};
 	int fd = open(data_file, O_RDWR);
@@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit)
 	return ret;
 }
 
-static int reg_disable(long *enable, int bit)
+static int reg_disable(void *enable, int bit)
 {
 	struct user_unreg reg = {0};
 	int fd = open(data_file, O_RDWR);
@@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit)
 }
 
 FIXTURE(user) {
-	long check;
+	int check;
+	long check_long;
 	bool umount;
 };
 
@@ -99,6 +100,7 @@ FIXTURE_SETUP(user) {
 
 	change_event(false);
 	self->check = 0;
+	self->check_long = 0;
 }
 
 FIXTURE_TEARDOWN(user) {
@@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) {
 
 #if BITS_PER_LONG == 8
 	/* Allow 0-64 bits for 64-bit */
-	ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63));
-	ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64));
-	ASSERT_EQ(0, reg_disable(&self->check, 63));
+	ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63));
+	ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64));
+	ASSERT_EQ(0, reg_disable(&self->check_long, 63));
 #endif
 
 	/* Disallowed sizes (everything beside 4 and 8) */
@@ -200,7 +202,7 @@ static int clone_check(void *check)
 	for (i = 0; i < 10; ++i) {
 		usleep(100000);
 
-		if (*(long *)check)
+		if (*(int *)check)
 			return 0;
 	}
 

base-commit: 6f874fa021dfc7bf37f4f37da3a5aaa41fe9c39c
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] selftests/user_events: Fix abi_test for BE archs
  2023-10-05 21:57 [PATCH v3] selftests/user_events: Fix abi_test for BE archs Beau Belgrave
@ 2023-10-17 20:38 ` Steven Rostedt
  2023-10-17 21:10   ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2023-10-17 20:38 UTC (permalink / raw)
  To: Beau Belgrave
  Cc: shuah, mhiramat, linux-kernel, linux-kselftest,
	linux-trace-kernel, Shuah Khan

On Thu,  5 Oct 2023 21:57:12 +0000
Beau Belgrave <beaub@linux.microsoft.com> wrote:

> The abi_test currently uses a long sized test value for enablement
> checks. On LE this works fine, however, on BE this results in inaccurate
> assert checks due to a bit being used and assuming it's value is the
> same on both LE and BE.
> 
> Use int type for 32-bit values and long type for 64-bit values to ensure
> appropriate behavior on both LE and BE.
> 
> Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
> Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
> ---
> V3 Changes:
> Fix missing cast in clone_check().
> 
> V2 Changes:
> Rebase to linux-kselftest/fixes.

Shuah,

Can you take this patch?

Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>

-- Steve

> 
>  tools/testing/selftests/user_events/abi_test.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/testing/selftests/user_events/abi_test.c b/tools/testing/selftests/user_events/abi_test.c
> index 8202f1327c39..f5575ef2007c 100644
> --- a/tools/testing/selftests/user_events/abi_test.c
> +++ b/tools/testing/selftests/user_events/abi_test.c
> @@ -47,7 +47,7 @@ static int change_event(bool enable)
>  	return ret;
>  }
>  
> -static int reg_enable(long *enable, int size, int bit)
> +static int reg_enable(void *enable, int size, int bit)
>  {
>  	struct user_reg reg = {0};
>  	int fd = open(data_file, O_RDWR);
> @@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit)
>  	return ret;
>  }
>  
> -static int reg_disable(long *enable, int bit)
> +static int reg_disable(void *enable, int bit)
>  {
>  	struct user_unreg reg = {0};
>  	int fd = open(data_file, O_RDWR);
> @@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit)
>  }
>  
>  FIXTURE(user) {
> -	long check;
> +	int check;
> +	long check_long;
>  	bool umount;
>  };
>  
> @@ -99,6 +100,7 @@ FIXTURE_SETUP(user) {
>  
>  	change_event(false);
>  	self->check = 0;
> +	self->check_long = 0;
>  }
>  
>  FIXTURE_TEARDOWN(user) {
> @@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) {
>  
>  #if BITS_PER_LONG == 8
>  	/* Allow 0-64 bits for 64-bit */
> -	ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63));
> -	ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64));
> -	ASSERT_EQ(0, reg_disable(&self->check, 63));
> +	ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63));
> +	ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64));
> +	ASSERT_EQ(0, reg_disable(&self->check_long, 63));
>  #endif
>  
>  	/* Disallowed sizes (everything beside 4 and 8) */
> @@ -200,7 +202,7 @@ static int clone_check(void *check)
>  	for (i = 0; i < 10; ++i) {
>  		usleep(100000);
>  
> -		if (*(long *)check)
> +		if (*(int *)check)
>  			return 0;
>  	}
>  
> 
> base-commit: 6f874fa021dfc7bf37f4f37da3a5aaa41fe9c39c


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] selftests/user_events: Fix abi_test for BE archs
  2023-10-17 20:38 ` Steven Rostedt
@ 2023-10-17 21:10   ` Shuah Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2023-10-17 21:10 UTC (permalink / raw)
  To: Steven Rostedt, Beau Belgrave
  Cc: shuah, mhiramat, linux-kernel, linux-kselftest,
	linux-trace-kernel, Shuah Khan

On 10/17/23 14:38, Steven Rostedt wrote:
> On Thu,  5 Oct 2023 21:57:12 +0000
> Beau Belgrave <beaub@linux.microsoft.com> wrote:
> 
>> The abi_test currently uses a long sized test value for enablement
>> checks. On LE this works fine, however, on BE this results in inaccurate
>> assert checks due to a bit being used and assuming it's value is the
>> same on both LE and BE.
>>
>> Use int type for 32-bit values and long type for 64-bit values to ensure
>> appropriate behavior on both LE and BE.
>>
>> Fixes: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
>> Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
>> ---
>> V3 Changes:
>> Fix missing cast in clone_check().
>>
>> V2 Changes:
>> Rebase to linux-kselftest/fixes.
> 
> Shuah,
> 
> Can you take this patch?
> 
> Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> 

Thank you both. Applied to linux-kselftest fixes for Linux 6.6-rc7

thanks,
-- Shuah



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-17 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-05 21:57 [PATCH v3] selftests/user_events: Fix abi_test for BE archs Beau Belgrave
2023-10-17 20:38 ` Steven Rostedt
2023-10-17 21:10   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).