Generate test-prep.sh using the generator, so the prepared disk types
tested are the same as the ones configured in prepopts.ml.
---
.gitignore | 1 +
fish/test-prep.sh | 35 -----------------------------------
generator/fish.ml | 33 +++++++++++++++++++++++++++++++++
generator/fish.mli | 1 +
generator/main.ml | 1 +
5 files changed, 36 insertions(+), 35 deletions(-)
delete mode 100755 fish/test-prep.sh
diff --git a/.gitignore b/.gitignore
index a6be0f0..285b28d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -206,6 +206,7 @@ Makefile.in
/fish/stamp-virt-copy-out.pod
/fish/stamp-virt-tar-in.pod
/fish/stamp-virt-tar-out.pod
+/fish/test-prep.sh
/fish/virt-copy-in.1
/fish/virt-copy-out.1
/fish/virt-tar-in.1
diff --git a/fish/test-prep.sh b/fish/test-prep.sh
deleted file mode 100755
index e2b972a..0000000
--- a/fish/test-prep.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash -
-# libguestfs
-# Copyright (C) 2012 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-set -e
-
-rm -f prep*.img
-
-# It would be nice if we could keep this automatically in sync
-# with the prepared disk types. XXX
-$VG guestfish \
- -N prep1.img=disk \
- -N prep2.img=part \
- -N prep3.img=fs \
- -N prep4.img=lv:/dev/VG1/LV \
- -N prep5.img=lvfs:/dev/VG2/LV \
- -N prep6.img=bootroot \
- -N prep7.img=bootrootlv:/dev/VG3/LV \
- exit
-
-rm prep*.img
diff --git a/generator/fish.ml b/generator/fish.ml
index 646674d..980f55f 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -1106,3 +1106,36 @@ event_bitmask_of_event_set (const char *arg, uint64_t *eventset_r)
return 0;
}
"
+
+and generate_fish_test_prep_sh () =
+ pr "#!/bin/bash -\n";
+ generate_header HashStyle GPLv2plus;
+
+ let all_disks = sprintf "prep{1..%d}.img" (List.length prepopts) in
+
+ pr "\
+set -e
+
+rm -f %s
+
+$VG guestfish \\
+" all_disks;
+
+ let vg_count = ref 0 in
+
+ iteri (
+ fun i (name, _, _, _) ->
+ let params = [name] in
+ let params =
+ if find name "lv" <> -1 then (
+ incr vg_count;
+ sprintf "/dev/VG%d/LV" !vg_count :: params
+ ) else params in
+ let params = List.rev params in
+ pr " -N prep%d.img=%s \\\n" (i + 1) (String.concat ":"
params)
+ ) prepopts;
+
+ pr " exit
+
+rm %s
+" all_disks
diff --git a/generator/fish.mli b/generator/fish.mli
index c654bf6..bb4376a 100644
--- a/generator/fish.mli
+++ b/generator/fish.mli
@@ -26,3 +26,4 @@ val generate_fish_event_names : unit -> unit
val generate_fish_prep_options_c : unit -> unit
val generate_fish_prep_options_h : unit -> unit
val generate_fish_prep_options_pod : unit -> unit
+val generate_fish_test_prep_sh : unit -> unit
diff --git a/generator/main.ml b/generator/main.ml
index 8d08d83..91ca4d7 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -124,6 +124,7 @@ Run it from the top source directory using the command
output_to "fish/prepopts.c" generate_fish_prep_options_c;
output_to "fish/prepopts.h" generate_fish_prep_options_h;
output_to "fish/guestfish-prepopts.pod" generate_fish_prep_options_pod;
+ output_to ~perm:0o555 "fish/test-prep.sh" generate_fish_test_prep_sh;
output_to "ocaml/guestfs.mli" generate_ocaml_mli;
output_to "ocaml/guestfs.ml" generate_ocaml_ml;
output_to "ocaml/guestfs-c-actions.c" generate_ocaml_c;
--
2.5.5