Commit cbe391c1 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Generate CLI usage using Pod::Usage

parent 861120fc
......@@ -37,6 +37,8 @@ use Getopt::Long qw(:config no_ignore_case bundling);
use POSIX qw(strftime);
use Time::HiRes qw(time);
use Pod::Usage;
use constant TESTS => "tst";
use constant TB => "tb";
......@@ -44,99 +46,36 @@ my $cfg = {};
my $prob = {};
my $dur = {};
sub usage {
my ($err) = @_;
$err = 0 if !defined($err);
my $scr = basename($0);
my $msg = <<USAGE;
$scr is the CLI FIJI Execution Engine
Usage: $scr [PARAMETERS]
Required:
-m, --mode=<mode> Download mode:
manual Prompt for fault patterns & timer values
auto Download tests in cfg file
random Download randomly generated tests
-s, --settings=<filename> FIJI Settings file
-t, --tests=<filename> FIJI Tests file
Options for random mode (optional, default to values in Tests file):
-a, --timer-1-min=<#> Minimum duration t1
-b, --timer-2-min=<#> Minimum duration t2
-A, --timer-1-max=<#> Maximum duration t1
-B, --timer-2-max=<#> Maximum duration t2
-0, --prob-s0=<#> Probability of stuck-at-0 fault
-1, --prob-s1=<#> Probability of stuck-at-1 fault
-d, --prob-dly=<#> Probability of delay fault
-f, --prob-seu=<#> Probability of SEU fault
-o, --prob-so=<#> Probability of stuck-open fault
Optional command-line arguments:
-p, --port=<port> Serial port to use. Defaults to value in Tests file
-c, --completion=<filename> Overrides the completion script from settings
-i, --interactive Wait for user input (default in manual mode).
Normally EE is to be used without user interaction.
-v, --verbose Increase verbosity of output
(can be given multiple times to increase
the verbosity level once per occurrence).
-h, --help Display this help and exit
USAGE
if ($err == 0) {
print STDOUT $msg;
} else {
print STDERR $msg;
}
return $err;
}
sub main {
my $log_conf = File::Spec->catfile($FindBin::Bin, 'logger.conf');
Log::Log4perl::init_and_watch($log_conf, 'HUP');
FIJI::Utils::increase_verbosity($cfg->{'verbosity_delta'});
my $logger = get_logger("");
my ($cfg,$prob,$dur) = @_;
if (defined $cfg->{'help'}) {
return usage();
}
pod2usage(0) if (defined $cfg->{'help'});
# Validate parameters
if (!defined $cfg->{'settings_name'} || !defined $cfg->{'tests_name'} || !defined $cfg->{'mode'}) {
print STDERR "$0: No settings file specified.\n" if (!defined $cfg->{'settings_name'});
print STDERR "$0: No tests file specified.\n" if (!defined $cfg->{'tests_name'});
print STDERR "$0: No test mode specified.\n" if (!defined $cfg->{'tests_name'});
print STDERR "\n";
return usage(1);
my $msg;
$msg .= "$0: No settings file specified.\n" if (!defined $cfg->{'settings_name'});
$msg .= "$0: No tests file specified.\n" if (!defined $cfg->{'tests_name'});
$msg .= "$0: No test mode specified.\n" if (!defined $cfg->{'tests_name'});
$logger->error($msg);
pod2usage(-exitval=>1,-msg=>$msg,-verbose);
}
if ($cfg->{'mode'} ne 'auto' &&
$cfg->{'mode'} ne 'manual' &&
$cfg->{'mode'} ne 'random') {
print "$0: Invalid mode \"" . $cfg->{'mode'} . "\"\n\n";
return usage(1);
my $msg = "$0: Invalid mode \"" . $cfg->{'mode'} . "\"\n\n";
$logger->error($msg);
pod2usage(-exitval=>1,-msg=>$msg,-verbose);
}
# default to interactive in manual mode
$cfg->{'interactive'} = 1 if ($cfg->{'mode'} eq 'manual');
my $log_conf = File::Spec->catfile($FindBin::Bin, 'logger.conf');
Log::Log4perl::init_and_watch($log_conf, 'HUP');
FIJI::Utils::increase_verbosity($cfg->{'verbosity_delta'});
my $logger = get_logger("");
# Make new downloader
my $fiji_downloader = FIJI::Downloader->new($cfg->{'mode'}, $cfg->{'tests_name'}, undef, $cfg->{'settings_name'});
......@@ -238,6 +177,111 @@ GetOptions(
"v|verbose+" => \($cfg->{'verbosity_delta'}),
"h|help" => \($cfg->{'help'}),
)
or exit(usage(1));
or pod2usage(-exitval=>1,-verbose=>1);
exit main($cfg,$prob,$dur);
__END__
=head1 NAME
fiji_ee.pl
=head1 SYNOPSIS
fiji_ee.pl [options] -m MODE -s SETTINGS -t TESTS
fiji_ee.pl is the CLI Test Execution Engine
=head1 OPTIONS
=item B<-m, --mode MODE>
Download mode:
manual Prompt for fault patterns & timer values
auto Download tests in cfg file
random Download randomly generated tests
=item B<-s, --settings FILENAME>
FIJI Settings file
=item B<-t, --tests FILENAME>
FIJI Tests file
=back
=head2 OPTIONAL
Values for the random execution mode.
These values default to the values in the Test file
=over
=item B<-a, --timer-1-min DURATION>
Minimum duration t1
=item B<-b, --timer-2-min DURATION>
Minimum duration t2
=item B<-A, --timer-1-max DURATION>
Maximum duration t1
=item B<-B, --timer-2-max DURATION>
Maximum duration t2
=item B<-0, --prob-s0 PROBABILITY>
Probability of stuck-at-0 fault
=item B<-1, --prob-s1 PROBABILITY>
Probability of stuck-at-1 fault
=item B<-d, --prob-dly PROBABILITY>
Probability of delay fault
=item B<-f, --prob-seu PROBABILITY>
Probability of SEU fault
=item B<-o, --prob-so PROBABILITY>
Probability of stuck-open fault
=back
General optional arguments.
=over
=item B<-p, --port PORT>
Serial port to use. Defaults to value in Tests file
=item B<-c, --completion FILENAME>
Overrides the completion script from settings
=item B<-i, --interactive>
Wait for user input (default in manual mode).
Normally EE is to be used without user interaction.
=item B<-v, --verbose>
Increase verbosity of output. Can be given multiple times to increase
the verbosity level once per occurrence.
=item B<-h, --help>
Display this help and exit
=back
......@@ -43,6 +43,7 @@ use Thread::Queue;
use Socket;
use IO::Handle;
use Getopt::Long qw(:config bundling);
use Pod::Usage;
## @var USE_MENU defines control style of fiji_settings:
# 0 => classic, no menu GUI
......@@ -82,37 +83,6 @@ my $unsaved_changes = 0;
my $current_dir = ".";
sub usage {
my ($err) = @_;
$err = 0 if !defined($err);
my $scr = basename($0);
my $msg = <<USAGE;
$scr is the graphical FIJI Tests Editor and Execution Engine
Usage: $scr [PARAMETERS]
Optional command-line arguments:
-s, --settings=<filename> FIJI Settings file
-t, --tests=<filename> FIJI Tests file
-v, --verbose Increase verbosity of output
(can be given multiple times to increase
the verbosity level once per occurrence).
-h, --help Display this help and exit
USAGE
if ($err == 0) {
print STDOUT $msg;
} else {
print STDERR $msg;
}
return $err;
}
#** @function download_worker ()
# @brief Downloader worker thread for fiji_download_gui
#
......@@ -232,8 +202,8 @@ sub main {
my $loglevel = FIJI::Utils::increase_verbosity($verbosity_delta);
return usage(1) if (!$parse);
return usage() if (defined $help);
pod2usage(-exitval => 1, -verbose => 1) if (!$parse);
pod2usage(0) if (defined $help);
# Create heavy thread as soon as possible
$worker_tid = threads->create('download_worker',$loglevel);
......@@ -895,3 +865,40 @@ Log::Log4perl::init_and_watch($log_conf, 'HUP');
# We can get the buffered output from the log window
Log::Log4perl->eradicate_appender("string");
exit main(@ARGV);
__END__
=head1 NAME
fiji_ee_gui.pl
=head1 SYNOPSIS
fiji_ee_gui.pl [options]
fiji_ee_gui.pl is the graphical FIJI Tests Editor and Execution Engine
=head1 OPTIONS
=head2 OPTIONAL PARAMETERS
=over
=item B<-s, --settings FILENAME>
FIJI Settings file
=item B<-t, --tests FILENAME>
FIJI Tests file
=item B<-v, --verbose>
Increase verbosity of output. Can be given multiple times to increase
the verbosity level once per occurrence.
=item B<-h, --help>
Display this help and exit
=back
......@@ -48,6 +48,8 @@ use FIJI::Utils;
use File::Spec;
use File::Path qw(make_path);
use Pod::Usage;
use Getopt::Long qw(:config bundling);
use constant NETLIST_SUFFIX => {
......@@ -439,29 +441,6 @@ sub usage {
$scr is the FIJI Instrumentation tool
Usage: $0 [PARAMETERS]
Required parameters:
-s, --settings=<filename> FIJI Settings file
-n, --netlist=<filename> Netlist file to instrument
Optional parameters:
-p, --file-prefix=<prefix> Prefix for all generated files
Otherwise: toplevel module name
-o, --output-dir=<path> The directory where the generated files are put.
The directory will be created if necessary.
Overrules the directory specified in
the FIJI settings file.
Otherwise: current working directory
-v, --verbose Increase verbosity of output
(can be given multiple times to increase
the verbosity level once per occurrence).
--help Display this help and exit
USAGE
if ($err == 0) {
......@@ -498,21 +477,31 @@ GetOptions(
"p|file-prefix=s" => \$options->{'file_prefix'},
"o|output-dir=s" => \$options->{'output_dir'},
"v|verbose+" => \$options->{'verbosity_delta'},
"help|h" => sub { exit(usage(0)); },
"help|h" => sub { pod2usage(0); },
);
my $msg;
# Check if all required options present
for my $k (keys(%{$options})) {
if (!defined $options->{$k}) {
if ($k eq 'output_dir' || $k eq 'file_prefix') {
} else {
$break = 1;
$logger->error("Option $k is required.");
$msg .= "Option $k is required.";
$logger->error($msg);
last;
}
}
}
exit usage(1) if (defined $break);
if (defined $break) {
pod2usage(-exitval => 1,
-verbose => 1,
-msg => $msg);
}
# clean up the passed paths
# @FIXME needed ?
......@@ -523,3 +512,58 @@ $options->{'output_dir'} = File::Spec->canonpath($options->{'output_dir'
FIJI::Utils::increase_verbosity($options->{'verbosity_delta'});
exit main($options);
__END__
=head1 NAME
fiji_instrument.pl
=head1 SYNOPSIS
fiji_instrument.pl [options] --settings <settings file> --netlist <netlist file>
fiji_instrument.pl is the FIJI Instrumentation tool
=head1 OPTIONS
=over
=item B<-s, --settings FILENAME>
FIJI Settings file
=item B<-n, --netlist FILENAME>
Netlist file to instrument
=back
=head2 OPTIONAL
=over
=item B<-p, --file-prefix PREFIX
Prefix for all generated files. Default: toplevel module name
=item B<-o, --output-dir PATH>
The directory where the generated files are put.
The directory will be created if necessary.
Overrules the directory specified in the FIJI settings file.
Default: current working directory
=item B<-v, --verbose>
Increase verbosity of output. Can be given multiple times to increase
the verbosity level once per occurrence.
=item B<-h, --help>
Display this help and exit
=back
......@@ -38,7 +38,7 @@ use FIJI::Utils;
use Tk::FIJISettingsViewer;
use Tk::FIJIUtils;
use Time::HiRes qw(ualarm);
use Pod::Usage;
use Getopt::Long qw(:config bundling);
use FIJI qw(:fiji_dir :fiji_documentation_path);
......@@ -66,36 +66,6 @@ my $do_splash;
use constant START_PERIOD => 500000; # 500 ms
sub usage {
my ($err) = @_;
$err = 0 if !defined($err);
my $scr = basename($0);
my $msg = <<USAGE;
$scr is the graphical FIJI Settings editor
Usage: $scr [PARAMETERS]
Optional command-line arguments:
-s, --settings=<filename> FIJI Settings file
-n, --netlist=<filename> Netlist file to instrument
-v, --verbose Increase verbosity of output
(can be given multiple times to increase
the verbosity level once per occurrence).
-h, --help Display this help and exit
USAGE
if ($err == 0) {
print STDOUT $msg;
} else {
print STDERR $msg;
}
return $err;
}
my $rv;
sub main {
......@@ -120,8 +90,8 @@ sub main {
$logger->warn("Benchmarking mode: Terminating after loading settings and netlist") if $only_load;
return usage(1) if (!$parse);
return usage() if (defined $help);
pod2usage(-exitval => 1, -verbose => 1) if (!$parse);
pod2usage(0) if (defined $help);
my %hash;
my $self = bless(\%hash);
......@@ -728,3 +698,40 @@ my $log_conf = File::Spec->catfile($FindBin::Bin, 'logger.conf');
Log::Log4perl::init_and_watch($log_conf, 'HUP');
Log::Log4perl->eradicate_appender("string"); # No need for buffered log output
exit main(@ARGV);
__END__
=head1 NAME
fiji_setup.pl
=head1 SYNOPSIS
fiji_setup.pl [options]
fiji_setup.pl is the graphical FIJI Settings editor
=head1 OPTIONS
=head2 OPTIONAL PARAMETERS
=over
=item B<-s, --settings FILENAME>
FIJI Settings file
=item B<-n, --netlist FILENAME>
Netlist file to instrument
=item B<-v, --verbose>
Increase verbosity of output. Can be given multiple times to increase
the verbosity level once per occurrence.
=item B<-h, --help>
Display this help and exit
=back
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment