46c400fb00
related: rhbz#2059289
73 lines
2.3 KiB
Diff
73 lines
2.3 KiB
Diff
From 660a2d164d27f6a563731172439a39a284a2e674 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Mon, 27 Jun 2022 14:01:51 +0100
|
|
Subject: [PATCH] tests/test-parallel-sh.sh: Small cleanups
|
|
|
|
Quote the inline script to make it easier to follow. This requires us
|
|
to export $curr_fds to nbdkit, but that's fine.
|
|
|
|
Use $curr_fds != "" as a proxy for the existence of /proc/$$/fd so we
|
|
don't need to test that twice.
|
|
|
|
Print the parent /proc/$$/fd as well as the child, so if a leaked fd
|
|
happens it's easier to tell what it is.
|
|
|
|
These are just refactorings which should not affect the test.
|
|
|
|
(cherry picked from commit 053293f93acee196e6411baf6f2b8827069ae7bf)
|
|
---
|
|
tests/test-parallel-sh.sh | 22 +++++++++++++---------
|
|
1 file changed, 13 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/tests/test-parallel-sh.sh b/tests/test-parallel-sh.sh
|
|
index 39ccd569..04f58b89 100755
|
|
--- a/tests/test-parallel-sh.sh
|
|
+++ b/tests/test-parallel-sh.sh
|
|
@@ -65,30 +65,34 @@ timeout 30s </dev/null qemu-io -f raw -c "aio_write -P 1 0 512" \
|
|
|
|
curr_fds=
|
|
if test -d /proc/$$/fd; then
|
|
+ echo "parent fds:" >&2
|
|
+ ls -l /proc/$$/fd >&2
|
|
curr_fds=$(/usr/bin/env bash -c '(ls /proc/$$/fd)' | wc -w)
|
|
fi
|
|
+export curr_fds
|
|
echo "using curr_fds=$curr_fds"
|
|
|
|
-cat > test-parallel-sh.script <<EOF
|
|
+cat > test-parallel-sh.script <<'EOF'
|
|
#!/usr/bin/env bash
|
|
f=test-parallel-sh.data
|
|
-if ! test -f \$f; then
|
|
+if ! test -f $f; then
|
|
echo "can't locate test-parallel-sh.data" >&2; exit 5
|
|
fi
|
|
-if test -d /proc/\$\$/fd; then
|
|
+if test -n "$curr_fds"; then
|
|
(
|
|
- if test \$( ls /proc/\$\$/fd | wc -w ) -ne \$(($curr_fds + 1)); then
|
|
+ if test $( ls /proc/$$/fd | wc -w ) -ne $(($curr_fds + 1)); then
|
|
+ echo "nbdkit script fds:" >&2
|
|
+ ls -l /proc/$$/fd >&2
|
|
echo "there seem to be leaked fds, curr_fds=$curr_fds" >&2
|
|
- ls -l /proc/\$\$/fd >&2
|
|
exit 1
|
|
fi
|
|
) || exit 5
|
|
fi
|
|
-case \$1 in
|
|
+case $1 in
|
|
thread_model) echo parallel ;;
|
|
- get_size) stat -L -c %s \$f || exit 1 ;;
|
|
- pread) dd iflag=skip_bytes,count_bytes skip=\$4 count=\$3 if=\$f || exit 1 ;;
|
|
- pwrite) dd oflag=seek_bytes conv=notrunc seek=\$4 of=\$f || exit 1 ;;
|
|
+ get_size) stat -L -c %s $f || exit 1 ;;
|
|
+ pread) dd iflag=skip_bytes,count_bytes skip=$4 count=$3 if=$f || exit 1 ;;
|
|
+ pwrite) dd oflag=seek_bytes conv=notrunc seek=$4 of=$f || exit 1 ;;
|
|
can_write) ;;
|
|
*) exit 2 ;;
|
|
esac
|
|
--
|
|
2.31.1
|
|
|