Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 60b1af8de8c1 ("tracing/user_events: Add ABI self-test")
Signed-off-by: Beau Belgrave <beaub@linux.microsoft.com>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Beau Belgrave and committed by
Shuah Khan
cf5a103c 6f874fa0

+9 -7
+9 -7
tools/testing/selftests/user_events/abi_test.c
··· 47 47 return ret; 48 48 } 49 49 50 - static int reg_enable(long *enable, int size, int bit) 50 + static int reg_enable(void *enable, int size, int bit) 51 51 { 52 52 struct user_reg reg = {0}; 53 53 int fd = open(data_file, O_RDWR); ··· 69 69 return ret; 70 70 } 71 71 72 - static int reg_disable(long *enable, int bit) 72 + static int reg_disable(void *enable, int bit) 73 73 { 74 74 struct user_unreg reg = {0}; 75 75 int fd = open(data_file, O_RDWR); ··· 90 90 } 91 91 92 92 FIXTURE(user) { 93 - long check; 93 + int check; 94 + long check_long; 94 95 bool umount; 95 96 }; 96 97 ··· 100 99 101 100 change_event(false); 102 101 self->check = 0; 102 + self->check_long = 0; 103 103 } 104 104 105 105 FIXTURE_TEARDOWN(user) { ··· 138 136 139 137 #if BITS_PER_LONG == 8 140 138 /* Allow 0-64 bits for 64-bit */ 141 - ASSERT_EQ(0, reg_enable(&self->check, sizeof(long), 63)); 142 - ASSERT_NE(0, reg_enable(&self->check, sizeof(long), 64)); 143 - ASSERT_EQ(0, reg_disable(&self->check, 63)); 139 + ASSERT_EQ(0, reg_enable(&self->check_long, sizeof(long), 63)); 140 + ASSERT_NE(0, reg_enable(&self->check_long, sizeof(long), 64)); 141 + ASSERT_EQ(0, reg_disable(&self->check_long, 63)); 144 142 #endif 145 143 146 144 /* Disallowed sizes (everything beside 4 and 8) */ ··· 202 200 for (i = 0; i < 10; ++i) { 203 201 usleep(100000); 204 202 205 - if (*(long *)check) 203 + if (*(int *)check) 206 204 return 0; 207 205 } 208 206