All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org,
	qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: fix -valgrind option for check
Date: Fri, 30 Oct 2015 19:09:42 +0100	[thread overview]
Message-ID: <5633B266.6000207@redhat.com> (raw)
In-Reply-To: <20151030180411.GC2628@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 4365 bytes --]

On 30.10.2015 19:04, Jeff Cody wrote:
> On Fri, Oct 30, 2015 at 06:16:29PM +0100, Max Reitz wrote:
>> On 29.10.2015 19:04, Jeff Cody wrote:
>>> Commit 934659c switched the iotests to run qemu-io from a bash subshell,
>>> in order to catch segfaults.  This method is incompatible with the
>>> current valgrind_qemu_io() bash function.
>>>
>>> Move the valgrind usage into the exec subshell in _qemu_io_wrapper(),
>>> while making sure the original return value is passed back to the
>>> caller.
>>>
>>> Update test output for tests 039, 061, and 137 as it looks for the
>>> specific subshell command when the process is terminated.
>>>
>>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>>> Signed-off-by: Jeff Cody <jcody@redhat.com>
>>> ---
>>>  tests/qemu-iotests/039.out       | 30 +++++++++++++++++++++++++-----
>>>  tests/qemu-iotests/061.out       | 12 ++++++++++--
>>>  tests/qemu-iotests/137.out       |  6 +++++-
>>>  tests/qemu-iotests/common        |  9 ++-------
>>>  tests/qemu-iotests/common.config | 18 +++++++++++++++++-
>>>  tests/qemu-iotests/common.rc     | 10 ----------
>>>  6 files changed, 59 insertions(+), 26 deletions(-)
>>>

[...]

>>> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
>>> index 4d8665f..db9702b 100644
>>> --- a/tests/qemu-iotests/common.config
>>> +++ b/tests/qemu-iotests/common.config
>>> @@ -122,7 +122,23 @@ _qemu_img_wrapper()
>>>  
>>>  _qemu_io_wrapper()
>>>  {
>>> -    (exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@")
>>> +    local VALGRIND_LOGFILE=/tmp/$$.valgrind
>>> +    local RETVAL
>>> +    (
>>> +        if [ "${VALGRIND_QEMU}" == "y" ]; then
>>> +            exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"
>>> +        else
>>> +            exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"
>>> +        fi
>>> +    )
>>> +    RETVAL=$?
>>
>> Er, well, this is nice... When just invoking $QEMU_IO -c 'sigraise 9', I
>> get the appropriate error message. ("$PID Killed [...]"). But the
>> instant an image is opened, it just disappears. Yes, using -c open makes
>> it disappear, too.
>>
>> Since all of our qemu-io invocations do use image files (that's its
>> purpose after all), that means that all of them seem to exit just fine
>> when running under valgrind. That is... strange.
>>
>> Is it just me? Maybe I have a broken valgrind, I don't know (3.11.0 here).
>>
> 
> I have valgrind-3.9.0 here, and I get the same behavior... it is not
> just you.  There are also some tests where valgrind itself segfaults.
> 
> I was going to suggest using kill -l TERM instead of kill -l KILL.
> However, I just tried that with test 137, and it causes valgrind to
> segfault. :(

Hm, well, then I guess we can just ignore this and declare it broken. If
someone complains, it'll be his/her job to fix it. ;-)

>>> +    if [ "${VALGRIND_QEMU}" == "y" ]; then
>>> +        if [ $RETVAL != 0 ]; then
>>> +            cat "${VALGRIND_LOGFILE}"
>>
>> If I got the error message and RETVAL would be correctly set to 137,
>> this would print the log file. I'm not sure whether that's what we
>> want...? If valgrind exits with any error code but 99, the log file will
>> probably not contain anything interesting.
>>
>> But if the qemu-io process was killed on purpose, this breaks the test,
>> which I don't think is necessary.
>>
> 
> Good point... How about just:
> 
>  if [ $RETVAL == 99 ]; then
>       cat "${VALGRIND_LOGFILE}"
>  fi

Yes, that's what I had in mind.

Max

>>> +        fi
>>> +        rm -f "${VALGRIND_LOGFILE}"
>>> +    fi
>>> +    (exit $RETVAL)
>>>  }
>>>  
>>>  _qemu_nbd_wrapper()
>>> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
>>> index 4878e99..d9913f8 100644
>>> --- a/tests/qemu-iotests/common.rc
>>> +++ b/tests/qemu-iotests/common.rc
>>> @@ -70,16 +70,6 @@ else
>>>      TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
>>>  fi
>>>  
>>> -function valgrind_qemu_io()
>>> -{
>>> -    valgrind --log-file=/tmp/$$.valgrind --error-exitcode=99 $REAL_QEMU_IO "$@"
>>> -    if [ $? != 0 ]; then
>>> -        cat /tmp/$$.valgrind
>>> -    fi
>>> -    rm -f /tmp/$$.valgrind
>>> -}
>>> -
>>> -
>>>  _optstr_add()
>>>  {
>>>      if [ -n "$1" ]; then
>>>
>>
>>
> 
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2015-10-30 18:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 18:04 [Qemu-devel] [PATCH] qemu-iotests: fix -valgrind option for check Jeff Cody
2015-10-30 17:16 ` Max Reitz
2015-10-30 18:04   ` Jeff Cody
2015-10-30 18:09     ` Max Reitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5633B266.6000207@redhat.com \
    --to=mreitz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.