Re: [kvm-unit-tests PATCH v3 1/4] runtime: add support for panic tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Claudio Imbrenda (2022-08-10 11:58:08)
[...]
> > diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> > index 0dfaf017db0a..739490bc7da2 100644
> > --- a/scripts/arch-run.bash
> > +++ b/scripts/arch-run.bash
> > @@ -104,6 +104,14 @@ qmp ()
> >       echo '{ "execute": "qmp_capabilities" }{ "execute":' "$2" '}' | ncat -U $1
> >  }
> >  
> > +qmp_events ()
> > +{
> > +     while ! test -S "$1"; do sleep 0.1; done
> > +     echo '{ "execute": "qmp_capabilities" }{ "execute": "cont" }' \
> 
> if you put the pipe at the end of the line, instead of the beginning,
> then you don't need the \ . I think it is easier to read without the \
> and it is also more robust (no need to worry about spaces)

Makes sense, changed.

> > +run_panic ()
> > +{
> > +     if ! command -v ncat >/dev/null 2>&1; then
> > +             echo "${FUNCNAME[0]} needs ncat (netcat)" >&2
> > +             return 77
> > +     fi
> > +
> > +     if ! command -v jq >/dev/null 2>&1; then
> > +             echo "${FUNCNAME[0]} needs jq" >&2
> > +             return 77
> > +     fi
> > +
> > +     qmp=$(mktemp -u -t panic-qmp.XXXXXXXXXX)
> > +
> > +     trap 'kill 0; exit 2' INT TERM
> > +     trap 'rm -f ${qmp}' RETURN EXIT
> > +
> > +     # start VM stopped so we don't miss any events
> > +     eval "$@" -chardev socket,id=mon1,path=${qmp},server=on,wait=off \
> > +             -mon chardev=mon1,mode=control -S &
> > +
> > +     panic_event_count=$(qmp_events ${qmp} | jq -c 'select(.event == "GUEST_PANICKED")' | wc -l)
> > +     if [ "$panic_event_count" -lt 1 ]; then
> > +             echo "FAIL: guest did not panic"
> > +             ret=3
> > +     else
> > +             # some QEMU versions report multiple panic events
> > +             echo "PASS: guest panicked"
> > +             ret=1
> 
> so we never return 0? is that intentional?

Yes, as far as I understand things, this is correct:

run_panic's status code is (in the end) fed to run_qemu or run_qemu_status. These two functions rewrite the QEMU status code to determine whether tests succeeded.

Before the rewrite, return 3 means unit test failed; return 1 means unit test succeeded. So I *think* this is appropriate as-is.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux