From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 2/2] docs/devel: update instruction on how to add new unit tests
Date: Wed, 7 Oct 2020 04:03:12 -0400 [thread overview]
Message-ID: <20201007080312.566464-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20201007080312.566464-1-pbonzini@redhat.com>
The instructions for adding new unit tests were not in
build-system.rst and therefore I missed them in the Meson
conversion. Just like with the Makefile code there are
some magic variables to be aware of, so document them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/devel/qtest.rst | 30 +++++++++++++++++++++---------
docs/devel/testing.rst | 19 ++++++++++---------
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/docs/devel/qtest.rst b/docs/devel/qtest.rst
index 075fe5f7d5..97c5a75626 100644
--- a/docs/devel/qtest.rst
+++ b/docs/devel/qtest.rst
@@ -33,15 +33,27 @@ Steps to add a new QTest case are:
2. Write the test code with the glib and libqtest/libqos API. See also existing
tests and the library headers for reference.
-3. Register the new test in ``tests/qtest/Makefile.include``. Add the test
- executable name to an appropriate ``check-qtest-*-y`` variable. For example:
-
- ``check-qtest-generic-y = tests/qtest/foo-test$(EXESUF)``
-
-4. Add object dependencies of the executable in the Makefile, including the
- test source file(s) and other interesting objects. For example:
-
- ``tests/qtest/foo-test$(EXESUF): tests/qtest/foo-test.o $(libqos-obj-y)``
+3. Register the new test in ``tests/qtest/meson.build``. Add the test
+ executable name to an appropriate ``qtests_*`` variable. There is
+ one variable per architecture, plus ``qtests_generic`` for tests
+ that can be run for all architectures. For example::
+
+ qtests_generic = [
+ ...
+ 'foo-test',
+ ...
+ ]
+
+4. If the test has more than one source file or needs to be linked with any
+ dependency other than ``qemuutil`` and ``qos``, list them in the ``qtests``
+ dictionary. For example a test that needs to use the ``QIO`` library
+ will have an entry like::
+
+ {
+ ...
+ 'foo-test': [io],
+ ...
+ }
Debugging a QTest failure is slightly harder than the unit test because the
tests look up QEMU program names in the environment variables, such as
diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst
index a171494b4e..cecee6eaa1 100644
--- a/docs/devel/testing.rst
+++ b/docs/devel/testing.rst
@@ -41,15 +41,16 @@ add a new unit test:
test. The test code should be organized with the glib testing framework.
Copying and modifying an existing test is usually a good idea.
-3. Add the test to ``tests/Makefile.include``. First, name the unit test
- program and add it to ``$(check-unit-y)``; then add a rule to build the
- executable. For example:
-
-.. code::
-
- check-unit-y += tests/foo-test$(EXESUF)
- tests/foo-test$(EXESUF): tests/foo-test.o $(test-util-obj-y)
- ...
+3. Add the test to ``tests/meson.build``. The unit tests are listed in a
+ dictionary called ``tests``. The values are any additional sources and
+ dependencies to be linked with the test. For a simple test whose source
+ is in ``tests/foo-test.c``, it is enough to add an entry like::
+
+ {
+ ...
+ 'foo-test': [],
+ ...
+ }
Since unit tests don't require environment variables, the simplest way to debug
a unit test failure is often directly invoking it or even running it under
--
2.26.2
prev parent reply other threads:[~2020-10-07 8:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 8:03 [PATCH 0/2] simplify tests/qtest/meson.build and update docs Paolo Bonzini
2020-10-07 8:03 ` [PATCH 1/2] qtest: unify extra_qtest_srcs and extra_qtest_deps Paolo Bonzini
2020-10-07 8:03 ` Paolo Bonzini [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=20201007080312.566464-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--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).