summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-28 21:38:41 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-05-29 10:29:28 +0200
commit167a776dbe9d033523bd6881e5a695f2155dc321 (patch)
tree34cdc15be5e1ff66c745a2aafb47bdd1f9cfff84 /src/test
parentfb39af4ce42d7ef9af63009f271f404038703704 (diff)
downloadsystemd-167a776dbe9d033523bd6881e5a695f2155dc321.tar.gz
test-execute: use CPUSet too
cpu_set_malloc() was the last user. It doesn't seem useful to keep it just to save the allocation of a few hundred bytes in a test, so it is dropped and a fixed maximum is allocated (1024 bytes).
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-execute.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 9f1cb0ca38..4a2f546827 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -179,13 +179,12 @@ static void test_exec_bindpaths(Manager *m) {
}
static void test_exec_cpuaffinity(Manager *m) {
- _cleanup_cpu_free_ cpu_set_t *c = NULL;
- unsigned n;
+ _cleanup_(cpu_set_reset) CPUSet c = {};
- assert_se(c = cpu_set_malloc(&n));
- assert_se(sched_getaffinity(0, CPU_ALLOC_SIZE(n), c) >= 0);
+ assert_se(cpu_set_realloc(&c, 8192) >= 0); /* just allocate the maximum possible size */
+ assert_se(sched_getaffinity(0, c.allocated, c.set) >= 0);
- if (CPU_ISSET_S(0, CPU_ALLOC_SIZE(n), c) == 0) {
+ if (!CPU_ISSET_S(0, c.allocated, c.set)) {
log_notice("Cannot use CPU 0, skipping %s", __func__);
return;
}
@@ -193,8 +192,8 @@ static void test_exec_cpuaffinity(Manager *m) {
test(__func__, m, "exec-cpuaffinity1.service", 0, CLD_EXITED);
test(__func__, m, "exec-cpuaffinity2.service", 0, CLD_EXITED);
- if (CPU_ISSET_S(1, CPU_ALLOC_SIZE(n), c) == 0 ||
- CPU_ISSET_S(2, CPU_ALLOC_SIZE(n), c) == 0) {
+ if (!CPU_ISSET_S(1, c.allocated, c.set) ||
+ !CPU_ISSET_S(2, c.allocated, c.set)) {
log_notice("Cannot use CPU 1 or 2, skipping remaining tests in %s", __func__);
return;
}