From 1ded8d02c38d95b02ee33bfc94d06b8a82f14a25 Mon Sep 17 00:00:00 2001 From: cytopia Date: Mon, 28 Mar 2022 14:36:55 +0200 Subject: [PATCH] Ensure xargs with with -P option --- tests/03-test-xargs.sh | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tests/03-test-xargs.sh diff --git a/tests/03-test-xargs.sh b/tests/03-test-xargs.sh new file mode 100755 index 0000000..5e7fada --- /dev/null +++ b/tests/03-test-xargs.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -e +set -u +set -o pipefail + +CWD="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" + +IMAGE="${1}" +#NAME="${2}" +#VERSION="${3}" +TAG="${4}" +ARCH="${5}" + + +### +### Load Library +### +# shellcheck disable=SC1091 +. "${CWD}/.lib.sh" + + +RAND_NAME="$( get_random_name )" + +### +### Startup container +### +FILES="$( \ +run "docker run --rm --platform ${ARCH} \ + -e DEBUG_ENTRYPOINT=2 \ + -e DEBUG_RUNTIME=1 \ + -e NEW_UID=$( id -u ) \ + -e NEW_GID=$( id -g ) \ + --entrypoint=bash \ + --name ${RAND_NAME} ${IMAGE}:${TAG} -c ' + find /lib -print0 | xargs -n1 -0 -P 2 + '" +)" + +if [ -z "${FILES}" ]; then + >&2 echo "Error, no files found with 'find' and 'xargs'" + exit 1 +fi + +echo "[OK] xargs works"