summaryrefslogtreecommitdiffstats
path: root/test/test-execute
diff options
context:
space:
mode:
authoralexlzhu <alexlzhu@devvm2387.atn0.facebook.com>2021-07-09 02:10:47 +0200
committerChris Down <chris@chrisdown.name>2021-09-28 15:52:27 +0200
commit8c35c10d20ff7b369bfff3fbbb92a43ca2fd5938 (patch)
treebe87626fe62937be49a7b3388d75d44623ed2c5d /test/test-execute
parentMerge pull request #20837 from bluca/coveralls (diff)
downloadsystemd-8c35c10d20ff7b369bfff3fbbb92a43ca2fd5938.tar.xz
systemd-8c35c10d20ff7b369bfff3fbbb92a43ca2fd5938.zip
core: Add ExecSearchPath parameter to specify the directory relative to which binaries executed by Exec*= should be found
Currently there does not exist a way to specify a path relative to which all binaries executed by Exec should be found. The only way is to specify the absolute path. This change implements the functionality to specify a path relative to which binaries executed by Exec*= can be found. Closes #6308
Diffstat (limited to 'test/test-execute')
-rw-r--r--test/test-execute/exec-execsearchpath-environment-path-set.service5
-rw-r--r--test/test-execute/exec-execsearchpath-environment.service5
-rw-r--r--test/test-execute/exec-execsearchpath-environmentfile-set.service8
-rw-r--r--test/test-execute/exec-execsearchpath-environmentfile.service8
-rw-r--r--test/test-execute/exec-execsearchpath-passenvironment-set.service8
-rw-r--r--test/test-execute/exec-execsearchpath-passenvironment.service8
-rw-r--r--test/test-execute/exec-execsearchpath-unit-specifier.service7
-rw-r--r--test/test-execute/exec-execsearchpath.service4
8 files changed, 53 insertions, 0 deletions
diff --git a/test/test-execute/exec-execsearchpath-environment-path-set.service b/test/test-execute/exec-execsearchpath-environment-path-set.service
new file mode 100644
index 0000000000..dd27de84a8
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-environment-path-set.service
@@ -0,0 +1,5 @@
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$PATH" = "/usr" && test "$$VAR1" = word3 && test "$$VAR2" = "\\$$word 5 6"'
+Type=oneshot
+ExecSearchPath=/tmp:/bin
+Environment="PATH=/usr" VAR1=word3 "VAR2=$word 5 6"
diff --git a/test/test-execute/exec-execsearchpath-environment.service b/test/test-execute/exec-execsearchpath-environment.service
new file mode 100644
index 0000000000..ba477fbdcd
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-environment.service
@@ -0,0 +1,5 @@
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6" && test "$$PATH" = "/tmp:/bin"'
+Type=oneshot
+ExecSearchPath=/tmp:/bin
+Environment="VAR1=word1 word2" VAR2=word3 "VAR3=$word 5 6"
diff --git a/test/test-execute/exec-execsearchpath-environmentfile-set.service b/test/test-execute/exec-execsearchpath-environmentfile-set.service
new file mode 100644
index 0000000000..45877b1d12
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-environmentfile-set.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Test for ExecSearchPath with EnvironmentFile where EnvironmentFile sets PATH
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6" && test "$$VAR4" = "new\nline" && test "$$VAR5" = passwordwithbackslashes && test "$$PATH" = /usr'
+Type=oneshot
+EnvironmentFile=/tmp/test-exec_execsearchpath_environmentfile-set.conf
+ExecSearchPath=/tmp:/bin
diff --git a/test/test-execute/exec-execsearchpath-environmentfile.service b/test/test-execute/exec-execsearchpath-environmentfile.service
new file mode 100644
index 0000000000..65a04e7dbe
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-environmentfile.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Test for ExecSearchPath with EnvironmentFile where EnvironmentFile does not set PATH
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6" && test "$$VAR4" = "new\nline" && test "$$VAR5" = passwordwithbackslashes && test "$$PATH" = "/tmp:/bin"'
+Type=oneshot
+ExecSearchPath=/tmp:/bin
+EnvironmentFile=/tmp/test-exec_execsearchpath_environmentfile.conf
diff --git a/test/test-execute/exec-execsearchpath-passenvironment-set.service b/test/test-execute/exec-execsearchpath-passenvironment-set.service
new file mode 100644
index 0000000000..62c7742b10
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-passenvironment-set.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Test for PassEnvironment with ExecSearchPath with PATH set by user
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6" && test "$$VAR4" = "new\nline" && test "$$VAR5" = passwordwithbackslashes && test "$$PATH" = "/usr"'
+Type=oneshot
+PassEnvironment=VAR1 VAR2 VAR3 VAR4 VAR5 PATH
+ExecSearchPath=/tmp:/bin
diff --git a/test/test-execute/exec-execsearchpath-passenvironment.service b/test/test-execute/exec-execsearchpath-passenvironment.service
new file mode 100644
index 0000000000..83eb0d680a
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-passenvironment.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Test for PassEnvironment with ExecSearchPath with PATH not set by user
+
+[Service]
+ExecStart=/bin/sh -x -c 'test "$$VAR1" = "word1 word2" && test "$$VAR2" = word3 && test "$$VAR3" = "\\$$word 5 6" && test "$$VAR4" = "new\nline" && test "$$VAR5" = passwordwithbackslashes && test "$$PATH" = "/tmp:/bin"'
+Type=oneshot
+PassEnvironment=VAR1 VAR2 VAR3 VAR4 VAR5
+ExecSearchPath=/tmp:/bin
diff --git a/test/test-execute/exec-execsearchpath-unit-specifier.service b/test/test-execute/exec-execsearchpath-unit-specifier.service
new file mode 100644
index 0000000000..740bab1d41
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath-unit-specifier.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Test for specifiers with exec search path
+
+[Service]
+Type=oneshot
+ExecSearchPath=/tmp:/bin:/usr/bin:%V
+ExecStart=/bin/sh -x -c 'test %V = /var/tmp && test "$$PATH" = "/tmp:/bin:/usr/bin:/var/tmp"'
diff --git a/test/test-execute/exec-execsearchpath.service b/test/test-execute/exec-execsearchpath.service
new file mode 100644
index 0000000000..67b71709f3
--- /dev/null
+++ b/test/test-execute/exec-execsearchpath.service
@@ -0,0 +1,4 @@
+[Service]
+ExecStart=ls_temp
+Type=oneshot
+ExecSearchPath=/tmp/test-exec_execsearchpath