Lines Matching +full:python +full:- +full:container

7 everything from unit testing and exercising specific sub-systems all
9 tests you can run ``make check-help`` from either the source or build
17 [./pyvenv/bin/]meson test --suite qemu:softfloat
25 -------------------------
36 Different sub-types of "make check" tests will be explained below.
45 Unit tests, which can be invoked with ``make check-unit``, are simple C tests
53 1. Create a new source file. For example, ``tests/unit/foo-test.c``.
63 is in ``tests/unit/foo-test.c``, it is enough to add an entry like::
67 'foo-test': [],
80 make check-unit V=1
97 make check-qtest
136 The input/output data is managed under the ``tests/qapi-schema`` directory.
139 * ``${casename}.json`` - the file contains the JSON input for feeding the
141 * ``${casename}.out`` - the file contains the expected stdout from the parser
142 * ``${casename}.err`` - the file contains the expected stderr from the parser
143 * ``${casename}.exit`` - the expected error code
150 ``$EDITOR tests/qapi-schema/foo.{json,out,err,exit}``.
154 ``qapi-schema += foo.json``
156 check-block
159 ``make check-block`` runs a subset of the block layer iotests (the tests that
164 ------------
166 QEMU iotests, under the directory ``tests/qemu-iotests``, is the testing
168 than "make check" tests and 99% of the code is written in bash or Python
173 ``tests/qemu-iotests`` directory under the build directory, and run ``./check``
183 ./check -qcow2
185 ./check -nbd
192 ./check -qcow2 001 030 153
194 Cache mode can be selected with the "-c" option, which may help reveal bugs
197 More options are supported by the ``./check`` script, run ``./check -h`` for
228 * A Python unittest script. Import ``iotests`` and create a subclass of
233 * A simple Python script without using unittest module. This could also import
235 from ``iotests.QMPTestCase`` therefore doesn't use the Python unittest
238 Pick the language per your preference since both Bash and Python have
240 you opt for Python, it is strongly recommended to write Python 3 compatible
243 Both Python and Bash frameworks in iotests provide helpers to manage test
246 more convenient to use the pseudo block driver, ``null-co://``, as the test
247 image, which doesn't require image creation or cleaning up. Avoid system-wide
260 * ``-gdb`` wraps every QEMU invocation in a ``gdbserver``, which waits for a
266 ``gdb -iex "target remote $addr"``, where ``$addr`` is the address
268 If the ``-gdb`` option is not used, ``$GDB_OPTIONS`` is ignored,
271 * ``-valgrind`` attaches a valgrind instance to QEMU. If it detects
274 The final command line will be ``valgrind --log-file=$TEST_DIR/
275 <valgrind_pid>.valgrind --error-exitcode=99 $QEMU ...``
277 * ``-d`` (debug) just increases the logging verbosity, showing
280 * ``-p`` (print) redirects QEMU’s stdout and stderr to the test output,
282 ``$TEST_DIR/qemu-machine-<random_string>``.
298 Another way of defining groups is creating the tests/qemu-iotests/group.local
307 # ci - tests to run on build
308 # down - our downstream tests, not for upstream
316 our-ugly-workaround-test down ci
320 - quick: Tests in this group should finish within a few seconds.
322 - auto: Tests in this group are used during "make check" and should be
324 (also non-x86), with every QEMU configuration (i.e. must not fail if
325 an optional feature is not compiled in - but reporting a "skip" is ok),
330 - disabled: Tests in this group are disabled and ignored by check.
332 .. _container-ref:
334 Container based tests
335 ---------------------
340 The container testing framework in QEMU utilizes public images to
345 an alternative container runtime. Although many of the target
349 The container images are also used to augment the generation of tests
350 for testing TCG. See :ref:`checktcg-ref` for more details.
363 $ # or `apt-get install docker` for Ubuntu, etc.
376 $ sudo usermod $USER -a -G docker
398 From source tree, type ``make docker-help`` to see the help. Testing
400 ``make`` are done in the container, with parameters defined by the
405 make docker-test-build@debian
407 This will create a container instance using the ``debian`` image (the image
408 is downloaded and initialized automatically), in which the ``test-build`` job
414 The QEMU project has a container registry hosted by GitLab at
415 ``registry.gitlab.com/qemu-project/qemu`` which will automatically be
416 used to pull in pre-built layers. This avoids unnecessary strain on
418 container build steps over and over again. This can be overridden
423 make docker-image-debian-arm64-cross NOCACHE=1
429 in ``tests/docker/dockerfiles/``, called ``debian.docker``. ``make docker-help``
435 for example, to make qemu-user powered cross build containers work.
443 using the ``lcitool`` program provided by the ``libvirt-ci`` project:
445 https://gitlab.com/libvirt/libvirt-ci
447 ``libvirt-ci`` contains an ``lcitool`` program as well as a list of
450 pre-requisites in ``tests/lcitool/projects/qemu.yml``, determines the
456 Adding new build pre-requisites
460 pre-requisite to QEMU, the prerequisites should to be added to
464 In the simple case where the pre-requisite is already known to ``libvirt-ci``
467 * Edit ``tests/lcitool/projects/qemu.yml`` and add the pre-requisite
469 * Run ``make lcitool-refresh`` to re-generate all relevant build environment
472 It may be that ``libvirt-ci`` does not know about the new pre-requisite.
474 first to contribute the mapping to the ``libvirt-ci`` project:
476 * Fork the ``libvirt-ci`` project on gitlab
480 many OS distros as practical. Run ``python -m pytest --regenerate-output``
484 files, and submit a merge request to the ``libvirt-ci`` project.
485 Please note in the description that this is a new build pre-requisite
490 all OS distributions supported by ``libvirt-ci``.
493 the ``tests/lcitool/libvirt-ci`` submodule to point to a commit that
495 run ``make lcitool-refresh``.
497 * Please also trigger gitlab container generation pipelines on your change
499 obvious breakages when adding the new pre-requisite. Please see
503 For enterprise distros that default to old, end-of-life versions of the
504 Python runtime, QEMU uses a separate set of mappings that work with more
506 Modifying this file should not be necessary unless the new pre-requisite
507 is a Python library or tool.
513 In some cases ``libvirt-ci`` will not know about the OS distro that is
517 * Send a mail to qemu-devel, copying people listed in the
523 * File an issue at https://gitlab.com/libvirt/libvirt-ci/-/issues
524 pointing to the qemu-devel mail thread in the archives.
527 to avoid duplication, as well as to get feedback from libvirt-ci
532 * Fork the ``libvirt-ci`` project on gitlab
536 uses a package format not currently known. The ``libvirt-ci``
541 as practical. Run ``python -m pytest --regenerate-output`` and
545 files, and submit a merge request to the ``libvirt-ci`` project.
546 Please note in the description that this is a new build pre-requisite
551 all OS distributions supported by ``libvirt-ci``.
554 the ``libvirt-ci`` submodule to point to a commit that contains
563 ``test-*``. They are typically shell scripts and are built on top of a shell
567 The full list of tests is printed in the ``make docker-help`` help.
576 ``make docker-test-mingw@fedora-win64-cross J=8``.
579 in the container right before testing starts. You could either manually
580 build QEMU and run tests from there, or press Ctrl-D to let the Docker
582 4. If you press Ctrl-D, the same building and testing procedure will begin, and
593 container and enable verbose output.
594 * ``J=$N``: the number of parallel tasks in make commands in the container,
595 similar to the ``-j $N`` option in top level ``make``. (The ``-j`` option in
596 top level ``make`` will not be propagated into the container.)
601 ----------------
614 The test-tsan test will build using TSan and then run make check.
618 make docker-test-tsan@ubuntu2204
641 $ git clone --depth=1 --branch=2.81.0 https://github.com/GNOME/glib.git
643 $ CFLAGS="-O2 -g -fsanitize=thread" meson build
644 $ ninja -C build
650 ../configure --enable-tsan \
651 --disable-werror --extra-cflags="-O0"
660 $ ldd build/qemu-x86_64 | grep glib
661 $ qemu-system-x86_64 ...
692 tests/tsan/suppressions.tsan - Has TSan warnings we wish to suppress at runtime.
698 tests/tsan/ignore.tsan - Has TSan warnings we wish to disable
702 "--extra-cflags=-fsanitize-blacklist=<src path>/tests/tsan/ignore.tsan"
717 https://github.com/llvm/llvm-project/tree/master/compiler-rt/test/tsan/
723 https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
725 docker-binfmt-image-debian-% targets
726 ------------------------------------
737 You can use the script ``qemu-binfmt-conf.sh`` to configure a QEMU
743 executable on setup and avoids the need to find and re-open in the
744 chroot environment. This is triggered with the ``--persistent`` flag.
751 make docker-binfmt-image-debian-sid-hppa \
753 DEB_URL=http://ftp.ports.debian.org/debian-ports/ \
754 DEB_KEYRING=/usr/share/keyrings/debian-ports-archive-keyring.gpg \
755 EXECUTABLE=(pwd)/qemu-hppa V=1
758 ``debian-bootstrap.pre`` which is called to do the initial debootstrap
759 of the rootfs before it is copied into the container. The second stage
761 ``qemu/debian-sid-hppa``.
764 ----------
768 help which is displayed with ``make vm-help``.
773 Run ``make vm-help`` to list available make targets. Invoke a specific make
774 command to run build test in an image. For example, ``make vm-build-freebsd``
780 Note: images created by the scripts accept a well-known RSA key pair for SSH
788 By default, ``qemu-system-x86_64`` is searched in $PATH to run the guest. If
790 provide the QEMU binary in env var: ``QEMU=/path/to/qemu-2.10+``.
792 Likewise the path to ``qemu-img`` can be set in QEMU_IMG environment variable.
797 The ``-j$X`` option in the make command line is not propagated into the VM,
818 $ ./netbsd --build-image --image /var/tmp/netbsd.img
822 # --debug is added)
823 $ ./netbsd --debug --image /var/tmp/netbsd.img uname -a
826 $ ./netbsd --debug --image /var/tmp/netbsd.img --build-qemu $QEMU_SRC
829 $ ./netbsd --interactive --image /var/tmp/netbsd.img sh
847 - Root password set to ``BaseVM.ROOT_PASS``
848 - User ``BaseVM.GUEST_USER`` is created, and password set to
850 - SSH service is enabled and started on boot,
853 - DHCP client service is enabled and started on boot, so that it can
854 automatically configure the virtio-net-pci NIC and communicate with QEMU
856 - Necessary packages are installed to untar the source tarball and build
860 untars a raw virtio-blk block device, which is the tarball data blob of the
865 --------------------
872 tests/image-fuzzer/runner.py -c '[["qemu-img", "info", "$test_img"]]' /tmp/test qcow2
874 Alternatively, some command different from ``qemu-img info`` can be tested, by
875 changing the ``-c`` option.
877 Functional tests using Python
878 -----------------------------
881 Python. You can run the functional tests simply by executing:
885 make check-functional
887 See :ref:`checkfunctional-ref` for more details.
890 ---------------------------------------------
900 make check-avocado
902 See :ref:`checkavocado-ref` for more details.
905 .. _checktcg-ref:
907 Testing with "make check-tcg"
908 -----------------------------
910 The check-tcg tests are intended for simple smoke tests of both
911 linux-user and softmmu TCG functionality. However to build test
916 apt install gcc-aarch64-linux-gnu
923 $(configure) --cross-cc-aarch64=aarch64-cc
925 There is also a ``--cross-cc-cflags-ARCH`` flag in case additional
931 use the same container to build tests. However there are a number of
932 additional containers defined that have a minimal cross-build
938 See :ref:`container-ref` for more details.
945 make build-tcg-tests-$TARGET
949 make run-tcg-tests-$TARGET
962 make run-plugin-test-mmap-with-libinline.so
965 gdbstub tests also re-use the test binaries but while exercising gdb.
971 either totally bare with minimal gcc lib support (for system-mode tests)
972 or just glibc (for linux-user tests). This is because getting a cross
976 ---------------
978 There are a number of out-of-tree test suites that are used for more
989 https://git.kernel.org/pub/scm/virt/kvm/kvm-unit-tests.git
997 to run to exercise QEMU's linux-user code::
999 https://linux-test-project.github.io/
1002 ----------------
1006 ``--enable-gcov`` option and build. Then run the tests as usual.
1009 clean-gcda`` target can be used to delete any existing coverage
1013 coverage-html`` which will create
1014 ``meson-logs/coveragereport/index.html``.