Testing, gdbstub and doc tweaks:

- increase timeout on replay kernel acceptance test
   - fixes for binfmt_misc docker images
   - better gdb version detection
   - don't silently skip gdb tests
   - fix for gdbstub auxv handling
   - cleaner handling of check-tcg on tcg disabled builds
   - expand vexpress/versitile docs with examples
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEZoWumedRZ7yvyN81+9DbCVqeKkQFAmAhHIMACgkQ+9DbCVqe
 KkS/gwf+OeN1OxOqn7kdhOvbTx2k0XAxOEN/lC47xeVIpGBmC08jA7o/+mfy3aLK
 xCGYpK7LkW06KYEZ3r3ojxph5dbR16TcqououM0Z5YrQ0A/wuMX7E9l27Ndr209c
 jt67z/8ZSXwnA93bttFrqYwIcYqGdfdx/cQFi/hyWGZytBBbwM+OWPkwwiklUPSu
 AnmC/K4LowItr3yifu1E1ppgbLsVGu/xX2t/Et/7CTnYngMSr3Zb9ZhdgfTsBuZ3
 JzMw990VR0OuslTg8t+563lYvBboCqu6WbV3WIas7XT41JC97KygCj+IuyZjV039
 2DQ0t723o9B05UFFrZaJJFXs1Kb+/A==
 =4zok
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-gdbstub-docs-080221-1' into staging

Testing, gdbstub and doc tweaks:

  - increase timeout on replay kernel acceptance test
  - fixes for binfmt_misc docker images
  - better gdb version detection
  - don't silently skip gdb tests
  - fix for gdbstub auxv handling
  - cleaner handling of check-tcg on tcg disabled builds
  - expand vexpress/versitile docs with examples

# gpg: Signature made Mon 08 Feb 2021 11:12:03 GMT
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-testing-gdbstub-docs-080221-1:
  docs/system: document an example booting the versatilepb machine
  docs/system: document an example vexpress-a15 invocation
  tests/Makefile.include: don't use TARGET_DIRS for check-tcg
  scripts/mtest2make.py: export all-%s-targets variable and use it
  tests/tcg: Replace /bin/true by true (required on macOS)
  gdbstub: Fix handle_query_xfer_auxv
  tests/tcg: don't silently skip the gdb tests
  configure: bump the minimum gdb version for check-tcg to 9.1
  configure: make version_ge more tolerant of shady version input
  tests/docker: add a docker-exec-copy-test
  tests/docker: alias docker-help target for consistency
  tests/docker: preserve original name when copying libs
  tests/docker: make _copy_with_mkdir accept missing files
  tests/docker: Fix typo in help message
  tests/docker: Fix _get_so_libs() for docker-binfmt-image
  tests/acceptance: Increase the timeout in the replay tests

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-02-08 13:00:54 +00:00
commit 8eef07b4d3
13 changed files with 141 additions and 27 deletions

View File

@ -305,7 +305,7 @@ endif
@echo 'Test targets:' @echo 'Test targets:'
$(call print-help,check,Run all tests (check-help for details)) $(call print-help,check,Run all tests (check-help for details))
$(call print-help,bench,Run all benchmarks) $(call print-help,bench,Run all benchmarks)
$(call print-help,docker,Help about targets running tests inside containers) $(call print-help,docker-help,Help about targets running tests inside containers)
$(call print-help,vm-help,Help about targets running tests inside VM) $(call print-help,vm-help,Help about targets running tests inside VM)
@echo '' @echo ''
@echo 'Documentation targets:' @echo 'Documentation targets:'

6
configure vendored
View File

@ -198,8 +198,8 @@ has() {
} }
version_ge () { version_ge () {
local_ver1=`echo $1 | tr . ' '` local_ver1=$(expr "$1" : '\([0-9.]*\)' | tr . ' ')
local_ver2=`echo $2 | tr . ' '` local_ver2=$(echo "$2" | tr . ' ')
while true; do while true; do
set x $local_ver1 set x $local_ver1
local_first=${2-0} local_first=${2-0}
@ -6115,7 +6115,7 @@ fi
if test -n "$gdb_bin"; then if test -n "$gdb_bin"; then
gdb_version=$($gdb_bin --version | head -n 1) gdb_version=$($gdb_bin --version | head -n 1)
if version_ge ${gdb_version##* } 8.3.1; then if version_ge ${gdb_version##* } 9.1; then
echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak
fi fi
fi fi

View File

@ -27,3 +27,37 @@ The Arm Versatile baseboard is emulated with the following devices:
devices. devices.
- PL181 MultiMedia Card Interface with SD card. - PL181 MultiMedia Card Interface with SD card.
Booting a Linux kernel
----------------------
Building a current Linux kernel with ``versatile_defconfig`` should be
enough to get something running. Nowadays an out-of-tree build is
recommended (and also useful if you build a lot of different targets).
In the following example $BLD points to the build directory and $SRC
points to the root of the Linux source tree. You can drop $SRC if you
are running from there.
.. code-block:: bash
$ make O=$BLD -C $SRC ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- versatile_defconfig
$ make O=$BLD -C $SRC ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
You may want to enable some additional modules if you want to boot
something from the SCSI interface::
CONFIG_PCI=y
CONFIG_PCI_VERSATILE=y
CONFIG_SCSI=y
CONFIG_SCSI_SYM53C8XX_2=y
You can then boot with a command line like:
.. code-block:: bash
$ qemu-system-arm -machine type=versatilepb \
-serial mon:stdio \
-drive if=scsi,driver=file,filename=debian-buster-armel-rootfs.ext4 \
-kernel zImage \
-dtb versatile-pb.dtb \
-append "console=ttyAMA0 ro root=/dev/sda"

View File

@ -58,3 +58,31 @@ Other differences between the hardware and the QEMU model:
``vexpress-a15``, and have IRQs from 40 upwards. If a dtb is ``vexpress-a15``, and have IRQs from 40 upwards. If a dtb is
provided on the command line then QEMU will edit it to include provided on the command line then QEMU will edit it to include
suitable entries describing these transports for the guest. suitable entries describing these transports for the guest.
Booting a Linux kernel
----------------------
Building a current Linux kernel with ``multi_v7_defconfig`` should be
enough to get something running. Nowadays an out-of-tree build is
recommended (and also useful if you build a lot of different targets).
In the following example $BLD points to the build directory and $SRC
points to the root of the Linux source tree. You can drop $SRC if you
are running from there.
.. code-block:: bash
$ make O=$BLD -C $SRC ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- multi_v7_defconfig
$ make O=$BLD -C $SRC ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
By default you will want to boot your rootfs off the sdcard interface.
Your rootfs will need to be padded to the right size. With a suitable
DTB you could also add devices to the virtio-mmio bus.
.. code-block:: bash
$ qemu-system-arm -cpu cortex-a15 -smp 4 -m 4096 \
-machine type=vexpress-a15 -serial mon:stdio \
-drive if=sd,driver=file,filename=armel-rootfs.ext4 \
-kernel zImage \
-dtb vexpress-v2p-ca15-tc1.dtb \
-append "console=ttyAMA0 root=/dev/mmcblk0 ro"

View File

@ -2245,7 +2245,6 @@ static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
{ {
TaskState *ts; TaskState *ts;
unsigned long offset, len, saved_auxv, auxv_len; unsigned long offset, len, saved_auxv, auxv_len;
const char *mem;
if (gdb_ctx->num_params < 2) { if (gdb_ctx->num_params < 2) {
put_packet("E22"); put_packet("E22");
@ -2257,8 +2256,8 @@ static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
ts = gdbserver_state.c_cpu->opaque; ts = gdbserver_state.c_cpu->opaque;
saved_auxv = ts->info->saved_auxv; saved_auxv = ts->info->saved_auxv;
auxv_len = ts->info->auxv_len; auxv_len = ts->info->auxv_len;
mem = (const char *)(saved_auxv + offset);
if (offset > auxv_len) { if (offset >= auxv_len) {
put_packet("E00"); put_packet("E00");
return; return;
} }
@ -2269,12 +2268,20 @@ static void handle_query_xfer_auxv(GdbCmdContext *gdb_ctx, void *user_ctx)
if (len < auxv_len - offset) { if (len < auxv_len - offset) {
g_string_assign(gdbserver_state.str_buf, "m"); g_string_assign(gdbserver_state.str_buf, "m");
memtox(gdbserver_state.str_buf, mem, len);
} else { } else {
g_string_assign(gdbserver_state.str_buf, "l"); g_string_assign(gdbserver_state.str_buf, "l");
memtox(gdbserver_state.str_buf, mem, auxv_len - offset); len = auxv_len - offset;
} }
g_byte_array_set_size(gdbserver_state.mem_buf, len);
if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset,
gdbserver_state.mem_buf->data, len, false)) {
put_packet("E14");
return;
}
memtox(gdbserver_state.str_buf,
(const char *)gdbserver_state.mem_buf->data, len);
put_packet_binary(gdbserver_state.str_buf->str, put_packet_binary(gdbserver_state.str_buf->str,
gdbserver_state.str_buf->len, true); gdbserver_state.str_buf->len, true);
} }

View File

@ -110,6 +110,7 @@ def emit_suite(name, suite, prefix):
print('ifneq ($(filter %s %s, $(MAKECMDGOALS)),)' % (target, prefix)) print('ifneq ($(filter %s %s, $(MAKECMDGOALS)),)' % (target, prefix))
print('.tests += $(.test.$(SPEED).%s)' % (target, )) print('.tests += $(.test.$(SPEED).%s)' % (target, ))
print('endif') print('endif')
print('all-%s-targets += %s' % (prefix, target))
targets = {t['id']: [os.path.relpath(f) for f in t['filename']] targets = {t['id']: [os.path.relpath(f) for f in t['filename']]
for t in introspect['targets']} for t in introspect['targets']}

View File

@ -12,7 +12,7 @@ check-help:
@echo " $(MAKE) check-speed Run qobject speed tests" @echo " $(MAKE) check-speed Run qobject speed tests"
@echo " $(MAKE) check-qapi-schema Run QAPI schema tests" @echo " $(MAKE) check-qapi-schema Run QAPI schema tests"
@echo " $(MAKE) check-block Run block tests" @echo " $(MAKE) check-block Run block tests"
ifeq ($(CONFIG_TCG),y) ifneq ($(filter $(all-check-targets), check-softfloat),)
@echo " $(MAKE) check-tcg Run TCG tests" @echo " $(MAKE) check-tcg Run TCG tests"
@echo " $(MAKE) check-softfloat Run FPU emulation tests" @echo " $(MAKE) check-softfloat Run FPU emulation tests"
endif endif
@ -40,11 +40,13 @@ SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
SPEED = quick SPEED = quick
# Per guest TCG tests # Build up our target list from the filtered list of ninja targets
TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets)))
BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS)) # Per guest TCG tests
CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS)) BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGETS))
RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS)) CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGETS))
RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGETS))
# Probe for the Docker Builds needed for each build # Probe for the Docker Builds needed for each build
$(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(foreach PROBE_TARGET,$(TARGET_DIRS), \

View File

@ -31,7 +31,7 @@ class ReplayKernelBase(LinuxKernelTest):
terminates. terminates.
""" """
timeout = 90 timeout = 120
KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 ' KERNEL_COMMON_COMMAND_LINE = 'printk.time=1 panic=-1 '
def run_vm(self, kernel_path, kernel_command_line, console_pattern, def run_vm(self, kernel_path, kernel_command_line, console_pattern,

View File

@ -1,6 +1,6 @@
# Makefile for Docker tests # Makefile for Docker tests
.PHONY: docker docker-test docker-clean docker-image docker-qemu-src .PHONY: docker docker-help docker-test docker-clean docker-image docker-qemu-src
NULL := NULL :=
SPACE := $(NULL) # SPACE := $(NULL) #
@ -11,7 +11,7 @@ HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
DOCKER_SUFFIX := .docker DOCKER_SUFFIX := .docker
DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
# we don't run tests on intermediate images (used as base by another image) # we don't run tests on intermediate images (used as base by another image)
DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap empty
DOCKER_IMAGES := $(sort $(notdir $(basename $(wildcard $(DOCKER_FILES_DIR)/*.docker)))) DOCKER_IMAGES := $(sort $(notdir $(basename $(wildcard $(DOCKER_FILES_DIR)/*.docker))))
DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES)) DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES))
# Use a global constant ccache directory to speed up repetitive builds # Use a global constant ccache directory to speed up repetitive builds
@ -92,6 +92,24 @@ docker-binfmt-image-debian-%: $(DOCKER_FILES_DIR)/debian-bootstrap.docker
{ echo "You will need to build $(EXECUTABLE)"; exit 1;},\ { echo "You will need to build $(EXECUTABLE)"; exit 1;},\
"CHECK", "debian-$* exists")) "CHECK", "debian-$* exists"))
# These are test targets
USER_TCG_TARGETS=$(patsubst %-linux-user,qemu-%,$(filter %-linux-user,$(TARGET_DIRS)))
EXEC_COPY_TESTS=$(patsubst %,docker-exec-copy-test-%, $(USER_TCG_TARGETS))
$(EXEC_COPY_TESTS): docker-exec-copy-test-%: $(DOCKER_FILES_DIR)/empty.docker
$(call quiet-command, \
$(DOCKER_SCRIPT) build -t qemu/exec-copy-test-$* -f $< \
$(if $V,,--quiet) --no-cache \
--include-executable=$* \
--skip-binfmt, \
"TEST","copy $* to container")
$(call quiet-command, \
$(DOCKER_SCRIPT) run qemu/exec-copy-test-$* \
/$* -version > tests/docker-exec-copy-test-$*.out, \
"TEST","check $* works in container")
docker-exec-copy-test: $(EXEC_COPY_TESTS)
endif endif
# Enforce dependencies for composite images # Enforce dependencies for composite images
@ -209,7 +227,7 @@ endif
@echo ' before running the command.' @echo ' before running the command.'
@echo ' NETWORK=1 Enable virtual network interface with default backend.' @echo ' NETWORK=1 Enable virtual network interface with default backend.'
@echo ' NETWORK=$$BACKEND Enable virtual network interface with $$BACKEND.' @echo ' NETWORK=$$BACKEND Enable virtual network interface with $$BACKEND.'
@echo ' NOUSER Define to disable adding current user to containers passwd.' @echo ' NOUSER=1 Define to disable adding current user to containers passwd.'
@echo ' NOCACHE=1 Ignore cache when build images.' @echo ' NOCACHE=1 Ignore cache when build images.'
@echo ' EXECUTABLE=<path> Include executable in image.' @echo ' EXECUTABLE=<path> Include executable in image.'
@echo ' EXTRA_FILES="<path> [... <path>]"' @echo ' EXTRA_FILES="<path> [... <path>]"'
@ -218,6 +236,8 @@ endif
@echo ' Specify which container engine to run.' @echo ' Specify which container engine to run.'
@echo ' REGISTRY=url Cache builds from registry (default:$(DOCKER_REGISTRY))' @echo ' REGISTRY=url Cache builds from registry (default:$(DOCKER_REGISTRY))'
docker-help: docker
# This rule if for directly running against an arbitrary docker target. # This rule if for directly running against an arbitrary docker target.
# It is called by the expanded docker targets (e.g. make # It is called by the expanded docker targets (e.g. make
# docker-test-foo@bar) which will do additional verification. # docker-test-foo@bar) which will do additional verification.

View File

@ -93,7 +93,7 @@ def _guess_engine_command():
commands_txt) commands_txt)
def _copy_with_mkdir(src, root_dir, sub_path='.'): def _copy_with_mkdir(src, root_dir, sub_path='.', name=None):
"""Copy src into root_dir, creating sub_path as needed.""" """Copy src into root_dir, creating sub_path as needed."""
dest_dir = os.path.normpath("%s/%s" % (root_dir, sub_path)) dest_dir = os.path.normpath("%s/%s" % (root_dir, sub_path))
try: try:
@ -102,8 +102,13 @@ def _copy_with_mkdir(src, root_dir, sub_path='.'):
# we can safely ignore already created directories # we can safely ignore already created directories
pass pass
dest_file = "%s/%s" % (dest_dir, os.path.basename(src)) dest_file = "%s/%s" % (dest_dir, name if name else os.path.basename(src))
copy(src, dest_file)
try:
copy(src, dest_file)
except FileNotFoundError:
print("Couldn't copy %s to %s" % (src, dest_file))
pass
def _get_so_libs(executable): def _get_so_libs(executable):
@ -120,7 +125,7 @@ def _get_so_libs(executable):
search = ldd_re.search(line) search = ldd_re.search(line)
if search: if search:
try: try:
libs.append(s.group(1)) libs.append(search.group(1))
except IndexError: except IndexError:
pass pass
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@ -150,8 +155,9 @@ def _copy_binary_with_libs(src, bin_dest, dest_dir):
if libs: if libs:
for l in libs: for l in libs:
so_path = os.path.dirname(l) so_path = os.path.dirname(l)
name = os.path.basename(l)
real_l = os.path.realpath(l) real_l = os.path.realpath(l)
_copy_with_mkdir(real_l, dest_dir, so_path) _copy_with_mkdir(real_l, dest_dir, so_path, name)
def _check_binfmt_misc(executable): def _check_binfmt_misc(executable):
@ -432,6 +438,9 @@ class BuildCommand(SubCommand):
help="""Specify a binary that will be copied to the help="""Specify a binary that will be copied to the
container together with all its dependent container together with all its dependent
libraries""") libraries""")
parser.add_argument("--skip-binfmt",
action="store_true",
help="""Skip binfmt entry check (used for testing)""")
parser.add_argument("--extra-files", nargs='*', parser.add_argument("--extra-files", nargs='*',
help="""Specify files that will be copied in the help="""Specify files that will be copied in the
Docker image, fulfilling the ADD directive from the Docker image, fulfilling the ADD directive from the
@ -460,7 +469,9 @@ class BuildCommand(SubCommand):
docker_dir = tempfile.mkdtemp(prefix="docker_build") docker_dir = tempfile.mkdtemp(prefix="docker_build")
# Validate binfmt_misc will work # Validate binfmt_misc will work
if args.include_executable: if args.skip_binfmt:
qpath = args.include_executable
elif args.include_executable:
qpath, enabled = _check_binfmt_misc(args.include_executable) qpath, enabled = _check_binfmt_misc(args.include_executable)
if not enabled: if not enabled:
return 1 return 1

View File

@ -0,0 +1,8 @@
#
# Empty Dockerfile
#
FROM scratch
# Add everything from the context into the container
ADD . /

View File

@ -90,11 +90,11 @@ run-guest-tests: guest-tests
else else
guest-tests: guest-tests:
$(call quiet-command, /bin/true, "BUILD", \ $(call quiet-command, true, "BUILD", \
"$(TARGET) guest-tests SKIPPED") "$(TARGET) guest-tests SKIPPED")
run-guest-tests: run-guest-tests:
$(call quiet-command, /bin/true, "RUN", \ $(call quiet-command, true, "RUN", \
"tests for $(TARGET) SKIPPED") "tests for $(TARGET) SKIPPED")
endif endif

View File

@ -63,8 +63,11 @@ run-gdbstub-qxfer-auxv-read: sha1
--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
"basic gdbstub qXfer:auxv:read support") "basic gdbstub qXfer:auxv:read support")
EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read else
run-gdbstub-%:
$(call skip-test, "gdbstub test $*", "need working gdb")
endif endif
EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read
# Update TESTS # Update TESTS