]> git.proxmox.com Git - qemu-server.git/blame - test/run_pci_addr_checks.pl
cfg2cmd test: hostpci, also specify exact PCIe devices
[qemu-server.git] / test / run_pci_addr_checks.pl
CommitLineData
d7d698f6
TL
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use experimental 'smartmatch';
6
7use lib qw(..);
8
9use Test::More;
10
11use PVE::QemuServer::PCI;
12
13print "testing PCI(e) address conflicts\n";
14
15# exec tests
16
17#FIXME: make cross PCI <-> PCIe check sense at all??
18my $addr_map = {};
19my ($fail, $ignored) = (0, 0);
20sub check_conflict {
21 my ($id, $what) = @_;
22
23 my ($bus, $addr) = $what->@{qw(bus addr)};
24 my $full_addr = "$bus:$addr";
25
26 if (defined(my $conflict = $addr_map->{$full_addr})) {
27 if (my @ignores = $what->{conflict_ok}) {
28 if ($conflict ~~ @ignores) {
29 note("OK: ignore conflict for '$full_addr' between '$id' and '$conflict'");
30 $ignored++;
31 return;
32 }
33 }
34 note("ERR: conflict for '$full_addr' between '$id' and '$conflict'");
35 $fail++;
36 } else {
37 $addr_map->{$full_addr} = $id;
38 }
39}
40
41
42my $pci_map = PVE::QemuServer::PCI::get_pci_addr_map();
43while (my ($id, $what) = each %$pci_map) {
44 check_conflict($id, $what);
45}
46
47my $pcie_map = PVE::QemuServer::PCI::get_pcie_addr_map();
48while (my ($id, $what) = each %$pcie_map) {
49 check_conflict($id, $what);
50}
51
52if ($fail) {
53 fail("PCI(e) address conflict check, ignored: $ignored, conflicts: $fail");
54} else {
55 pass("PCI(e) address conflict check, ignored: $ignored");
56}
57
58done_testing();