984f77
From 5226df888c28ede9219d7f018af02cca1d1f6d2a Mon Sep 17 00:00:00 2001
984f77
From: Yu Watanabe <watanabe.yu+github@gmail.com>
984f77
Date: Tue, 11 Sep 2018 14:07:53 +0900
984f77
Subject: [PATCH] test-execute: add tests for $RUNTIME_DIRECTORY= or friends
984f77
984f77
(cherry picked from commit 6088662d57bbd81167bd272d385fdd1044b287ec)
984f77
984f77
Related: #2049788
984f77
---
984f77
 .../test-execute/exec-dynamicuser-statedir-migrate-step1.service | 1 +
984f77
 .../test-execute/exec-dynamicuser-statedir-migrate-step2.service | 1 +
984f77
 test/test-execute/exec-dynamicuser-statedir.service              | 1 +
984f77
 test/test-execute/exec-runtimedirectory-mode.service             | 1 +
984f77
 test/test-execute/exec-runtimedirectory.service                  | 1 +
984f77
 5 files changed, 5 insertions(+)
984f77
984f77
diff --git a/test/test-execute/exec-dynamicuser-statedir-migrate-step1.service b/test/test-execute/exec-dynamicuser-statedir-migrate-step1.service
984f77
index 72e6d7686f..5efc5483b8 100644
984f77
--- a/test/test-execute/exec-dynamicuser-statedir-migrate-step1.service
984f77
+++ b/test/test-execute/exec-dynamicuser-statedir-migrate-step1.service
984f77
@@ -10,6 +10,7 @@ ExecStart=test -d /var/lib/test-dynamicuser-migrate
984f77
 ExecStart=test -d /var/lib/test-dynamicuser-migrate2/hoge
984f77
 ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
984f77
 ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
984f77
+ExecStart=/bin/sh -x -c 'test "$$STATE_DIRECTORY" = "%S/test-dynamicuser-migrate:%S/test-dynamicuser-migrate2/hoge"'
984f77
 
984f77
 Type=oneshot
984f77
 DynamicUser=no
984f77
diff --git a/test/test-execute/exec-dynamicuser-statedir-migrate-step2.service b/test/test-execute/exec-dynamicuser-statedir-migrate-step2.service
984f77
index edb0be7ef8..c72302ffd5 100644
984f77
--- a/test/test-execute/exec-dynamicuser-statedir-migrate-step2.service
984f77
+++ b/test/test-execute/exec-dynamicuser-statedir-migrate-step2.service
984f77
@@ -18,6 +18,7 @@ ExecStart=touch /var/lib/test-dynamicuser-migrate/yay
984f77
 ExecStart=touch /var/lib/test-dynamicuser-migrate2/hoge/yayyay
984f77
 ExecStart=touch /var/lib/private/test-dynamicuser-migrate/yay
984f77
 ExecStart=touch /var/lib/private/test-dynamicuser-migrate2/hoge/yayyay
984f77
+ExecStart=/bin/sh -x -c 'test "$$STATE_DIRECTORY" = "%S/test-dynamicuser-migrate:%S/test-dynamicuser-migrate2/hoge"'
984f77
 
984f77
 Type=oneshot
984f77
 DynamicUser=yes
984f77
diff --git a/test/test-execute/exec-dynamicuser-statedir.service b/test/test-execute/exec-dynamicuser-statedir.service
984f77
index f459f3c1eb..2fb7b8660b 100644
984f77
--- a/test/test-execute/exec-dynamicuser-statedir.service
984f77
+++ b/test/test-execute/exec-dynamicuser-statedir.service
984f77
@@ -10,6 +10,7 @@ ExecStart=test -f /var/lib/waldo/yay
984f77
 ExecStart=test -f /var/lib/quux/pief/yayyay
984f77
 ExecStart=test -f /var/lib/private/waldo/yay
984f77
 ExecStart=test -f /var/lib/private/quux/pief/yayyay
984f77
+ExecStart=/bin/sh -x -c 'test "$$STATE_DIRECTORY" = "%S/waldo:%S/quux/pief"'
984f77
 
984f77
 # Make sure that /var/lib/private/waldo is really the only writable directory besides the obvious candidates
984f77
 ExecStart=sh -x -c 'test $$(find / \( -path /var/tmp -o -path /tmp -o -path /proc -o -path /dev/mqueue -o -path /dev/shm -o -path /sys/fs/bpf \) -prune -o -type d -writable -print 2>/dev/null | sort -u | tr -d '\\\\n') = /var/lib/private/quux/pief/var/lib/private/waldo'
984f77
diff --git a/test/test-execute/exec-runtimedirectory-mode.service b/test/test-execute/exec-runtimedirectory-mode.service
984f77
index 480f904155..85ae5161c4 100644
984f77
--- a/test/test-execute/exec-runtimedirectory-mode.service
984f77
+++ b/test/test-execute/exec-runtimedirectory-mode.service
984f77
@@ -3,6 +3,7 @@ Description=Test for RuntimeDirectoryMode
984f77
 
984f77
 [Service]
984f77
 ExecStart=/bin/sh -x -c 'mode=$$(stat -c %%a %t/test-exec_runtimedirectory-mode); test "$$mode" = "750"'
984f77
+ExecStart=/bin/sh -x -c 'test "$$RUNTIME_DIRECTORY" = "%t/test-exec_runtimedirectory-mode"'
984f77
 Type=oneshot
984f77
 RuntimeDirectory=test-exec_runtimedirectory-mode
984f77
 RuntimeDirectoryMode=0750
984f77
diff --git a/test/test-execute/exec-runtimedirectory.service b/test/test-execute/exec-runtimedirectory.service
984f77
index 6a4383110f..a33044d23c 100644
984f77
--- a/test/test-execute/exec-runtimedirectory.service
984f77
+++ b/test/test-execute/exec-runtimedirectory.service
984f77
@@ -4,6 +4,7 @@ Description=Test for RuntimeDirectory
984f77
 [Service]
984f77
 ExecStart=/bin/sh -x -c 'test -d %t/test-exec_runtimedirectory'
984f77
 ExecStart=/bin/sh -x -c 'test -d %t/test-exec_runtimedirectory2/hogehoge'
984f77
+ExecStart=/bin/sh -x -c 'test "$$RUNTIME_DIRECTORY" = "%t/test-exec_runtimedirectory:%t/test-exec_runtimedirectory2/hogehoge"'
984f77
 Type=oneshot
984f77
 RuntimeDirectory=test-exec_runtimedirectory
984f77
 RuntimeDirectory=./test-exec_runtimedirectory2///./hogehoge/.