Merge pull request #4021 from diederikdehaas/replace-which-in-tests-too

Replace 'which' with 'command -v' in tests too
This commit is contained in:
Stéphane Graber 2021-10-28 15:32:01 -04:00 committed by GitHub
commit 09a4a38d6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -18,7 +18,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
if ! which apparmor_parser >/dev/null 2>&1; then
if ! command -v apparmor_parser >/dev/null 2>&1; then
echo 'SKIP: test for generated apparmor profiles: apparmor_parser missing'
fi
exit 0

View File

@ -91,7 +91,7 @@ chmod 0666 "$logfile"
# of an empty directory over the securityfs 'mount' directory
# be removed, we need to do this as non-root.
which newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
command -v newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
# create a test user
TUSER=lxcunpriv
HDIR=/home/$TUSER
@ -119,7 +119,7 @@ chown -R $TUSER: /run/user/$(id -u $TUSER)
cd $HDIR
if which cgm >/dev/null 2>&1; then
if command -v cgm >/dev/null 2>&1; then
cgm create all $TUSER
cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
cgm movepid all $TUSER $$

View File

@ -62,7 +62,7 @@ if modprobe -q overlayfs; then
fi
fi
which newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
command -v newuidmap >/dev/null 2>&1 || { echo "'newuidmap' command is missing" >&2; exit 1; }
DONE=0
UNPRIV_LOG=$(mktemp --dry-run)
@ -130,7 +130,7 @@ chown -R $TUSER: /run/user/$(id -u $TUSER)
cd $HDIR
if which cgm >/dev/null 2>&1; then
if command -v cgm >/dev/null 2>&1; then
cgm create all $TUSER
cgm chown all $TUSER $(id -u $TUSER) $(id -g $TUSER)
cgm movepid all $TUSER $$
@ -181,7 +181,7 @@ p1=$(run_cmd lxc-info -n c2 -p -H -l trace -o "${UNPRIV_LOG}")
run_cmd lxc-stop -n c2 -k -l trace -o "${UNPRIV_LOG}"
if which cgm >/dev/null 2>&1; then
if command -v cgm >/dev/null 2>&1; then
echo "Testing containers under different cgroups per subsystem"
run_cmd cgm create freezer x1/x2
cgm movepid freezer x1 $$

View File

@ -80,7 +80,7 @@ lxc.idmap = u 0 910000 10000
lxc.idmap = g 0 910000 10000
EOF
if which cgm >/dev/null 2>&1; then
if command -v cgm >/dev/null 2>&1; then
cgm create all usernic-user
cgm chown all usernic-user $(id -u usernic-user) $(id -g usernic-user)
cgm movepid all usernic-user $$