daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
b9a53a
From 3cf9361996b796eae0bda12aec8c92ddae1d5d48 Mon Sep 17 00:00:00 2001
b9a53a
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
b9a53a
Date: Tue, 4 Jun 2019 09:40:38 +0200
b9a53a
Subject: [PATCH] test-cpu-set-util: fix allocation size check on i386
b9a53a
b9a53a
We get just 28 bytes not 32 as on 64-bit architectures (__cpu_set_t is 4 bytes,
b9a53a
we need at least 26, so 28 satisfies the constraints).
b9a53a
b9a53a
(cherry picked from commit 64412970ac0d4b6f5c4bbd8816edc9bff9eab2de)
b9a53a
b9a53a
Related: #1734787
b9a53a
---
b9a53a
 src/test/test-cpu-set-util.c | 4 +++-
b9a53a
 1 file changed, 3 insertions(+), 1 deletion(-)
b9a53a
b9a53a
diff --git a/src/test/test-cpu-set-util.c b/src/test/test-cpu-set-util.c
b9a53a
index 3456add989..136eaca82d 100644
b9a53a
--- a/src/test/test-cpu-set-util.c
b9a53a
+++ b/src/test/test-cpu-set-util.c
b9a53a
@@ -256,7 +256,9 @@ static void test_cpu_set_to_from_dbus(void) {
b9a53a
         assert_se(array);
b9a53a
         assert_se(allocated == c.allocated);
b9a53a
 
b9a53a
-        assert(memcmp(array, expected, sizeof expected) == 0);
b9a53a
+        assert_se(allocated <= sizeof expected);
b9a53a
+        assert_se(allocated >= DIV_ROUND_UP(201u, 8u)); /* We need at least 201 bits for our mask */
b9a53a
+        assert(memcmp(array, expected, allocated) == 0);
b9a53a
 
b9a53a
         assert_se(cpu_set_from_dbus(array, allocated, &c2) == 0);
b9a53a
         assert_se(c2.set);