mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
test: add TEST-21-SYSUSERS test
This test tests the systemd-sysuser binary via the --root=$TESTDIR option and ensures that for the given inputs the expected passwd and group files will be generated.
This commit is contained in:
parent
5bc9c980d0
commit
1e589ed264
4
test/TEST-21-SYSUSERS/Makefile
Normal file
4
test/TEST-21-SYSUSERS/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
BUILD_DIR=$(shell ../../tools/find-build-dir.sh)
|
||||
|
||||
all setup clean run:
|
||||
@basedir=../.. TEST_BASE_DIR=../ BUILD_DIR=$(BUILD_DIR) ./test.sh --$@
|
2
test/TEST-21-SYSUSERS/test-1.expected-group
Normal file
2
test/TEST-21-SYSUSERS/test-1.expected-group
Normal file
@ -0,0 +1,2 @@
|
||||
g1:x:111:
|
||||
u1:x:222:
|
1
test/TEST-21-SYSUSERS/test-1.expected-passwd
Normal file
1
test/TEST-21-SYSUSERS/test-1.expected-passwd
Normal file
@ -0,0 +1 @@
|
||||
u1:x:222:222::/:/sbin/nologin
|
3
test/TEST-21-SYSUSERS/test-1.input
Normal file
3
test/TEST-21-SYSUSERS/test-1.input
Normal file
@ -0,0 +1,3 @@
|
||||
#Type Name ID GECOS HOMEDIR
|
||||
u u1 222 - -
|
||||
g g1 111 - -
|
1
test/TEST-21-SYSUSERS/test-2.expected-group
Normal file
1
test/TEST-21-SYSUSERS/test-2.expected-group
Normal file
@ -0,0 +1 @@
|
||||
u1:x:999:
|
1
test/TEST-21-SYSUSERS/test-2.expected-passwd
Normal file
1
test/TEST-21-SYSUSERS/test-2.expected-passwd
Normal file
@ -0,0 +1 @@
|
||||
u1:x:999:999:some gecos:/random/dir:/sbin/nologin
|
2
test/TEST-21-SYSUSERS/test-2.input
Normal file
2
test/TEST-21-SYSUSERS/test-2.input
Normal file
@ -0,0 +1,2 @@
|
||||
#Type Name ID GECOS HOMEDIR
|
||||
u u1 - "some gecos" /random/dir
|
4
test/TEST-21-SYSUSERS/test-3.expected-group
Normal file
4
test/TEST-21-SYSUSERS/test-3.expected-group
Normal file
@ -0,0 +1,4 @@
|
||||
hoge:x:300:
|
||||
baz:x:302:
|
||||
foo:x:301:
|
||||
ccc:x:306:
|
4
test/TEST-21-SYSUSERS/test-3.expected-passwd
Normal file
4
test/TEST-21-SYSUSERS/test-3.expected-passwd
Normal file
@ -0,0 +1,4 @@
|
||||
foo:x:301:301::/:/sbin/nologin
|
||||
aaa:x:303:302::/:/sbin/nologin
|
||||
bbb:x:304:302::/:/sbin/nologin
|
||||
ccc:x:305:306::/:/sbin/nologin
|
7
test/TEST-21-SYSUSERS/test-3.input
Normal file
7
test/TEST-21-SYSUSERS/test-3.input
Normal file
@ -0,0 +1,7 @@
|
||||
g hoge 300 - -
|
||||
u foo 301 - -
|
||||
|
||||
g baz 302 - -
|
||||
u aaa 303:302 - -
|
||||
u bbb 304:302 - -
|
||||
u ccc 305:306 - -
|
30
test/TEST-21-SYSUSERS/test.sh
Executable file
30
test/TEST-21-SYSUSERS/test.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
set -e
|
||||
TEST_DESCRIPTION="Sysuser-related tests"
|
||||
|
||||
. $TEST_BASE_DIR/test-functions
|
||||
|
||||
test_setup() {
|
||||
mkdir -p $TESTDIR/etc $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp
|
||||
}
|
||||
|
||||
test_run() {
|
||||
for f in test-*.input; do
|
||||
echo "***** Running $f"
|
||||
rm -f $TESTDIR/etc/*
|
||||
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
|
||||
${BUILD_DIR}/systemd-sysusers --root=$TESTDIR
|
||||
if ! diff -u $TESTDIR/etc/passwd ${f%.*}.expected-passwd; then
|
||||
echo "**** Unexpected output for $f"
|
||||
exit 1
|
||||
fi
|
||||
if ! diff -u $TESTDIR/etc/group ${f%.*}.expected-group; then
|
||||
echo "**** Unexpected output for $f"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
do_test "$@"
|
Loading…
Reference in New Issue
Block a user