Commit cf5a103c authored by Beau Belgrave's avatar Beau Belgrave Committed by Shuah Khan

selftests/user_events: Fix abi_test for BE archs

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: 60b1af8d ("tracing/user_events: Add ABI self-test")
Signed-off-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
Acked-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 6f874fa0
...@@ -47,7 +47,7 @@ static int change_event(bool enable) ...@@ -47,7 +47,7 @@ static int change_event(bool enable)
return ret; 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}; struct user_reg reg = {0};
int fd = open(data_file, O_RDWR); int fd = open(data_file, O_RDWR);
...@@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit) ...@@ -69,7 +69,7 @@ static int reg_enable(long *enable, int size, int bit)
return ret; return ret;
} }
static int reg_disable(long *enable, int bit) static int reg_disable(void *enable, int bit)
{ {
struct user_unreg reg = {0}; struct user_unreg reg = {0};
int fd = open(data_file, O_RDWR); int fd = open(data_file, O_RDWR);
...@@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit) ...@@ -90,7 +90,8 @@ static int reg_disable(long *enable, int bit)
} }
FIXTURE(user) { FIXTURE(user) {
long check; int check;
long check_long;
bool umount; bool umount;
}; };
...@@ -99,6 +100,7 @@ FIXTURE_SETUP(user) { ...@@ -99,6 +100,7 @@ FIXTURE_SETUP(user) {
change_event(false); change_event(false);
self->check = 0; self->check = 0;
self->check_long = 0;
} }
FIXTURE_TEARDOWN(user) { FIXTURE_TEARDOWN(user) {
...@@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) { ...@@ -136,9 +138,9 @@ TEST_F(user, bit_sizes) {
#if BITS_PER_LONG == 8 #if BITS_PER_LONG == 8
/* Allow 0-64 bits for 64-bit */ /* Allow 0-64 bits for 64-bit */
ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63)); ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63));
ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64)); ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64));
ASSERT_EQ(0, reg_disable(&self->check, 63)); ASSERT_EQ(0, reg_disable(&self->check_long, 63));
#endif #endif
/* Disallowed sizes (everything beside 4 and 8) */ /* Disallowed sizes (everything beside 4 and 8) */
...@@ -200,7 +202,7 @@ static int clone_check(void *check) ...@@ -200,7 +202,7 @@ static int clone_check(void *check)
for (i = 0; i < 10; ++i) { for (i = 0; i < 10; ++i) {
usleep(100000); usleep(100000);
if (*(long *)check) if (*(int *)check)
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment