File util-linux-ipcs-shmall-overflow-ts.patch of Package python3-libmount.26138
From 734678205af89c2022fd1ad86fddd7c07d188f20 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 19 Jan 2021 16:25:33 +0100
Subject: [PATCH] tests: improve u64 use in ipcs test
UINT64_MAX is 18446744073709551615, but 2^64 is 18446744073709551616.
We also need to use kbytes in all calculation in the test than bytes
as ipcs by default do not use bytes anymore.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
tests/helpers/test_sysinfo.c | 9 +++++++++
tests/ts/ipcs/functions.sh | 17 ++++++++++-------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c
index ce7bc081a..e13931d04 100644
--- a/tests/helpers/test_sysinfo.c
+++ b/tests/helpers/test_sysinfo.c
@@ -19,6 +19,8 @@
#include <string.h>
#include <unistd.h>
#include <limits.h>
+#include <stdint.h>
+#include <inttypes.h>
typedef struct {
const char *name;
@@ -72,6 +74,12 @@ static int hlp_ulong_max(void)
return 0;
}
+static int hlp_u64_max(void)
+{
+ printf("%" PRIu64 "\n", UINT64_MAX);
+ return 0;
+}
+
static int hlp_ulong_max32(void)
{
#if __WORDSIZE == 64
@@ -91,6 +99,7 @@ static mntHlpfnc hlps[] =
{ "LONG_MAX", hlp_long_max },
{ "ULONG_MAX", hlp_ulong_max },
{ "ULONG_MAX32",hlp_ulong_max32 },
+ { "UINT64_MAX", hlp_u64_max },
{ "byte-order", hlp_endianness },
{ NULL, NULL }
};
diff --git a/tests/ts/ipcs/functions.sh b/tests/ts/ipcs/functions.sh
index b23e123d9..e9b437ee4 100644
--- a/tests/ts/ipcs/functions.sh
+++ b/tests/ts/ipcs/functions.sh
@@ -63,6 +63,8 @@ IPCS_LIMITS=(
# list of indexes = 0..(sizeof Array - 1)
IPCS_IDX=$(seq 0 $(( ${#IPCS_PROCFILES[*]} - 1 )))
+UINT64_MAX=$($TS_HELPER_SYSINFO UINT64_MAX)
+
# checker
function ipcs_limits_check {
for i in $IPCS_IDX; do
@@ -72,16 +74,17 @@ function ipcs_limits_check {
a=$(eval ${IPCS_KERNEL_CMD[$i]})
b=$(eval ${IPCS_CMD[$i]})
+ # follow the way how ipcs handles u64 overflow
+ max_kbytes=$(bc <<< "$UINT64_MAX - ($UINT64_MAX % ($PAGE_SIZE / 1024))")
+
#echo
- #echo "KERNEL-CMD: ${IPCS_KERNEL_CMD[$i]}"
- #echo "KERNEL-RAW: $(cat ${IPCS_PROCFILES[$i]})"
- #echo "IPCS-CMD: ${IPCS_CMD[$i]}"
+ #echo "kernel kbytes: $a"
+ #echo "lsipc kbytes: $b"
+ #echo "max kbytes: $max_kbytes"
#echo
- # overflow is handled differently because we don't have large
- # int math, see https://github.com/karelzak/util-linux/issues/51
- if [ $(bc <<<"$a >= 2^64/1024") -eq 1 ]; then
- a=$(bc <<<"(2^64 - $PAGE_SIZE)/1024")
+ if [ $(bc <<<"$a > $max_kbytes") -eq 1 ]; then
+ a=$max_kbytes
fi
if [ x"$a" == x"$b" ]; then
--
2.33.0