tests/tcg: extend SSE tests to AVX
[qemu.git] / tests / vm / Makefile.include
blob2cc2203d0916f693be5034502a50460ba64685b9
1 # Makefile for VM tests
3 # Hack to allow running in an unconfigured build tree
4 ifeq ($(wildcard $(SRC_PATH)/config-host.mak),)
5 VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3
6 VM_VENV =
7 HOST_ARCH := $(shell uname -m)
8 else
9 VM_PYTHON = $(TESTS_PYTHON)
10 VM_VENV = check-venv
11 HOST_ARCH = $(ARCH)
12 endif
14 .PHONY: vm-build-all vm-clean-all
16 EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)
18 X86_IMAGES := freebsd netbsd openbsd haiku.x86_64
19 ifneq ($(GENISOIMAGE),)
20 X86_IMAGES += centos
21 ifneq ($(EFI_AARCH64),)
22 ARM64_IMAGES += ubuntu.aarch64 centos.aarch64
23 endif
24 endif
26 ifeq ($(HOST_ARCH),x86_64)
27 IMAGES=$(X86_IMAGES) $(if $(USE_TCG),$(ARM64_IMAGES))
28 else ifeq ($(HOST_ARCH),aarch64)
29 IMAGES=$(ARM64_IMAGES) $(if $(USE_TCG),$(X86_IMAGES))
30 endif
32 IMAGES_DIR := $(HOME)/.cache/qemu-vm/images
33 IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
35 .PRECIOUS: $(IMAGE_FILES)
37 ifneq ($(PYTHON),)
38 HAVE_PYTHON_YAML = $(shell $(PYTHON) -c "import yaml" 2> /dev/null && echo yes)
39 endif
41 # 'vm-help' target was historically named 'vm-test'
42 vm-help vm-test:
43         @echo "vm-help: Test QEMU in preconfigured virtual machines"
44         @echo
45         @echo "  vm-build-freebsd                - Build QEMU in FreeBSD VM"
46         @echo "  vm-build-netbsd                 - Build QEMU in NetBSD VM"
47         @echo "  vm-build-openbsd                - Build QEMU in OpenBSD VM"
48 ifneq ($(GENISOIMAGE),)
49         @echo "  vm-build-centos                 - Build QEMU in CentOS VM, with Docker"
50 ifneq ($(EFI_AARCH64),)
51         @echo "  vm-build-ubuntu.aarch64         - Build QEMU in ubuntu aarch64 VM"
52         @echo "  vm-build-centos.aarch64         - Build QEMU in CentOS aarch64 VM"
53 else
54         @echo "  (to build centos/ubuntu aarch64 images use configure --efi-aarch64)"
55 endif
56 else
57         @echo "  (install genisoimage to build centos/ubuntu images)"
58 endif
59         @echo "  vm-build-haiku.x86_64           - Build QEMU in Haiku VM"
60         @echo ""
61         @echo "  vm-build-all                    - Build QEMU in: $(IMAGES)"
62         @echo "  vm-clean-all                    - Clean up VM images"
63         @echo
64         @echo "For trouble-shooting:"
65         @echo "  vm-boot-serial-<guest>          - Boot guest, serial console on stdio"
66         @echo "  vm-boot-ssh-<guest>             - Boot guest and login via ssh"
67         @echo
68         @echo "Special variables:"
69         @echo "    BUILD_TARGET=foo              - Override the build target"
70         @echo "    DEBUG=1                       - Enable verbose output on host and interactive debugging"
71         @echo '    EXTRA_CONFIGURE_OPTS="..."   - Pass to configure step'
72         @echo "    J=[0..9]*                     - Override the -jN parameter for make commands"
73         @echo "    LOG_CONSOLE=1                 - Log console to file in: ~/.cache/qemu-vm "
74         @echo "    USE_TCG=1                     - Use TCG for cross-arch images"
75         @echo "    QEMU=/path/to/qemu            - Change path to QEMU binary"
76 ifeq ($(HAVE_PYTHON_YAML),yes)
77         @echo "    QEMU_CONFIG=/path/conf.yml   - Change path to VM configuration .yml file."
78 else
79         @echo "    (install python3-yaml to enable support for yaml file to configure a VM.)"
80 endif
81         @echo "                                   See conf_example_*.yml for file format details."
82         @echo "    QEMU_IMG=/path/to/qemu-img    - Change path to qemu-img tool"
83         @echo "    QEMU_LOCAL=1                 - Use QEMU binary local to this build."
84         @echo "    TARGET_LIST=a,b,c             - Override target list in builds"
85         @echo "    V=1                           - Enable verbose ouput on host and guest commands"
87 vm-build-all: $(addprefix vm-build-, $(IMAGES))
89 vm-clean-all:
90         rm -f $(IMAGE_FILES)
92 $(IMAGES_DIR)/%.img:    $(SRC_PATH)/tests/vm/% \
93                         $(SRC_PATH)/tests/vm/basevm.py \
94                         $(SRC_PATH)/tests/vm/Makefile.include \
95                         $(VM_VENV)
96         @mkdir -p $(IMAGES_DIR)
97         $(call quiet-command, \
98                 $(VM_PYTHON) $< \
99                 $(if $(V)$(DEBUG), --debug) \
100                 $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \
101                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
102                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
103                 $(if $(LOG_CONSOLE),--log-console) \
104                 --source-path $(SRC_PATH) \
105                 --image "$@" \
106                 --force \
107                 --build-image $@, \
108                 "  VM-IMAGE $*")
110 # Build in VM $(IMAGE)
111 vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV)
112         $(call quiet-command, \
113                 $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \
114                 $(if $(V)$(DEBUG), --debug) \
115                 $(if $(DEBUG), --interactive) \
116                 $(if $(J),--jobs $(J)) \
117                 $(if $(V),--verbose) \
118                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
119                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
120                 $(if $(LOG_CONSOLE),--log-console) \
121                 --image "$<" \
122                 $(if $(BUILD_TARGET),--build-target $(BUILD_TARGET)) \
123                 --snapshot \
124                 --build-qemu $(SRC_PATH) -- \
125                 $(if $(TARGET_LIST),--target-list=$(TARGET_LIST)) \
126                 $(if $(EXTRA_CONFIGURE_OPTS),$(EXTRA_CONFIGURE_OPTS)), \
127                 "  VM-BUILD $*")
129 vm-boot-serial-%: $(IMAGES_DIR)/%.img
130         qemu-system-x86_64 -enable-kvm -m 4G -smp 2 -nographic \
131                 -drive if=none,id=vblk,cache=writeback,file="$<" \
132                 -netdev user,id=vnet \
133                 -device virtio-blk-pci,drive=vblk \
134                 -device virtio-net-pci,netdev=vnet \
135         || true
137 vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV)
138         $(call quiet-command, \
139                 $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \
140                 $(if $(J),--jobs $(J)) \
141                 $(if $(V)$(DEBUG), --debug) \
142                 $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
143                 $(if $(EFI_AARCH64),--efi-aarch64 $(EFI_AARCH64)) \
144                 $(if $(LOG_CONSOLE),--log-console) \
145                 --image "$<" \
146                 --interactive \
147                 false, \
148                 "  VM-BOOT-SSH $*") || true