Skip to content

Commit

Permalink
CA-397268: Add unit test for valid_device
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Lu <[email protected]>
  • Loading branch information
minglumlu authored and lindig committed Aug 14, 2024
1 parent ce24e0a commit d04ba27
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ocaml/tests/test_xapi_vbd_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,40 @@ let test_ca253933_valid_operations () =
in
List.iter operation_is_valid valid_operations

let test_valid_device () =
let valid_devices =
[
("autodetect", `Floppy)
; ("sda", `Disk)
; ("sda0", `Disk)
; ("sdp", `Disk)
; ("sdp99", `Disk)
; ("xvda", `Disk)
; ("xvda0", `Disk)
; ("xvdp", `Disk)
; ("xvdp99", `Disk)
; ("hda", `Disk)
; ("hda0", `Disk)
; ("hdp", `Disk)
; ("hdp99", `Disk)
; ("fda", `Disk)
; ("fdb", `Disk)
; ("0", `CD)
; ("1", `CD)
]
in
let check (dev, _type) =
let f = Xapi_vbd_helpers.valid_device in
Alcotest.(check bool) "must be equal" true (f dev ~_type)
in
List.iter check valid_devices

let test =
[
( "test_ca253933_invalid_operations"
, `Quick
, test_ca253933_invalid_operations
)
; ("test_ca253933_valid_operations", `Quick, test_ca253933_valid_operations)
; ("test_valid_device", `Quick, test_valid_device)
]

0 comments on commit d04ba27

Please sign in to comment.