diff --git a/test/lib/aux.sh b/test/lib/aux.sh index de1425327..ab3fc05d8 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -86,6 +86,22 @@ prepare_lvmetad() { echo ok } +lvmetad_talk() { + if type -p socat >& /dev/null; then + socat "unix-connect:$TESTDIR/lvmetad.socket" - + elif echo | nc -U "$TESTDIR/lvmetad.socket"; then + nc -U "$TESTDIR/lvmetad.socket" + else + echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2 + echo "# failed to contact lvmetad" + return 1 + fi | tee -a lvmetad-talk.txt +} + +lvmetad_dump() { + (echo 'request="dump"'; echo '##') | lvmetad_talk "$@" +} + notify_lvmetad() { if test -e LOCAL_LVMETAD; then pvscan --cache "$@" || true diff --git a/test/shell/lvmetad-dump.sh b/test/shell/lvmetad-dump.sh index 462de1c87..9c9cd2b3d 100644 --- a/test/shell/lvmetad-dump.sh +++ b/test/shell/lvmetad-dump.sh @@ -16,24 +16,8 @@ aux prepare_pvs 2 vgcreate $vg1 $dev1 $dev2 lvcreate -n bar -l 1 $vg1 -lvmetad_talk() { - if type -p socat >& /dev/null; then - socat "unix-connect:$1" - - elif echo | nc -U "$1"; then - nc -U "$1" - else - echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2 - echo "# DUMP FAILED" - return 1 - fi -} - -lvmetad_dump() { - (echo 'request="dump"'; echo '##') | lvmetad_talk "$@" -} - -(echo | lvmetad_talk ./lvmetad.socket) || skip -lvmetad_dump ./lvmetad.socket | tee lvmetad.txt +(echo | aux lvmetad_talk) || skip +aux lvmetad_dump | tee lvmetad.txt grep $vg1 lvmetad.txt