]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-execute: let's ignore the difference between CLD_KILLED and CLD_DUMPED
authorLennart Poettering <lennart@poettering.net>
Mon, 29 Apr 2019 10:58:55 +0000 (12:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 May 2019 08:48:28 +0000 (10:48 +0200)
Depending on system configuration and whether SCMP_ACT_KILL_PROCESS or
SCMP_ACT_KILL_THREAD is available/used processes might coredump on
specific coredumps or are just plain killed. For our test case the
difference doesn't really matter, hence let's hide it away.

src/test/test-execute.c

index a27de296a4dfe7359ccb0b07ef96862eab28c437..7f8ea2be986209ea44a2b5c4ef1b1be93dfa3a06 100644 (file)
@@ -33,6 +33,12 @@ static bool can_unshare;
 
 typedef void (*test_function_t)(Manager *m);
 
+static int cld_dumped_to_killed(int code) {
+        /* Depending on the system, seccomp version, … some signals might result in dumping, others in plain
+         * killing. Let's ignore the difference here, and map both cases to CLD_KILLED */
+        return code == CLD_DUMPED ? CLD_KILLED : code;
+}
+
 static void check(const char *func, Manager *m, Unit *unit, int status_expected, int code_expected) {
         Service *service = NULL;
         usec_t ts;
@@ -63,7 +69,7 @@ static void check(const char *func, Manager *m, Unit *unit, int status_expected,
         }
         exec_status_dump(&service->main_exec_status, stdout, "\t");
 
-        if (service->main_exec_status.code != code_expected) {
+        if (cld_dumped_to_killed(service->main_exec_status.code) != cld_dumped_to_killed(code_expected)) {
                 log_error("%s: %s: exit code %d, expected %d",
                           func, unit->id,
                           service->main_exec_status.code, code_expected);