dryang / rpms / systemd

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