1# SPDX-License-Identifier: LGPL-2.1-or-later
2[Unit]
3Description=Test for TemporaryFileSystem with read-only mode
4
5[Service]
6Type=oneshot
7
8# Check directories exist
9ExecStart=/bin/sh -c 'test -d /var/test-exec-temporaryfilesystem/rw && test -d /var/test-exec-temporaryfilesystem/ro'
10
11# Check TemporaryFileSystem= are empty
12ExecStart=/bin/sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
13
14# Check default mode
15ExecStart=sh -x -c 'test "$$(stat -c %%a /var)" = "755"'
16
17# Cannot create a file in /var
18ExecStart=/bin/sh -c '! touch /var/hoge'
19
20# Create a file in /var/test-exec-temporaryfilesystem/rw
21ExecStart=/bin/sh -c 'touch /var/test-exec-temporaryfilesystem/rw/thisisasimpletest-temporaryfilesystem'
22
23# Then, the file can be access through /tmp
24ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest-temporaryfilesystem'
25
26# Also, through /var/test-exec-temporaryfilesystem/ro
27ExecStart=/bin/sh -c 'test -f /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
28
29# The file cannot modify through /var/test-exec-temporaryfilesystem/ro
30ExecStart=/bin/sh -c '! touch /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
31
32# Cleanup
33ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest-temporaryfilesystem'
34
35TemporaryFileSystem=/var:ro
36BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
37BindReadOnlyPaths=/tmp:/var/test-exec-temporaryfilesystem/ro
38