From 31cd5f63ce86a0784c4ef869c4d323a11ff14adc Mon Sep 17 00:00:00 2001 From: Anita Zhang Date: Fri, 28 Jun 2019 17:02:30 -0700 Subject: core: ExecCondition= for services Closes #10596 --- test/fuzz/fuzz-unit-file/directives.service | 1 + test/meson.build | 2 ++ test/test-execute/exec-condition-failed.service | 11 +++++++++++ test/test-execute/exec-condition-skip.service | 15 +++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 test/test-execute/exec-condition-failed.service create mode 100644 test/test-execute/exec-condition-skip.service (limited to 'test') diff --git a/test/fuzz/fuzz-unit-file/directives.service b/test/fuzz/fuzz-unit-file/directives.service index 8105d23a47..2f59585671 100644 --- a/test/fuzz/fuzz-unit-file/directives.service +++ b/test/fuzz/fuzz-unit-file/directives.service @@ -83,6 +83,7 @@ DirectoryNotEmpty= Documentation= DynamicUser= ExecReload= +ExecCondition= ExecStart= ExecStartPost= ExecStartPre= diff --git a/test/meson.build b/test/meson.build index 8c71e72667..36d9df729c 100644 --- a/test/meson.build +++ b/test/meson.build @@ -56,6 +56,8 @@ test_data_files = ''' test-execute/exec-capabilityboundingset-merge.service test-execute/exec-capabilityboundingset-reset.service test-execute/exec-capabilityboundingset-simple.service + test-execute/exec-condition-failed.service + test-execute/exec-condition-skip.service test-execute/exec-cpuaffinity1.service test-execute/exec-cpuaffinity2.service test-execute/exec-cpuaffinity3.service diff --git a/test/test-execute/exec-condition-failed.service b/test/test-execute/exec-condition-failed.service new file mode 100644 index 0000000000..4a406dc17f --- /dev/null +++ b/test/test-execute/exec-condition-failed.service @@ -0,0 +1,11 @@ +[Unit] +Description=Test for exec condition that fails the unit + +[Service] +Type=oneshot + +# exit 255 will fail the unit +ExecCondition=/bin/sh -c 'exit 255' + +# This should not get run +ExecStart=/bin/sh -c 'true' diff --git a/test/test-execute/exec-condition-skip.service b/test/test-execute/exec-condition-skip.service new file mode 100644 index 0000000000..9450e8442a --- /dev/null +++ b/test/test-execute/exec-condition-skip.service @@ -0,0 +1,15 @@ +[Unit] +Description=Test for exec condition that triggers skipping + +[Service] +Type=oneshot + +# exit codes [1, 254] will result in skipping the rest of execution +ExecCondition=/bin/sh -c 'exit 0' +ExecCondition=/bin/sh -c 'exit 254' + +# This would normally fail the unit but will not get run due to the skip above +ExecCondition=/bin/sh -c 'exit 255' + +# This should not get run +ExecStart=/bin/sh -c 'true' -- cgit v1.2.1