Skip to content

Commit 8a8f2ad

Browse files
simonjbeaumontjohnelse
authored andcommitted
Use mock pci.ids databse for testing
Signed-off-by: Si Beaumont <[email protected]> Imported-by: John Else <[email protected]> Conflicts: ocaml/test/test_pci_helpers.ml
1 parent 4131b1a commit 8a8f2ad

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

ocaml/test/test_pci_helpers.ml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let get_cached_pci_db () =
4343
match !pci_db_cache with
4444
| Some pci_db -> pci_db
4545
| None ->
46-
let pci_db = Pci_db.of_file Pci_db.base_pci_ids_path in
46+
let pci_db = Pci_db.of_file "ocaml/test/data/base-pci.ids" in
4747
pci_db_cache := Some pci_db;
4848
pci_db
4949

@@ -73,54 +73,54 @@ module ParseLspciLine = Generic.Make(struct
7373
(* n.b. these tests might start failing if the copy of pci.ids in the chroot
7474
* changes. *)
7575
let tests = [
76-
(* Test that a display device present in pci.ids and with subdevice and
76+
(* Test that a device present in pci.ids and with subdevice and
7777
* subvendor IDs can be parsed. *)
78-
"0000:44:00.0 \"0300\" \"10de\" \"014e\" -ra1 \"10de\" \"100a\"",
78+
"0000:44:00.0 \"0001\" \"0003\" \"0001\" -ra1 \"0001\" \"0002\"",
7979
Xapi_pci_helpers.({
8080
id = "0000:44:00.0";
81-
vendor_id = 0x10deL;
82-
vendor_name = "NVIDIA Corporation";
83-
device_id = 0x014eL;
84-
device_name = "NV43GL [Quadro FX 540]";
85-
class_id = 0x03L;
86-
class_name = "Display controller";
81+
vendor_id = 0x0003L;
82+
vendor_name = "SimpleVendorName3";
83+
device_id = 0x0001L;
84+
device_name = "SimpleDeviceName-3-1";
85+
class_id = 0x00L;
86+
class_name = "Class Name";
8787
related = []
8888
});
89-
(* Test that a display device present in pci.ids without subdevice or
89+
(* Test that a device present in pci.ids without subdevice or
9090
* subvendor IDs can be parsed. *)
91-
"0000:44:00.0 \"0300\" \"10de\" \"014e\" -ra1 \"\" \"\"",
91+
"0000:45:00.0 \"0001\" \"0003\" \"0001\" -ra1 \"\" \"\"",
9292
Xapi_pci_helpers.({
93-
id = "0000:44:00.0";
94-
vendor_id = 0x10deL;
95-
vendor_name = "NVIDIA Corporation";
96-
device_id = 0x014eL;
97-
device_name = "NV43GL [Quadro FX 540]";
98-
class_id = 0x03L;
99-
class_name = "Display controller";
93+
id = "0000:45:00.0";
94+
vendor_id = 0x0003L;
95+
vendor_name = "SimpleVendorName3";
96+
device_id = 0x0001L;
97+
device_name = "SimpleDeviceName-3-1";
98+
class_id = 0x00L;
99+
class_name = "Class Name";
100100
related = []
101101
});
102-
(* Test that a display device not preset in pci.ids can be parsed. *)
103-
"0000:44:00.0 \"0300\" \"0055\" \"abcd\" -ra1 \"\" \"\"",
102+
(* Test that a device not preset in pci.ids can be parsed. *)
103+
"0000:46:00.0 \"0001\" \"0055\" \"abcd\" -ra1 \"\" \"\"",
104104
Xapi_pci_helpers.({
105-
id = "0000:44:00.0";
105+
id = "0000:46:00.0";
106106
vendor_id = 0x0055L;
107107
vendor_name = "Unknown (0055)";
108108
device_id = 0xabcdL;
109109
device_name = "Unknown (abcd)";
110-
class_id = 0x03L;
111-
class_name = "Display controller";
110+
class_id = 0x00L;
111+
class_name = "Class Name";
112112
related = [];
113113
});
114114
(* Test that an unknown device from a known vendor can be parsed. *)
115-
"0000:44:00.0 \"0300\" \"10de\" \"abcd\" -ra1 \"\" \"\"",
115+
"0000:47:00.0 \"0001\" \"0003\" \"abcd\" -ra1 \"\" \"\"",
116116
Xapi_pci_helpers.({
117-
id = "0000:44:00.0";
118-
vendor_id = 0x10deL;
119-
vendor_name = "NVIDIA Corporation";
117+
id = "0000:47:00.0";
118+
vendor_id = 0x0003L;
119+
vendor_name = "SimpleVendorName3";
120120
device_id = 0xabcdL;
121121
device_name = "Unknown (abcd)";
122-
class_id = 0x03L;
123-
class_name = "Display controller";
122+
class_id = 0x00L;
123+
class_name = "Class Name";
124124
related = [];
125125
});
126126
]

0 commit comments

Comments
 (0)