summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorFilipe Brandenburger <filbranden@google.com>2015-09-25 04:45:22 -0700
committerFilipe Brandenburger <filbranden@google.com>2015-10-27 17:39:58 -0700
commit4fc66acb93d6f0002263e2dfaefa46e272ae0c9c (patch)
tree2abd6cf5439be33c6047616ab4948ce3f1b507d9 /src/test
parentdc1e811ebd80d1659d1476c4ae733d212d6aa946 (diff)
cpu-set-util: Accept commas as separators in parse_cpu_set_and_warn
Tested CPUAffinity settings on both a service unit and in system.conf and confirmed they work as expected. Added a new test to confirm that trailing commas and spaces work and to prevent any regressions in that area.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-util.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index ffde10c7e1..b0eb77592e 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1012,8 +1012,21 @@ static void test_parse_cpu_set(void) {
/* Use commas as separators */
ncpus = parse_cpu_set_and_warn("0,1,2,3 8,9,10,11", &c, NULL, "fake", 1, "CPUAffinity");
- assert_se(ncpus < 0);
- assert_se(!c);
+ assert_se(ncpus >= 1024);
+ assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 8);
+ for (cpu = 0; cpu < 4; cpu++)
+ assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
+ for (cpu = 8; cpu < 12; cpu++)
+ assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
+ c = mfree(c);
+
+ /* Commas with spaces (and trailing comma, space) */
+ ncpus = parse_cpu_set_and_warn("0, 1, 2, 3, 4, 5, 6, 7, ", &c, NULL, "fake", 1, "CPUAffinity");
+ assert_se(ncpus >= 1024);
+ assert_se(CPU_COUNT_S(CPU_ALLOC_SIZE(ncpus), c) == 8);
+ for (cpu = 0; cpu < 8; cpu++)
+ assert_se(CPU_ISSET_S(cpu, CPU_ALLOC_SIZE(ncpus), c));
+ c = mfree(c);
/* Ranges */
ncpus = parse_cpu_set_and_warn("0-3,8-11", &c, NULL, "fake", 1, "CPUAffinity");