]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add a sysusers test with NIS entries 8468/head
authorFranck Bui <fbui@suse.com>
Thu, 15 Mar 2018 12:39:38 +0000 (13:39 +0100)
committerFranck Bui <fbui@suse.com>
Sat, 17 Mar 2018 13:18:26 +0000 (14:18 +0100)
test/TEST-21-SYSUSERS/test-11.expected-group [new file with mode: 0644]
test/TEST-21-SYSUSERS/test-11.expected-passwd [new file with mode: 0644]
test/TEST-21-SYSUSERS/test-11.initial-group [new file with mode: 0644]
test/TEST-21-SYSUSERS/test-11.initial-passwd [new file with mode: 0644]
test/TEST-21-SYSUSERS/test-11.input [new file with mode: 0644]
test/TEST-21-SYSUSERS/test.sh

diff --git a/test/TEST-21-SYSUSERS/test-11.expected-group b/test/TEST-21-SYSUSERS/test-11.expected-group
new file mode 100644 (file)
index 0000000..815a6c5
--- /dev/null
@@ -0,0 +1,6 @@
+o1:x:100:
+g1:x:111:
+u1:x:222:
++giant:::bill,tina,alan,hetty
+-transport:::
++:::
diff --git a/test/TEST-21-SYSUSERS/test-11.expected-passwd b/test/TEST-21-SYSUSERS/test-11.expected-passwd
new file mode 100644 (file)
index 0000000..3f9ab39
--- /dev/null
@@ -0,0 +1,6 @@
+root:x:0:0:root:/root:/bin/bash
+systemd-network:x:492:492:Systemd Network Management:/:/usr/sbin/nologin
+systemd-resolve:x:491:491:Systemd Resolver:/:/usr/sbin/nologin
+systemd-timesync:x:493:493:Systemd Time Synchronization:/:/usr/sbin/nologin
+u1:x:222:222::/:/sbin/nologin
++::::::
diff --git a/test/TEST-21-SYSUSERS/test-11.initial-group b/test/TEST-21-SYSUSERS/test-11.initial-group
new file mode 100644 (file)
index 0000000..88d31f2
--- /dev/null
@@ -0,0 +1,4 @@
+o1:x:100
++giant:::bill,tina,alan,hetty
+-transport:::
++:::
diff --git a/test/TEST-21-SYSUSERS/test-11.initial-passwd b/test/TEST-21-SYSUSERS/test-11.initial-passwd
new file mode 100644 (file)
index 0000000..45d3ffd
--- /dev/null
@@ -0,0 +1,5 @@
+root:x:0:0:root:/root:/bin/bash
+systemd-network:x:492:492:Systemd Network Management:/:/usr/sbin/nologin
+systemd-resolve:x:491:491:Systemd Resolver:/:/usr/sbin/nologin
+systemd-timesync:x:493:493:Systemd Time Synchronization:/:/usr/sbin/nologin
++::::::
diff --git a/test/TEST-21-SYSUSERS/test-11.input b/test/TEST-21-SYSUSERS/test-11.input
new file mode 100644 (file)
index 0000000..bffc2cd
--- /dev/null
@@ -0,0 +1,3 @@
+#Type Name ID  GECOS HOMEDIR
+u     u1   222 -     -
+g     g1   111 -     -
index bebbab9d2377c1273ab6244fd276d87e403fa79f..73cbe10b69a0e66e15430f744f1f4b1506853a6e 100755 (executable)
@@ -10,6 +10,13 @@ test_setup() {
         mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp
 }
 
+prepare_testdir() {
+        rm -f $TESTDIR/etc/*{passwd,group,shadow}
+        for i in $1.initial-{passwd,group,shadow}; do
+                test -f $i && cp $i $TESTDIR/etc/${i#*.initial-}
+        done
+}
+
 preprocess() {
     in="$1"
 
@@ -41,7 +48,7 @@ test_run() {
         # happy tests
         for f in test-*.input; do
                 echo "*** Running $f"
-                rm -f $TESTDIR/etc/*{passwd,group,shadow}
+                prepare_testdir ${f%.input}
                 cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
                 systemd-sysusers --root=$TESTDIR
 
@@ -50,7 +57,7 @@ test_run() {
 
         for f in test-*.input; do
                 echo "*** Running $f on stdin"
-                rm -f $TESTDIR/etc/*{passwd,group,shadow}
+                prepare_testdir ${f%.input}
                 touch $TESTDIR/etc/sysusers.d/test.conf
                 cat $f | systemd-sysusers --root=$TESTDIR -
 
@@ -59,7 +66,7 @@ test_run() {
 
         for f in test-*.input; do
                 echo "*** Running $f on stdin with --replace"
-                rm -f $TESTDIR/etc/*{passwd,group,shadow}
+                prepare_testdir ${f%.input}
                 touch $TESTDIR/etc/sysusers.d/test.conf
                 # this overrides test.conf which is masked on disk
                 cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf -
@@ -71,7 +78,7 @@ test_run() {
 
         # test --inline
         echo "*** Testing --inline"
-        rm -f $TESTDIR/etc/*{passwd,group,shadow}
+        prepare_testdir
         # copy a random file to make sure it is ignored
         cp $f $TESTDIR/etc/sysusers.d/confuse.conf
         systemd-sysusers --root=$TESTDIR --inline \
@@ -82,7 +89,7 @@ test_run() {
 
         # test --replace
         echo "*** Testing --inline with --replace"
-        rm -f $TESTDIR/etc/*{passwd,group,shadow}
+        prepare_testdir
         # copy a random file to make sure it is ignored
         cp $f $TESTDIR/etc/sysusers.d/confuse.conf
         systemd-sysusers --root=$TESTDIR \
@@ -98,7 +105,7 @@ test_run() {
         # tests for error conditions
         for f in unhappy-*.input; do
                 echo "*** Running test $f"
-                rm -f $TESTDIR/etc/*{passwd,group,shadow}
+                prepare_testdir ${f%.input}
                 cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
                 systemd-sysusers --root=$TESTDIR 2> /dev/null
                 journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err