Skip to content

Commit 3f2f687

Browse files
authored
virtual_device: add graphics test for video devices test (#6400)
Expanded test coverage for video devices with graphics-aware scenarios, validating presence/absence of graphics and video devices. Signed-off-by: Lili Zhu <lizhu@redhat.com>
1 parent 02d8c2d commit 3f2f687

File tree

2 files changed

+47
-20
lines changed

2 files changed

+47
-20
lines changed

libvirt/tests/cfg/virtual_device/video_devices.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
- positive_test:
66
status_error = "no"
77
variants:
8+
- graphics_test:
9+
graphics_test = "yes"
10+
only no_primary_video
11+
only no_secondary_video
12+
video_device = "no"
13+
qemu_line = "-device.*id.*video"
14+
variants:
15+
- with_graphics:
16+
with_graphics = "yes"
17+
- no_graphics:
18+
with_graphics = "no"
819
- resolution_test:
920
no qxl
1021
resolution_test = "yes"
@@ -129,6 +140,8 @@
129140
no s390-virtio, aarch64
130141
primary_video_model = bochs
131142
only no_secondary_video..model_test.default no_secondary_video..vram..bochs_default_size
143+
- no_primary_video:
144+
only graphics_test
132145
- negative_test:
133146
status_error = "yes"
134147
variants:

libvirt/tests/src/virtual_device/video_devices.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def check_mem_test_cmd_line(model_type, mem_type, mem_size):
179179
cmdline = open('/proc/%s/cmdline' % vm.get_pid()).read().replace("\x00", " ")
180180
logging.debug("the cmdline is: %s" % cmdline)
181181

182+
pattern = ""
182183
if mem_type == "ram" or mem_type == "vram":
183184
cmd_mem_size = str(int(mem_size)*1024)
184185
pattern = r"-device.*qxl-vga.*%s_size\W{1,2}%s" % (mem_type, cmd_mem_size)
@@ -226,6 +227,9 @@ def up_round_to_power_of_two(num):
226227
resolution_test = params.get("resolution_test", "no") == "yes"
227228
resolution_x = params.get("resolution_x")
228229
resolution_y = params.get("resolution_y")
230+
graphics_test = params.get("graphics_test", "no") == "yes"
231+
with_graphics = params.get("with_graphics", "yes") == "yes"
232+
video_device = params.get("video_device", "yes") == "yes"
229233

230234
vm_xml = VMXML.new_from_dumpxml(vm_name)
231235
vm_xml_backup = vm_xml.copy()
@@ -238,31 +242,37 @@ def up_round_to_power_of_two(num):
238242

239243
try:
240244
vm_xml.remove_all_device_by_type('video')
241-
kwargs = {}
242-
model_type = primary_video_model
243-
is_primary = None
244-
if secondary_video_model:
245-
is_primary = True
246-
if heads_test and not default_primary_heads:
247-
kwargs["model_heads"] = primary_heads
248-
if mem_test and not default_mem_size:
249-
kwargs["model_" + mem_type] = mem_size
250-
if model_type == "virtio" and with_packed:
251-
kwargs["driver"] = {"packed": driver_packed}
252-
if resolution_test:
253-
kwargs["resolution"] = {"x": resolution_x, "y": resolution_y}
254-
add_video_device(model_type, vm_xml, is_primary, status_error, **kwargs)
255-
256-
if secondary_video_model:
245+
if graphics_test and not with_graphics:
246+
vm_xml.remove_all_device_by_type('graphics')
247+
248+
if video_device:
257249
kwargs = {}
258-
model_type = secondary_video_model
259-
is_primary = False
260-
if heads_test and not default_secondary_heads:
261-
kwargs["model_heads"] = secondary_heads
250+
model_type = primary_video_model
251+
is_primary = None
252+
if secondary_video_model:
253+
is_primary = True
254+
if heads_test and not default_primary_heads:
255+
kwargs["model_heads"] = primary_heads
256+
if mem_test and not default_mem_size:
257+
kwargs["model_" + mem_type] = mem_size
262258
if model_type == "virtio" and with_packed:
263259
kwargs["driver"] = {"packed": driver_packed}
260+
if resolution_test:
261+
kwargs["resolution"] = {"x": resolution_x, "y": resolution_y}
264262
add_video_device(model_type, vm_xml, is_primary, status_error, **kwargs)
265263

264+
if secondary_video_model:
265+
kwargs = {}
266+
model_type = secondary_video_model
267+
is_primary = False
268+
if heads_test and not default_secondary_heads:
269+
kwargs["model_heads"] = secondary_heads
270+
if model_type == "virtio" and with_packed:
271+
kwargs["driver"] = {"packed": driver_packed}
272+
add_video_device(model_type, vm_xml, is_primary, status_error, **kwargs)
273+
274+
vm_xml.sync()
275+
266276
if not status_error:
267277
res = virsh.start(vm_name)
268278

@@ -271,6 +281,10 @@ def up_round_to_power_of_two(num):
271281
"device xml. details: %s " % res)
272282
logging.debug("vm started successfully in positive cases.")
273283

284+
if graphics_test:
285+
libvirt.check_qemu_cmd_line(params.get("qemu_line"),
286+
expect_exist=with_graphics)
287+
274288
if resolution_test:
275289
libvirt.check_qemu_cmd_line(params.get("qemu_line"))
276290

0 commit comments

Comments
 (0)