[LTP] [PATCH v2] acct: fix version check on big endian system

Ping Fang pifang@redhat.com
Thu Oct 10 10:17:52 CEST 2019


ac_version = ACCT_VERION | ACCT_BYTEORDER
which is 0x83 (131) on big endian system.

failure output:
tst_kconfig.c:62: INFO: Parsing kernel config
'/boot/config-4.18.0-147.el8.s390x'
tst_test.c:1118: INFO: Timeout per run is 0h 05m 00s
tst_kconfig.c:62: INFO: Parsing kernel config
'/boot/config-4.18.0-147.el8.s390x'
acct02.c:239: INFO: Verifying using 'struct acct_v3'
acct02.c:192: INFO: == entry 1 ==
acct02.c:147: INFO: ac_version != 3 (131)
acct02.c:192: INFO: == entry 2 ==
acct02.c:82: INFO: ac_comm != 'acct02_helper' ('acct02')
acct02.c:133: INFO: ac_exitcode != 32768 (0)
acct02.c:141: INFO: ac_ppid != 34501 (34500)
acct02.c:147: INFO: ac_version != 3 (131)
acct02.c:182: FAIL: end of file reached

Signed-off-by: Ping Fang <pifang@redhat.com>
---
 include/lapi/acct.h                     | 5 +++++
 testcases/kernel/syscalls/acct/acct02.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/lapi/acct.h b/include/lapi/acct.h
index ebd65bbf4..c81b78b44 100644
--- a/include/lapi/acct.h
+++ b/include/lapi/acct.h
@@ -64,6 +64,11 @@ enum {
 	ACORE = 0x08,
 	AXSIG = 0x10
 };
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define ACCT_BYTEORDER  0x80
+# elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define ACCT_BYTEORDER  0x00
+# endif
 #endif /* HAVE_STRUCT_ACCT_V3 */
 
 #endif /* LAPI_ACCT_H */
diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index 7c2a27046..4d95aafec 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -142,7 +142,7 @@ static int verify_acct(void *acc, int elap_time)
 		ret = 1;
 	}
 
-	if (ACCT_MEMBER_V3(ac_version) != 3) {
+	if (ACCT_MEMBER_V3(ac_version) != (3 | ACCT_BYTEORDER)) {
 		tst_res(TINFO, "ac_version != 3 (%d)",
 			ACCT_MEMBER_V3(ac_version));
 		ret = 1;
-- 
2.21.0



More information about the ltp mailing list