From 044df624aaa7293f82d2da48eb553cdf0ac780d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 1 Oct 2020 14:16:46 +0200 Subject: [PATCH] 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. --- test/test-sysusers.sh.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test-sysusers.sh.in b/test/test-sysusers.sh.in index b84d6f2d80b..39d238c1f78 100755 --- a/test/test-sysusers.sh.in +++ b/test/test-sysusers.sh.in @@ -27,12 +27,12 @@ preprocess() { } compare() { - if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then - echo "**** Unexpected output for $f" + if ! diff -u $TESTDIR/etc/passwd <(preprocess $1.expected-passwd); then + echo "**** Unexpected output for $f $2" exit 1 fi - if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then + if ! diff -u $TESTDIR/etc/group <(preprocess $1.expected-group); then echo "**** Unexpected output for $f $2" exit 1 fi @@ -47,7 +47,7 @@ for f in $(ls -1 $SOURCE/test-*.input | sort -V); do cp $f $TESTDIR/usr/lib/sysusers.d/test.conf $SYSUSERS --root=$TESTDIR - compare $f "" + compare ${f%.*} "" done 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 touch $TESTDIR/etc/sysusers.d/test.conf cat $f | $SYSUSERS --root=$TESTDIR - - compare $f "on stdin" + compare ${f%.*} "on stdin" done 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 # this should be ignored cat $SOURCE/test-1.input | $SYSUSERS --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - - compare $f "on stdin with --replace" + compare ${f%.*} "on stdin with --replace" done # test --inline echo "*** Testing --inline" -prepare_testdir +prepare_testdir $SOURCE/inline # copy a random file to make sure it is ignored cp $f $TESTDIR/etc/sysusers.d/confuse.conf $SYSUSERS --root=$TESTDIR --inline \ @@ -84,7 +84,7 @@ compare $SOURCE/inline "(--inline)" # test --replace echo "*** Testing --inline with --replace" -prepare_testdir +prepare_testdir $SOURCE/inline # copy a random file to make sure it is ignored cp $f $TESTDIR/etc/sysusers.d/confuse.conf $SYSUSERS --root=$TESTDIR \