mirror of
https://github.com/systemd/systemd.git
synced 2025-11-26 16:25:44 +03:00
test: add tests for TemporaryFileSystem=
This commit is contained in:
11
test/test-execute/exec-temporaryfilesystem-options.service
Normal file
11
test/test-execute/exec-temporaryfilesystem-options.service
Normal file
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=Test for TemporaryFileSystem with mount options
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
# Check /proc/self/mountinfo
|
||||
ExecStart=/bin/sh -c 'test $$(awk \'$$5 == "/var" { print $$6 }\' /proc/self/mountinfo) = "ro,nodev,relatime"'
|
||||
ExecStart=/bin/sh -c 'test $$(awk \'$$5 == "/var" { print $$11 }\' /proc/self/mountinfo) = "ro,mode=700"'
|
||||
|
||||
TemporaryFileSystem=/var:ro,mode=0700,nostrictatime
|
||||
33
test/test-execute/exec-temporaryfilesystem-ro.service
Normal file
33
test/test-execute/exec-temporaryfilesystem-ro.service
Normal file
@@ -0,0 +1,33 @@
|
||||
[Unit]
|
||||
Description=Test for TemporaryFileSystem with read-only mode
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
# Check directories exist
|
||||
ExecStart=/bin/sh -c 'test -d /var/test-exec-temporaryfilesystem/rw && test -d /var/test-exec-temporaryfilesystem/ro'
|
||||
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=/bin/sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
|
||||
# Cannot create a file in /var
|
||||
ExecStart=/bin/sh -c '! touch /var/hoge'
|
||||
|
||||
# Create a file in /var/test-exec-temporaryfilesystem/rw
|
||||
ExecStart=/bin/sh -c 'touch /var/test-exec-temporaryfilesystem/rw/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Then, the file can be access through /tmp
|
||||
ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Also, through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c 'test -f /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# The file cannot modify through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c '! touch /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Cleanup
|
||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
TemporaryFileSystem=/var:ro
|
||||
BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
|
||||
BindReadOnlyPaths=/tmp:/var/test-exec-temporaryfilesystem/ro
|
||||
33
test/test-execute/exec-temporaryfilesystem-rw.service
Normal file
33
test/test-execute/exec-temporaryfilesystem-rw.service
Normal file
@@ -0,0 +1,33 @@
|
||||
[Unit]
|
||||
Description=Test for TemporaryFileSystem
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
# Check directories exist
|
||||
ExecStart=/bin/sh -c 'test -d /var/test-exec-temporaryfilesystem/rw && test -d /var/test-exec-temporaryfilesystem/ro'
|
||||
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=/bin/sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
|
||||
# Create a file in /var
|
||||
ExecStart=/bin/sh -c 'touch /var/hoge'
|
||||
|
||||
# Create a file in /var/test-exec-temporaryfilesystem/rw
|
||||
ExecStart=/bin/sh -c 'touch /var/test-exec-temporaryfilesystem/rw/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Then, the file can be access through /tmp
|
||||
ExecStart=/bin/sh -c 'test -f /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Also, through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c 'test -f /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# The file cannot modify through /var/test-exec-temporaryfilesystem/ro
|
||||
ExecStart=/bin/sh -c '! touch /var/test-exec-temporaryfilesystem/ro/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
# Cleanup
|
||||
ExecStart=/bin/sh -c 'rm /tmp/thisisasimpletest-temporaryfilesystem'
|
||||
|
||||
TemporaryFileSystem=/var
|
||||
BindPaths=/tmp:/var/test-exec-temporaryfilesystem/rw
|
||||
BindReadOnlyPaths=/tmp:/var/test-exec-temporaryfilesystem/ro
|
||||
15
test/test-execute/exec-temporaryfilesystem-usr.service
Normal file
15
test/test-execute/exec-temporaryfilesystem-usr.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Test for TemporaryFileSystem on /usr
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=/bin/sh -c 'for i in $$(ls -A /usr); do test $$i = lib -o $$i = lib64 -o $$i = bin -o $$i = sbin || false; done'
|
||||
|
||||
# Cannot create files under /usr
|
||||
ExecStart=/bin/sh -c '! touch /usr/hoge'
|
||||
ExecStart=/bin/sh -c '! touch /usr/bin/hoge'
|
||||
|
||||
TemporaryFileSystem=/usr:ro
|
||||
BindReadOnlyPaths=-/usr/lib -/usr/lib64 /usr/bin /usr/sbin
|
||||
Reference in New Issue
Block a user