fish: generate test-prep.sh with generator

Generate test-prep.sh using the generator, so the prepared disk types
tested are the same as the ones configured in prepopts.ml.
This commit is contained in:
Pino Toscano
2016-05-19 18:52:42 +02:00
parent d5b3f558e0
commit 1c9e808eee
5 changed files with 36 additions and 35 deletions

1
.gitignore vendored
View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;