3 TEST_DESCRIPTION
="Sysuser-related tests"
5 .
$TEST_BASE_DIR/test-functions
8 mkdir
-p $TESTDIR/etc
/sysusers.d
$TESTDIR/usr
/lib
/sysusers.d
$TESTDIR/tmp
12 rm -f $TESTDIR/etc
/*{passwd
,group
,shadow
}
13 for i
in $1.initial-
{passwd
,group
,shadow
}; do
14 test -f $i && cp $i $TESTDIR/etc
/${i#*.initial-}
22 # see meson.build how to extract this. gcc -E was used before to
23 # get this value from config.h, however the autopkgtest fails with
25 SYSTEM_UID_MAX
=$
(awk 'BEGIN { uid=999 } /^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }' /etc
/login.defs
)
26 sed "s/SYSTEM_UID_MAX/${SYSTEM_UID_MAX}/g" "$in"
30 if ! diff -u $TESTDIR/etc
/passwd
<(preprocess
${1%.*}.expected-passwd
); then
31 echo "**** Unexpected output for $f"
35 if ! diff -u $TESTDIR/etc
/group
<(preprocess
${1%.*}.expected-group
); then
36 echo "**** Unexpected output for $f $2"
42 # ensure our build of systemd-sysusers is run
43 PATH
=${BUILD_DIR}:$PATH
45 rm -f $TESTDIR/etc
/sysusers.d
/* $TESTDIR/usr
/lib
/sysusers.d
/*
48 for f
in test-
*.input
; do
50 prepare_testdir
${f%.input}
51 cp $f $TESTDIR/usr
/lib
/sysusers.d
/test.conf
52 systemd-sysusers
--root=$TESTDIR
57 for f
in test-
*.input
; do
58 echo "*** Running $f on stdin"
59 prepare_testdir
${f%.input}
60 touch $TESTDIR/etc
/sysusers.d
/test.conf
61 cat $f | systemd-sysusers
--root=$TESTDIR -
66 for f
in test-
*.input
; do
67 echo "*** Running $f on stdin with --replace"
68 prepare_testdir
${f%.input}
69 touch $TESTDIR/etc
/sysusers.d
/test.conf
70 # this overrides test.conf which is masked on disk
71 cat $f | systemd-sysusers
--root=$TESTDIR --replace=/etc
/sysusers.d
/test.conf
-
72 # this should be ignored
73 cat test-1.input | systemd-sysusers
--root=$TESTDIR --replace=/usr
/lib
/sysusers.d
/test.conf
-
75 compare
$f "on stdin with --replace"
79 echo "*** Testing --inline"
81 # copy a random file to make sure it is ignored
82 cp $f $TESTDIR/etc
/sysusers.d
/confuse.conf
83 systemd-sysusers
--root=$TESTDIR --inline \
84 "u u1 222 - - /bin/zsh" \
87 compare inline
"(--inline)"
90 echo "*** Testing --inline with --replace"
92 # copy a random file to make sure it is ignored
93 cp $f $TESTDIR/etc
/sysusers.d
/confuse.conf
94 systemd-sysusers
--root=$TESTDIR \
96 --replace=/etc
/sysusers.d
/confuse.conf \
97 "u u1 222 - - /bin/zsh" \
100 compare inline
"(--inline --replace=…)"
102 rm -f $TESTDIR/etc
/sysusers.d
/* $TESTDIR/usr
/lib
/sysusers.d
/*
104 # tests for error conditions
105 for f
in unhappy-
*.input
; do
106 echo "*** Running test $f"
107 prepare_testdir
${f%.input}
108 cp $f $TESTDIR/usr
/lib
/sysusers.d
/test.conf
109 systemd-sysusers
--root=$TESTDIR 2> /dev
/null
110 journalctl
-t systemd-sysusers
-o cat |
tail -n1 > $TESTDIR/tmp
/err
111 if ! diff -u $TESTDIR/tmp
/err
${f%.*}.expected-err
; then
112 echo "**** Unexpected error output for $f"