mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
podcheck: Check tool --help output.
For OCaml tools this does essentially nothing useful because the --help output is automatically generated from the options, and so cannot be wrong. However for C tools this is a useful check. It would be nice to generate C tools --help output, but there isn't enough information in the getopt data to do that. This commit also includes fixes to the --help output for a few tools.
This commit is contained in:
@@ -87,6 +87,7 @@ usage (int status)
|
||||
" --help Display brief help\n"
|
||||
" -P nr_threads Use at most nr_threads\n"
|
||||
" -q|--quiet No output, just exit code\n"
|
||||
" --uuid Print UUIDs instead of names\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
|
||||
@@ -78,12 +78,12 @@ usage (int status)
|
||||
" --csv Output as Comma-Separated Values\n"
|
||||
" -d|--domain guest Add disks from libvirt guest\n"
|
||||
" --format[=raw|..] Force disk format for -a option\n"
|
||||
" -h|--human-readable Human-readable sizes in --long output\n"
|
||||
" -h|--human-readable Print sizes in human-readable format\n"
|
||||
" --help Display brief help\n"
|
||||
" -i|--inodes Display inodes\n"
|
||||
" --one-per-guest Separate appliance per guest\n"
|
||||
" -P nr_threads Use at most nr_threads\n"
|
||||
" --uuid Add UUIDs to --long output\n"
|
||||
" --uuid Print UUIDs instead of names\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
|
||||
26
edit/edit.c
26
edit/edit.c
@@ -70,20 +70,20 @@ usage (int status)
|
||||
" %s [--options] -d domname file [file ...]\n"
|
||||
" %s [--options] -a disk.img [-a disk.img ...] file [file ...]\n"
|
||||
"Options:\n"
|
||||
" -a|--add image Add image\n"
|
||||
" -b|--backup .ext Backup original as original.ext\n"
|
||||
" -c|--connect uri Specify libvirt URI for -d option\n"
|
||||
" -d|--domain guest Add disks from libvirt guest\n"
|
||||
" --echo-keys Don't turn off echo for passphrases\n"
|
||||
" -e|--expr expr Non-interactive editing using Perl expr\n"
|
||||
" --format[=raw|..] Force disk format for -a option\n"
|
||||
" --help Display brief help\n"
|
||||
" --keys-from-stdin Read passphrases from stdin\n"
|
||||
" -a|--add image Add image\n"
|
||||
" -b|--backup .ext Backup original as original.ext\n"
|
||||
" -c|--connect uri Specify libvirt URI for -d option\n"
|
||||
" -d|--domain guest Add disks from libvirt guest\n"
|
||||
" --echo-keys Don't turn off echo for passphrases\n"
|
||||
" -e|--edit|--expr expr Non-interactive editing using Perl expr\n"
|
||||
" --format[=raw|..] Force disk format for -a option\n"
|
||||
" --help Display brief help\n"
|
||||
" --keys-from-stdin Read passphrases from stdin\n"
|
||||
" -m|--mount dev[:mnt[:opts[:fstype]]]\n"
|
||||
" Mount dev on mnt (if omitted, /)\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
" Mount dev on mnt (if omitted, /)\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
"For more information, see the manpage %s(1).\n"),
|
||||
guestfs_int_program_name, guestfs_int_program_name,
|
||||
guestfs_int_program_name, guestfs_int_program_name);
|
||||
|
||||
@@ -126,6 +126,7 @@ usage (int status)
|
||||
" --echo-keys Don't turn off echo for passphrases\n"
|
||||
" -f|--file file Read commands from file\n"
|
||||
" --format[=raw|..] Force disk format for -a option\n"
|
||||
" --help Display brief help\n"
|
||||
" -i|--inspector Automatically mount filesystems\n"
|
||||
" --keys-from-stdin Read passphrases from stdin\n"
|
||||
" --listen Listen for remote commands\n"
|
||||
|
||||
@@ -82,16 +82,16 @@ usage (int status)
|
||||
" %s [--options] input.tar.gz output.img\n"
|
||||
" %s [--options] directory output.img\n"
|
||||
"Options:\n"
|
||||
" --floppy Make a virtual floppy disk\n"
|
||||
" --format=raw|qcow2|.. Set output format\n"
|
||||
" --help Display brief help\n"
|
||||
" --label=label Filesystem label\n"
|
||||
" --partition=mbr|gpt|.. Set partition type\n"
|
||||
" --size=size|+size Set size of output disk\n"
|
||||
" --type=ext4|.. Set filesystem type\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
" --floppy Make a virtual floppy disk\n"
|
||||
" -F|--format=raw|qcow2|.. Set output format\n"
|
||||
" --help Display brief help\n"
|
||||
" --label=label Filesystem label\n"
|
||||
" --partition=mbr|gpt|.. Set partition type\n"
|
||||
" -s|--size=size|+size Set size of output disk\n"
|
||||
" -t|--type=ext4|.. Set filesystem type\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
" -V|--version Display version and exit\n"
|
||||
" -x Trace libguestfs API calls\n"
|
||||
"For more information, see the manpage %s(1).\n"),
|
||||
guestfs_int_program_name, guestfs_int_program_name,
|
||||
guestfs_int_program_name, guestfs_int_program_name,
|
||||
|
||||
@@ -86,7 +86,7 @@ usage (int status)
|
||||
"Options:\n"
|
||||
" --help Display brief help\n"
|
||||
" --cmdline=CMDLINE Used to debug command line parsing\n"
|
||||
" --colours Use ANSI colour sequences even if not tty\n"
|
||||
" --colors|--colours Use ANSI colour sequences even if not tty\n"
|
||||
" --iso Running in the ISO environment\n"
|
||||
" --test-disk=DISK.IMG For testing, use disk as /dev/sda\n"
|
||||
" -v|--verbose Verbose messages\n"
|
||||
|
||||
47
podcheck.pl
47
podcheck.pl
@@ -153,6 +153,17 @@ delete $tool_option_exists{"--color"};
|
||||
delete $tool_option_exists{"--colour"};
|
||||
delete $tool_option_exists{"--debug-gc"};
|
||||
|
||||
# Run the tool with --help.
|
||||
my $help_content;
|
||||
open PIPE, "LANG=C $tool --help |"
|
||||
or die "$progname: $tool --help: $!";
|
||||
{
|
||||
local $/ = undef;
|
||||
$help_content = <PIPE>;
|
||||
}
|
||||
close PIPE;
|
||||
|
||||
# Do the tests.
|
||||
my $errors = 0;
|
||||
|
||||
# Check each option exists in the manual.
|
||||
@@ -184,9 +195,43 @@ foreach (sort keys %pod_options) {
|
||||
}
|
||||
}
|
||||
|
||||
# Check the tool's --help output mentions all the options. (For OCaml
|
||||
# tools this is a waste of time since the --help output is generated,
|
||||
# but for C tools it is a genuine test).
|
||||
my $help_options_checked = 0;
|
||||
|
||||
my %help_options = ();
|
||||
$help_options{$_} = 1 foreach ( $help_content =~ /(?<!\w)(-[-\w]+)/g );
|
||||
|
||||
# There are some help options which we automatically ignore.
|
||||
delete $help_options{"--color"};
|
||||
delete $help_options{"--colour"};
|
||||
# "[--options]" is used as a placeholder for options in the synopsis
|
||||
# text, so ignore it.
|
||||
delete $help_options{"--options"};
|
||||
|
||||
foreach (sort keys %tool_option_exists) {
|
||||
unless ($ignore{$_}) {
|
||||
unless (exists $help_options{$_}) {
|
||||
$errors++;
|
||||
warn "$progname: $tool: option $_ does not appear in --help output\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (sort keys %help_options) {
|
||||
unless ($ignore{$_}) {
|
||||
$help_options_checked++;
|
||||
unless (exists $tool_option_exists{$_}) {
|
||||
$errors++;
|
||||
warn "$progname: $tool: unknown option $_ appears in --help output\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit 1 if $errors > 0;
|
||||
|
||||
printf "$progname: $tool: checked $tool_options_checked tool options against $pod_options_checked documented options\n";
|
||||
printf "$progname: $tool: checked $tool_options_checked tool options, $pod_options_checked documented options, $help_options_checked help options\n";
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user