[PATCH bpf-next 1/2] selftests/bpf: Update ima test helper's losetup commands
KP Singh
kpsingh at chromium.org
Tue Dec 1 14:38:02 UTC 2020
Oops I sent this to the wrong list, sorry about that.
On Tue, Dec 1, 2020 at 3:32 PM KP Singh <kpsingh at chromium.org> wrote:
>
> From: KP Singh <kpsingh at google.com>
>
> Update the commands to use the bare minimum options so that it works
> in busybox environments.
>
> Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
> Reported-by: Andrii Nakryiko <andrii at kernel.org>
> Signed-off-by: KP Singh <kpsingh at google.com>
> ---
> tools/testing/selftests/bpf/ima_setup.sh | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh
> index 15490ccc5e55..ed29bde26a12 100755
> --- a/tools/testing/selftests/bpf/ima_setup.sh
> +++ b/tools/testing/selftests/bpf/ima_setup.sh
> @@ -3,6 +3,7 @@
>
> set -e
> set -u
> +set -o pipefail
>
> IMA_POLICY_FILE="/sys/kernel/security/ima/policy"
> TEST_BINARY="/bin/true"
> @@ -23,9 +24,10 @@ setup()
>
> dd if=/dev/zero of="${mount_img}" bs=1M count=10
>
> - local loop_device="$(losetup --find --show ${mount_img})"
> + losetup -f "${mount_img}"
> + local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1)
>
> - mkfs.ext4 "${loop_device}"
> + mkfs.ext4 "${loop_device:?}"
> mount "${loop_device}" "${mount_dir}"
>
> cp "${TEST_BINARY}" "${mount_dir}"
> @@ -38,7 +40,8 @@ cleanup() {
> local mount_img="${tmp_dir}/test.img"
> local mount_dir="${tmp_dir}/mnt"
>
> - local loop_devices=$(losetup -j ${mount_img} -O NAME --noheadings)
> + local loop_devices=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1)
> +
> for loop_dev in "${loop_devices}"; do
> losetup -d $loop_dev
> done
> --
> 2.29.2.454.gaff20da3a2-goog
>
More information about the kernel-team
mailing list