summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-04 12:01:20 +0200
committerGitHub <noreply@github.com>2019-06-04 12:01:20 +0200
commit33f724f42773434bc6601f08b3d6d88524dcd4bf (patch)
tree1b48e648f731051b364e19e6dbcccfd5a15f4962 /src
parentca866a32fb577cac86dd76bd93d5ffb8421ba08e (diff)
parent64412970ac0d4b6f5c4bbd8816edc9bff9eab2de (diff)
downloadsystemd-33f724f42773434bc6601f08b3d6d88524dcd4bf.tar.gz
systemd-33f724f42773434bc6601f08b3d6d88524dcd4bf.tar.bz2
systemd-33f724f42773434bc6601f08b3d6d88524dcd4bf.zip
Merge pull request #12734 from keszybz/cpu-set-util-on-i386
Fixes for test-cpu-set-util on i386
Diffstat (limited to 'src')
-rw-r--r--src/shared/generator.c2
-rw-r--r--src/test/test-cpu-set-util.c26
2 files changed, 15 insertions, 13 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 403c2a6737..0a5413ce04 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -158,7 +158,7 @@ int generator_write_fsck_deps(
lnk = strjoina(dir, "/" SPECIAL_LOCAL_FS_TARGET ".wants/"SPECIAL_FSCK_ROOT_SERVICE);
- mkdir_parents(lnk, 0755);
+ (void) mkdir_parents(lnk, 0755);
if (symlink(SYSTEM_DATA_UNIT_PATH "/"SPECIAL_FSCK_ROOT_SERVICE, lnk) < 0)
return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
diff --git a/src/test/test-cpu-set-util.c b/src/test/test-cpu-set-util.c
index 90f5755957..e1dd2eb32b 100644
--- a/src/test/test-cpu-set-util.c
+++ b/src/test/test-cpu-set-util.c
@@ -15,7 +15,7 @@ static void test_parse_cpu_set(void) {
/* Single value */
assert_se(parse_cpu_set_full("0", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
assert_se(c.set);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_ISSET_S(0, c.allocated, c.set));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 1);
@@ -31,7 +31,7 @@ static void test_parse_cpu_set(void) {
/* Simple range (from CPUAffinity example) */
assert_se(parse_cpu_set_full("1 2 4", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
assert_se(c.set);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_ISSET_S(1, c.allocated, c.set));
assert_se(CPU_ISSET_S(2, c.allocated, c.set));
assert_se(CPU_ISSET_S(4, c.allocated, c.set));
@@ -48,7 +48,7 @@ static void test_parse_cpu_set(void) {
/* A more interesting range */
assert_se(parse_cpu_set_full("0 1 2 3 8 9 10 11", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 8);
for (cpu = 0; cpu < 4; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -66,7 +66,7 @@ static void test_parse_cpu_set(void) {
/* Quoted strings */
assert_se(parse_cpu_set_full("8 '9' 10 \"11\"", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 4);
for (cpu = 8; cpu < 12; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -81,7 +81,7 @@ static void test_parse_cpu_set(void) {
/* Use commas as separators */
assert_se(parse_cpu_set_full("0,1,2,3 8,9,10,11", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 8);
for (cpu = 0; cpu < 4; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -94,7 +94,7 @@ static void test_parse_cpu_set(void) {
/* Commas with spaces (and trailing comma, space) */
assert_se(parse_cpu_set_full("0, 1, 2, 3, 4, 5, 6, 7, 63, ", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 9);
for (cpu = 0; cpu < 8; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -111,7 +111,7 @@ static void test_parse_cpu_set(void) {
/* Ranges */
assert_se(parse_cpu_set_full("0-3,8-11", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 8);
for (cpu = 0; cpu < 4; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -124,7 +124,7 @@ static void test_parse_cpu_set(void) {
/* Ranges with trailing comma, space */
assert_se(parse_cpu_set_full("0-3 8-11, ", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 8);
for (cpu = 0; cpu < 4; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -141,13 +141,13 @@ static void test_parse_cpu_set(void) {
/* Negative range (returns empty cpu_set) */
assert_se(parse_cpu_set_full("3-0", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 0);
cpu_set_reset(&c);
/* Overlapping ranges */
assert_se(parse_cpu_set_full("0-7 4-11", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 12);
for (cpu = 0; cpu < 12; cpu++)
assert_se(CPU_ISSET_S(cpu, c.allocated, c.set));
@@ -162,7 +162,7 @@ static void test_parse_cpu_set(void) {
/* Mix ranges and individual CPUs */
assert_se(parse_cpu_set_full("0,2 4-11", &c, true, NULL, "fake", 1, "CPUAffinity") >= 0);
- assert_se(c.allocated >= sizeof(__cpu_mask) / 8);
+ assert_se(c.allocated >= DIV_ROUND_UP(sizeof(__cpu_mask), 8));
assert_se(CPU_COUNT_S(c.allocated, c.set) == 10);
assert_se(CPU_ISSET_S(0, c.allocated, c.set));
assert_se(CPU_ISSET_S(2, c.allocated, c.set));
@@ -254,7 +254,9 @@ static void test_cpu_set_to_from_dbus(void) {
assert_se(array);
assert_se(allocated == c.allocated);
- assert(memcmp(array, expected, sizeof expected) == 0);
+ assert_se(allocated <= sizeof expected);
+ assert_se(allocated >= DIV_ROUND_UP(201u, 8u)); /* We need at least 201 bits for our mask */
+ assert(memcmp(array, expected, allocated) == 0);
assert_se(cpu_set_from_dbus(array, allocated, &c2) == 0);
assert_se(c2.set);