Skip to content

Commit 615538f

Browse files
author
David Scott
committed
test: verify the failure message from 'xenvm lvcreate' looks nice
Signed-off-by: David Scott <[email protected]>
1 parent 18105a3 commit 615538f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/test.ml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ let gib = Int64.mul mib 1024L
102102
let tib = Int64.mul mib 1024L
103103
let xib = Int64.mul tib 1024L
104104

105+
let contains s1 s2 =
106+
let re = Str.regexp_string s2 in
107+
try
108+
ignore (Str.search_forward re s1 0);
109+
true
110+
with Not_found -> false
111+
105112
let lvcreate_toobig =
106113
"lvcreate -n <name> -l <too many>: check that we fail nicely" >::
107114
fun () ->
@@ -110,7 +117,17 @@ let lvcreate_toobig =
110117
(fun () -> Client.create "toobig" xib "unknown" 0L [])
111118
(function Xenvm_interface.Insufficient_free_space(needed, available) -> return ()
112119
| e -> failwith (Printf.sprintf "Did not get Insufficient_free_space: %s" (Printexc.to_string e)))
113-
)
120+
);
121+
try
122+
xenvm [ "lvcreate"; "-n"; "test"; "-l"; Int64.to_string xib; vg ] |> ignore_string;
123+
failwith "Did not get Insufficient_free_space"
124+
with
125+
| Bad_exit(5, _, _, stdout, stderr) ->
126+
let expected = "insufficient free space" in
127+
if not (contains stderr expected)
128+
then failwith (Printf.sprintf "stderr [%s] did not have expected string [%s]" stderr expected)
129+
| _ ->
130+
failwith "Expected exit code 5"
114131

115132
let file_exists filename =
116133
try

0 commit comments

Comments
 (0)