@@ -96,6 +96,62 @@ let lvcreate_percent =
9696 assert_equal ~printer: Int64. to_string 0L free;
9797 xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
9898
99+ let kib = 1024L
100+ let mib = Int64. mul kib 1024L
101+ let gib = Int64. mul mib 1024L
102+ let tib = Int64. mul mib 1024L
103+ let xib = Int64. mul tib 1024L
104+
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+
112+ let lvcreate_toobig =
113+ " lvcreate -n <name> -l <too many>: check that we fail nicely" > ::
114+ fun () ->
115+ Lwt_main. run (
116+ Lwt. catch
117+ (fun () -> Client. create " toobig" xib " unknown" 0L [] )
118+ (function Xenvm_interface. Insufficient_free_space (needed , available ) -> return ()
119+ | e -> failwith (Printf. sprintf " Did not get Insufficient_free_space: %s" (Printexc. to_string e)))
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"
131+
132+ let lvextend_toobig =
133+ " lvextend packer-virtualbox-iso-vg/swap_1 -L 1T: check that the failure is nice" > ::
134+ fun () ->
135+ xenvm [ " lvcreate" ; " -n" ; " test" ; " -l" ; " 100%F" ; vg ] |> ignore_string;
136+ begin
137+ Lwt_main. run (
138+ Lwt. catch
139+ (fun () -> Client. resize " test" xib)
140+ (function Xenvm_interface. Insufficient_free_space (needed , available ) -> return ()
141+ | e -> failwith (Printf. sprintf " Did not get Insufficient_free_space: %s" (Printexc. to_string e)))
142+ );
143+ try
144+ xenvm [ " lvextend" ; vg ^ " /test" ; " -L" ; Int64. to_string xib ] |> ignore_string;
145+ failwith " Did not get Insufficient_free_space"
146+ with
147+ | Bad_exit (5 , _ , _ , stdout , stderr ) ->
148+ let expected = " Insufficient free space" in
149+ if not (contains stderr expected)
150+ then failwith (Printf. sprintf " stderr [%s] did not have expected string [%s]" stderr expected)
151+ | e ->
152+ failwith (Printf. sprintf " Expected exit code 5: %s" (Printexc. to_string e))
153+ end ;
154+ xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
99155
100156let file_exists filename =
101157 try
@@ -154,7 +210,9 @@ let xenvmd_suite = "Commands which require xenvmd" >::: [
154210 lvcreate_L;
155211 lvcreate_l;
156212 lvcreate_percent;
213+ lvcreate_toobig;
157214 lvchange_n;
215+ lvextend_toobig;
158216 vgs_online;
159217]
160218
0 commit comments