From c388dfea5a9de5771283fbf0f5ebc5a45c895b79 Mon Sep 17 00:00:00 2001 From: Ronny Chevalier Date: Fri, 30 Oct 2015 17:09:22 +0100 Subject: [PATCH] test-execute: add tests for OOMScoreAdjust --- Makefile.am | 2 ++ src/test/test-execute.c | 6 ++++++ test/exec-oomscoreadjust-negative.service | 7 +++++++ test/exec-oomscoreadjust-positive.service | 7 +++++++ 4 files changed, 22 insertions(+) create mode 100644 test/exec-oomscoreadjust-negative.service create mode 100644 test/exec-oomscoreadjust-positive.service diff --git a/Makefile.am b/Makefile.am index 64c0ca6..e2e3bca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1568,6 +1568,8 @@ EXTRA_DIST += \ test/exec-umask-default.service \ test/exec-privatenetwork-yes.service \ test/exec-environmentfile.service \ + test/exec-oomscoreadjust-positive.service \ + test/exec-oomscoreadjust-negative.service \ test/bus-policy/hello.conf \ test/bus-policy/methods.conf \ test/bus-policy/ownerships.conf \ diff --git a/src/test/test-execute.c b/src/test/test-execute.c index 5898b3f..d708878 100644 --- a/src/test/test-execute.c +++ b/src/test/test-execute.c @@ -211,6 +211,11 @@ static void test_exec_privatenetwork(Manager *m) { test(m, "exec-privatenetwork-yes.service", 0, CLD_EXITED); } +static void test_exec_oomscoreadjust(Manager *m) { + test(m, "exec-oomscoreadjust-positive.service", 0, CLD_EXITED); + test(m, "exec-oomscoreadjust-negative.service", 0, CLD_EXITED); +} + int main(int argc, char *argv[]) { test_function_t tests[] = { test_exec_workingdirectory, @@ -228,6 +233,7 @@ int main(int argc, char *argv[]) { test_exec_umask, test_exec_runtimedirectory, test_exec_capabilityboundingset, + test_exec_oomscoreadjust, NULL, }; test_function_t *test = NULL; diff --git a/test/exec-oomscoreadjust-negative.service b/test/exec-oomscoreadjust-negative.service new file mode 100644 index 0000000..63ab501 --- /dev/null +++ b/test/exec-oomscoreadjust-negative.service @@ -0,0 +1,7 @@ +[Unit] +Description=Test for OOMScoreAdjust + +[Service] +ExecStart=/bin/bash -c 'c=$(cat /proc/self/oom_score_adj); echo $c; exit $(test $c -eq -100)' +OOMScoreAdjust=-100 +Type=oneshot diff --git a/test/exec-oomscoreadjust-positive.service b/test/exec-oomscoreadjust-positive.service new file mode 100644 index 0000000..e47a4f1 --- /dev/null +++ b/test/exec-oomscoreadjust-positive.service @@ -0,0 +1,7 @@ +[Unit] +Description=Test for OOMScoreAdjust + +[Service] +ExecStart=/bin/bash -c 'c=$(cat /proc/self/oom_score_adj); echo $c; exit $(test $c -eq 100)' +OOMScoreAdjust=100 +Type=oneshot -- 2.7.4