From: Cleber Rosa <crosa@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
qemu-block@nongnu.org, Cleber Rosa <crosa@redhat.com>
Subject: [Qemu-devel] [PATCH 10/10] qemu-iotests: add section on how to write a new I/O test
Date: Thu, 16 Nov 2017 12:38:10 -0500 [thread overview]
Message-ID: <20171116173810.16457-11-crosa@redhat.com> (raw)
In-Reply-To: <20171116173810.16457-1-crosa@redhat.com>
This adds some basic information on how to write a new test. I'm
aware that some of the information in the wiki (Testing/QemuIoTests)
could also belong here.
Since copying content over won't generate much interesting feedback,
the goal here is to get feedback on the sample_test_templates, general
workflow proposed for writing a new test, etc.
After feedback is received, I can go over and sync both sides (wiki
and README).
Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
tests/qemu-iotests/README | 44 ++++++++++++++--
tests/qemu-iotests/sample_test_templates/sample.py | 59 ++++++++++++++++++++++
tests/qemu-iotests/sample_test_templates/sample.sh | 40 +++++++++++++++
3 files changed, 138 insertions(+), 5 deletions(-)
create mode 100755 tests/qemu-iotests/sample_test_templates/sample.py
create mode 100755 tests/qemu-iotests/sample_test_templates/sample.sh
diff --git a/tests/qemu-iotests/README b/tests/qemu-iotests/README
index 6079b401ae..efaf72d5e7 100644
--- a/tests/qemu-iotests/README
+++ b/tests/qemu-iotests/README
@@ -1,20 +1,54 @@
+= This is the QEMU I/O test suite =
-=== This is the QEMU I/O test suite ===
-
-* Intro
+== Intro ==
This package contains a simple test suite for the I/O layer of qemu.
It does not require a guest, but only the qemu, qemu-img and qemu-io
binaries. This does limit it to exercise the low-level I/O path only
but no actual block drivers like ide, scsi or virtio.
-* Usage
+== Usage ==
Just run ./check to run all tests for the raw image format, or ./check
-qcow2 to test the qcow2 image format. The output of ./check -h explains
additional options to test further image formats or I/O methods.
-* Feedback and patches
+== Writing a QEMU I/O test ==
+
+It's a common practice to start with an existing test that may relate
+to the task you have. QEMU I/O tests are usually written either in
+shell or Python, so it's also a good idea to pick an existing test
+based on your familiarity with those languages and/or what you
+anticipate about your test.
+
+You can find templates available at "sample_test_templates/", or you
+can start with an existing test, such as 001 (shell based) or 030
+(Python based).
+
+After you pick your template, name it as a three-digits file, starting
+with the next available one. If `ls -1 ??? | sort -rn | head -1` gives
+you "197", name your test "198". Finally, add an entry to the "group"
+file, which manages just that, test group classification, allowing a
+user to run all "quick" tests, for instance.
+
+=== Test configuration, expected results and reporting ===
+
+The tests are (mostly) standard executable files, that are executed by
+"./check" as such. Tests get most of their configuration (directly or
+indirectly) by environment variables. Some of the framework auxiliary
+code (for instance, "common.rc") defines or changes some of the
+environment variables. You'll come across tests that reference
+"$TEST_IMG", "$QEMU_IO" and other variables.
+
+The expected results for a test are stored in a file named after the
+(sequential) test number. For test 001, the expected output (stdout +
+stderr) is stored at 001.out.
+
+Tests that finish successfully should exit with status code 0. To be
+considered a successful run, a test must also produce output that
+matches what is recorded in the expected output file (say, 001.out).
+
+== Feedback and patches ==
Please send improvements to the test suite, general feedback or just
reports of failing tests cases to qemu-devel@nongnu.org with a CC:
diff --git a/tests/qemu-iotests/sample_test_templates/sample.py b/tests/qemu-iotests/sample_test_templates/sample.py
new file mode 100755
index 0000000000..35a7410b5c
--- /dev/null
+++ b/tests/qemu-iotests/sample_test_templates/sample.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# DESCRIPTION HERE, such as "Test a complex thing using a simple thing"
+#
+# COPYRIGHT NOTICE HERE, such as "Copyright (C) YYYY Yourself, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Creator/Owner: your.email@example.com
+#
+
+import iotests
+
+
+class Sample(iotests.QMPTestCase):
+
+ def setUp(self):
+ """
+ Method that runs before test method(s). Use it to prepare the
+ environment that is common to the all tests, but doesn't
+ necessarily mean that is part of the feature testing
+ specifics.
+
+ Remove this docstring unless you have a really good use for it.
+ """
+ pass
+
+ def tearDown(self):
+ """
+ Method that runs after the test method(s). Use it to clean up
+ the environment created previously in setUp().
+
+ Remove this docstring unless you have a really good use for it.
+ """
+ pass
+
+ def test(self):
+ """
+ Test code goes here, or in any other method whose name starts
+ with "test".
+
+ It's a good idea to describe what it's about.
+ """
+ pass
+
+
+if __name__ == '__main__':
+ iotests.main()
diff --git a/tests/qemu-iotests/sample_test_templates/sample.sh b/tests/qemu-iotests/sample_test_templates/sample.sh
new file mode 100755
index 0000000000..d50e228efc
--- /dev/null
+++ b/tests/qemu-iotests/sample_test_templates/sample.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+#
+# DESCRIPTION HERE, such as "Test a complex thing using a simple thing"
+#
+# COPYRIGHT NOTICE HERE, such as "Copyright (C) YYYY Yourself, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Creator/Owner: your.email@example.com
+#
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+status=1 # failure is the default!
+
+# get standard environment, filters and checks
+. ./common.rc
+
+# describe supported environment, and then remove this line.
+ _supported_fmt generic
+ _supported_proto generic
+ _supported_os Linux
+
+# put your test code goes here, and then remove this line.
+
+# success, all done
+echo "*** done"
+status=0
--
2.13.6
next prev parent reply other threads:[~2017-11-16 17:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 17:38 [Qemu-devel] [PATCH 00/10] I/O tests cleanups Cleber Rosa
2017-11-16 17:38 ` [Qemu-devel] [PATCH 01/10] qemu-iotests: make execution of tests agnostic to test type Cleber Rosa
2017-11-17 7:25 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-11-17 13:15 ` Cleber Rosa
2017-12-01 20:16 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 02/10] qemu-iotests: fix filename containing checks Cleber Rosa
2017-12-01 20:17 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 03/10] qemu-iotests: be strict with expected output Cleber Rosa
2017-12-01 20:25 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 04/10] qemu-iotests: include (source) filters from common.rc Cleber Rosa
2017-12-01 20:28 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 05/10] qemu-iotests: define functions used in _cleanup() before its use Cleber Rosa
2017-12-01 20:43 ` Max Reitz
2017-12-01 21:03 ` Eric Blake
2017-11-16 17:38 ` [Qemu-devel] [PATCH 06/10] qemu-iotests: turn owner variable into a comment Cleber Rosa
2017-11-17 7:19 ` [Qemu-devel] [Qemu-block] " Paolo Bonzini
2017-11-17 13:18 ` Cleber Rosa
2017-11-17 17:59 ` Eric Blake
2017-11-16 17:38 ` [Qemu-devel] [PATCH 07/10] qemu-iotests: remove the concept of $seq.full (and boiler plate code) Cleber Rosa
2017-12-01 20:52 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 08/10] qemu-iotests: clean up double comment characters Cleber Rosa
2017-12-01 20:53 ` Max Reitz
2017-11-16 17:38 ` [Qemu-devel] [PATCH 09/10] qemu-iotests: remove unused "here" variable Cleber Rosa
2017-11-17 18:03 ` Eric Blake
2017-12-01 20:55 ` Max Reitz
2017-11-16 17:38 ` Cleber Rosa [this message]
2017-12-01 21:12 ` [Qemu-devel] [PATCH 10/10] qemu-iotests: add section on how to write a new I/O test Max Reitz
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=20171116173810.16457-11-crosa@redhat.com \
--to=crosa@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).