aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2018-01-24 11:18:46 +0100
committerMichael Vogt <mvo@ubuntu.com>2018-01-25 12:51:00 +0100
commit1e589ed2649ad6ed31406c281fd4178fb396288a (patch)
tree06732adad74bc4e7c7ced3a22416acd0a5553920 /test/TEST-21-SYSUSERS
parentsysuser: use OrderedHashmap (diff)
downloadsystemd-1e589ed2649ad6ed31406c281fd4178fb396288a.tar.gz
systemd-1e589ed2649ad6ed31406c281fd4178fb396288a.tar.bz2
systemd-1e589ed2649ad6ed31406c281fd4178fb396288a.zip
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.
Diffstat (limited to 'test/TEST-21-SYSUSERS')
-rw-r--r--test/TEST-21-SYSUSERS/Makefile4
-rw-r--r--test/TEST-21-SYSUSERS/test-1.expected-group2
-rw-r--r--test/TEST-21-SYSUSERS/test-1.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-1.input3
-rw-r--r--test/TEST-21-SYSUSERS/test-2.expected-group1
-rw-r--r--test/TEST-21-SYSUSERS/test-2.expected-passwd1
-rw-r--r--test/TEST-21-SYSUSERS/test-2.input2
-rw-r--r--test/TEST-21-SYSUSERS/test-3.expected-group4
-rw-r--r--test/TEST-21-SYSUSERS/test-3.expected-passwd4
-rw-r--r--test/TEST-21-SYSUSERS/test-3.input7
-rwxr-xr-xtest/TEST-21-SYSUSERS/test.sh30
11 files changed, 59 insertions, 0 deletions
diff --git a/test/TEST-21-SYSUSERS/Makefile b/test/TEST-21-SYSUSERS/Makefile
new file mode 100644
index 000000000..34d7cc6cd
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/Makefile
@@ -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 --$@
diff --git a/test/TEST-21-SYSUSERS/test-1.expected-group b/test/TEST-21-SYSUSERS/test-1.expected-group
new file mode 100644
index 000000000..cc9093f80
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.expected-group
@@ -0,0 +1,2 @@
+g1:x:111:
+u1:x:222:
diff --git a/test/TEST-21-SYSUSERS/test-1.expected-passwd b/test/TEST-21-SYSUSERS/test-1.expected-passwd
new file mode 100644
index 000000000..8d0bfff31
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.expected-passwd
@@ -0,0 +1 @@
+u1:x:222:222::/:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-1.input b/test/TEST-21-SYSUSERS/test-1.input
new file mode 100644
index 000000000..bffc2cd7e
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-1.input
@@ -0,0 +1,3 @@
+#Type Name ID GECOS HOMEDIR
+u u1 222 - -
+g g1 111 - -
diff --git a/test/TEST-21-SYSUSERS/test-2.expected-group b/test/TEST-21-SYSUSERS/test-2.expected-group
new file mode 100644
index 000000000..f98e85fcf
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.expected-group
@@ -0,0 +1 @@
+u1:x:999:
diff --git a/test/TEST-21-SYSUSERS/test-2.expected-passwd b/test/TEST-21-SYSUSERS/test-2.expected-passwd
new file mode 100644
index 000000000..d907e483f
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.expected-passwd
@@ -0,0 +1 @@
+u1:x:999:999:some gecos:/random/dir:/sbin/nologin
diff --git a/test/TEST-21-SYSUSERS/test-2.input b/test/TEST-21-SYSUSERS/test-2.input
new file mode 100644
index 000000000..d8f31347a
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-2.input
@@ -0,0 +1,2 @@
+#Type Name ID GECOS HOMEDIR
+u u1 - "some gecos" /random/dir
diff --git a/test/TEST-21-SYSUSERS/test-3.expected-group b/test/TEST-21-SYSUSERS/test-3.expected-group
new file mode 100644
index 000000000..6ea8bce38
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.expected-group
@@ -0,0 +1,4 @@
+hoge:x:300:
+baz:x:302:
+foo:x:301:
+ccc:x:306:
diff --git a/test/TEST-21-SYSUSERS/test-3.expected-passwd b/test/TEST-21-SYSUSERS/test-3.expected-passwd
new file mode 100644
index 000000000..c35e9abb8
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.expected-passwd
@@ -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
diff --git a/test/TEST-21-SYSUSERS/test-3.input b/test/TEST-21-SYSUSERS/test-3.input
new file mode 100644
index 000000000..672c57bb9
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test-3.input
@@ -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 - -
diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh
new file mode 100755
index 000000000..a206fb7f3
--- /dev/null
+++ b/test/TEST-21-SYSUSERS/test.sh
@@ -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 "$@"