]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commit
block: qemu-iotests - add common.qemu, for bash-controlled qemu tests
authorJeff Cody <jcody@redhat.com>
Wed, 30 Apr 2014 14:55:08 +0000 (10:55 -0400)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 9 May 2014 18:57:32 +0000 (20:57 +0200)
commite940bc13ee15d6304f3a467961b9f33fc0f25595
treea01b70cccab50f162cbe025779c553380d566431
parent4f11aa8a40351b28c0e67c7276e0003b38cc46ac
block: qemu-iotests - add common.qemu, for bash-controlled qemu tests

This creates some common functions for bash language qemu-iotests
to control, and communicate with, a running QEMU process.

4 functions are introduced:

    1. _launch_qemu()
        This launches the QEMU process(es), and sets up the file
        descriptors and fifos for communication.  You can choose to
        launch each QEMU process listening for either QMP or HMP
        monitor.  You can call this function multiple times, and
        save the handle returned from each.  The returned handle is
        in $QEMU_HANDLE.  You must copy this value.

Commands 2 and 3 use the handle received from _launch_qemu(), to talk
to the appropriate process.

    2. _send_qemu_cmd()
        Sends a command string, specified by $2, to QEMU.  If $3 is
        non-NULL, _send_qemu_cmd() will wait to receive $3 as a
        required result string from QEMU.  Failure to receive $3 will
        cause the test to fail.  The command can optionally be retried
        $qemu_cmd_repeat number of times.  Set $qemu_error_no_exit
        to not force the test the fail on exit; in this case,
        $QEMU_STATUS[$1] will be set to -1 on failure.

    3. _timed_wait_for()
        Waits for a response, for up to a default of 10 seconds.  If
        $2 is not seen in that time (anywhere in the response), then
        the test fails.  Primarily used by _send_qemu_cmd, but could
        be useful standalone, as well.  To prevent automatic exit
        (and therefore test failure), set $qemu_error_no_exit to a
        non-NULL value.  If $silent is a non-NULL value, then output
        to stdout will be suppressed.

    4. _cleanup_qemu()
        Kills the running QEMU processes, and removes the fifos.

Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/qemu-iotests/common.qemu [new file with mode: 0644]