Skip to content

Commit 044df62

Browse files
committed
test-sysusers: fix how paths are calculated
We were looking at ${f%.*}, i.e. the $f with any suffix starting with a dot removed. This worked fine for paths like /some/path/test-11.input. It also worked for paths like /some/path/inline (there were no dots, so we got $f back unscathed). But in the ubuntu CI the package is built in a temporary directory like /tmp/autopkgtest-lxc.nnnfqb26/downtmp/build.UfW/ (yes, it has a dot, even two.). That still worked for the first case, but in the second case we truncated things after the first dot, and we would try to get /tmp/autopkgtest-lxc.nnnfqb26/downtmp/build and try to load /tmp/autopkgtest-lxc.nnnfqb26/downtmp/build.expected-password, which obviously didn't work as expected. To avoid this issue, do the suffix removal only when we know that there really is a suffix. A second minor issue was that we would try to copy $1.expected-*, and sometimes $1 would be given, and sometimes not. Effectively we were relying on there not being any files matching .expected-*. There weren't any such files, but let's avoid this ugliness and always pass $1.
1 parent 69a7c5f commit 044df62

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/test-sysusers.sh.in

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ preprocess() {
2727
}
2828

2929
compare() {
30-
if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then
31-
echo "**** Unexpected output for $f"
30+
if ! diff -u $TESTDIR/etc/passwd <(preprocess $1.expected-passwd); then
31+
echo "**** Unexpected output for $f $2"
3232
exit 1
3333
fi
3434

35-
if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then
35+
if ! diff -u $TESTDIR/etc/group <(preprocess $1.expected-group); then
3636
echo "**** Unexpected output for $f $2"
3737
exit 1
3838
fi
@@ -47,7 +47,7 @@ for f in $(ls -1 $SOURCE/test-*.input | sort -V); do
4747
cp $f $TESTDIR/usr/lib/sysusers.d/test.conf
4848
$SYSUSERS --root=$TESTDIR
4949

50-
compare $f ""
50+
compare ${f%.*} ""
5151
done
5252

5353
for f in $(ls -1 $SOURCE/test-*.input | sort -V); do
@@ -56,7 +56,7 @@ for f in $(ls -1 $SOURCE/test-*.input | sort -V); do
5656
touch $TESTDIR/etc/sysusers.d/test.conf
5757
cat $f | $SYSUSERS --root=$TESTDIR -
5858

59-
compare $f "on stdin"
59+
compare ${f%.*} "on stdin"
6060
done
6161

6262
for f in $(ls -1 $SOURCE/test-*.input | sort -V); do
@@ -68,12 +68,12 @@ for f in $(ls -1 $SOURCE/test-*.input | sort -V); do
6868
# this should be ignored
6969
cat $SOURCE/test-1.input | $SYSUSERS --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf -
7070

71-
compare $f "on stdin with --replace"
71+
compare ${f%.*} "on stdin with --replace"
7272
done
7373

7474
# test --inline
7575
echo "*** Testing --inline"
76-
prepare_testdir
76+
prepare_testdir $SOURCE/inline
7777
# copy a random file to make sure it is ignored
7878
cp $f $TESTDIR/etc/sysusers.d/confuse.conf
7979
$SYSUSERS --root=$TESTDIR --inline \
@@ -84,7 +84,7 @@ compare $SOURCE/inline "(--inline)"
8484

8585
# test --replace
8686
echo "*** Testing --inline with --replace"
87-
prepare_testdir
87+
prepare_testdir $SOURCE/inline
8888
# copy a random file to make sure it is ignored
8989
cp $f $TESTDIR/etc/sysusers.d/confuse.conf
9090
$SYSUSERS --root=$TESTDIR \

0 commit comments

Comments
 (0)