The necessary parameters for running Python tests on qemu are tedious to find.
The patch adds a complete example for running the Python tests for qemu-x86_defconfig on an X86 system. Cc: Stephen Warren <swar...@nvidia.com> Signed-off-by: Heinrich Schuchardt <xypron.g...@gmx.de> --- v3 Move the example into the correct section. Consider comments by Stephen. v2 Include all necessary information to run tests for qemu-x86_defconfig in a separate chapter. --- test/py/README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/test/py/README.md b/test/py/README.md index 829c7efbb2..80e26a3460 100644 --- a/test/py/README.md +++ b/test/py/README.md @@ -330,6 +330,87 @@ CROSS_COMPILE=arm-none-eabi- \ ./test/py/test.py --bd seaboard --build ``` +#### Running tests for qemu-x86\_defconfig on an x86 system + +We build u-boot.rom with + + export BUILD_ROM=y + make mrproper + make qemu-x86_defconfig + make + +We create directories `$HOME/ubtest/bin` and `$HOME/ubtest/py` for the script +files below and `../tftp` for the tftp server. + +We copy helloworld.efi to the tftp directory. + + cp lib/efi_loader/helloworld.efi ../tftp/ + +This file is used by the test\_efi\_loader.py test case. + +In the `$HOME/ubtest/bin` directory we create: + +File `u-boot-test-console` chmod 755 + + #!/bin/sh + touch /tmp/u-boot-monitor-socket + exec qemu-system-x86_64 -bios u-boot.rom -nographic -netdev \ + user,id=eth0,tftp=../tftp,net=192.168.76.0/24,dhcpstart=192.168.76.9 \ + -device e1000,netdev=eth0 -machine pc-i440fx-2.8 \ + -monitor unix:/tmp/u-boot-monitor-socket,server,nowait + +This script is executed when the tests commence. It starts qemu with a network +and a tftp server enabled. The control console is directed to the Unix socket +`/tmp/u-boot-monitor-socket`. + +File `u-boot-test-flash` chmod 755 + + #!/bin/sh + echo ... u-boot-test-flash ... + +This script serves to initialize the board. Nothing needs to be done here as we +pass u-boot.rom as a parameter in `u-boot-test-console`. + +File `u-boot-test-quit` chmod 755 + + #!/bin/sh + echo quit | socat - UNIX-CONNECT:/tmp/u-boot-monitor-socket + +This script is called when all tests are completed. The `quit` command is +passed to the qemu control console to terminate the qemu session. + +File `u-boot-test-reset` chmod 755 + + #!/bin/sh + echo system_reset | socat - UNIX-CONNECT:/tmp/u-boot-monitor-socket + true + +This script is called when a board reset is needed. The `system_reset` command +is passed to the qemu control console to reboot the qemu instance. The script +has to return true or the tests will fail. + +In the `$HOME/ubtest/py` directory we create file `u_boot_boardenv_qemu_x86.py` + + env__net_dhcp_server = True + env__efi_loader_helloworld_file = { + "fn": "helloworld.efi", + "size": 4298, + "crc32": "55d96ef8", + } + +The parameter `env__net_dhcp_server` enables the network tests. The parameter +`env__efi_loader_helloworld_file` is needed to make the file `helloworld.efi` +available which is loaded from the tftp server in `test_efi_loader.py`. + +The fields size and crc32 have to be updated to match the actual values. The +`crc32` command can be used to determine the latter. + +We now can run the Python tests with + + export PATH=$HOME/ubtest/bin:/usr/bin:/bin + export PYTHONPATH=$HOME/ubtest/py + ./test/py/test.py --bd=qemu-x86 --build-dir=. + ## Writing tests Please refer to the pytest documentation for details of writing pytest tests. -- 2.11.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot