summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-09-09 12:48:46 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-09-09 12:48:46 +0000
commit0da26cd1c201bfc87f0d038a27bd39208fd28c24 (patch)
tree60ea463a6e4ada0b0bc79e3b646df0919c94cdc9
parent6ca12dda6ac2a788fd9a495879e8e5651127b233 (diff)
xpp-zaptel: FXO: cleanup opermode verification code (from DAHDI):
* Add proper '-v' option to init_card_2_30 and use it in * xortel/Makefile * Use $mismatches as in DAHDI (minimize diffs). From xpp rev. 6108. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@4518 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xxpp/init_card_2_3029
1 files changed, 16 insertions, 13 deletions
diff --git a/xpp/init_card_2_30 b/xpp/init_card_2_30
index 859aca4..e2d5faa 100755
--- a/xpp/init_card_2_30
+++ b/xpp/init_card_2_30
@@ -50,7 +50,7 @@ my $unit_id;
my %opts;
$ENV{XPP_BASE} = '/proc/xpp';
-getopts('o:', \%opts);
+getopts('o:v:', \%opts);
my $debug;
@@ -264,7 +264,7 @@ sub opermode_verify($) {
my $input = shift or die;
my %verification_table;
my %location_lines;
- my $status = 0;
+ my $mismatches = 0;
open(F, $input) or die "$0: Failed opening '$input': $!\n";
while(<F>) {
@@ -284,30 +284,31 @@ sub opermode_verify($) {
foreach my $location (sort keys %verification_table) {
my $mode = $opermode_table{$location};
if(! defined $mode) {
- printf STDERR "Missing $location at $input:$location_lines{$location}\n";
- $status = 1;
+ printf STDERR "Missing from $0: '$location' at $input:$location_lines{$location}\n";
+ $mismatches++;
next;
}
my $verify_mode = $verification_table{$location};
my $str1 = opermode_to_string($mode);
my $str2 = opermode_to_string($verify_mode);
if($str1 ne $str2) {
- print STDERR "DIFF: $location at $input:$location_lines{$location}\n";
+ print STDERR "DIFF: '$location' at $input:$location_lines{$location}\n";
printf STDERR "\t%-20s: %s\n", "program", $str1;
printf STDERR "\t%-20s: %s\n", "verify", $str2;
- $status = 1;
+ $mismatches++;
}
}
# Second test: check for extra data in our program
foreach my $location (sort keys %opermode_table) {
my $mode = $verification_table{$location};
if(! defined $mode) {
- printf STDERR "Extra $location\n";
- $status = 1;
+ printf STDERR "Extra in $0 '$location'\n";
+ $mismatches++;
next;
}
}
- return $status;
+ print STDERR "Total $mismatches mismatches\n" if $mismatches;
+ return $mismatches;
}
sub read_defaults() {
@@ -338,11 +339,13 @@ package main;
FXO::opermode_preprocess; # Must be first
-if(@ARGV and $ARGV[0] =~ /^verify(.*)/) {
- my $verify_file = $1;
- die "Usage: $0 verify=filename\n" unless $verify_file =~ s/^=//;
+if($opts{v}) {
+ my $verify_file = $opts{v};
+ die "Usage: $0 [-v verify_filename]\n" unless $verify_file;
main::debug "$0: opermode verification (input='$verify_file')";
- exit FXO::opermode_verify($verify_file);
+ my $mismatches = FXO::opermode_verify($verify_file);
+ die "$0: Verification against $verify_file failed\n" if $mismatches != 0;
+ exit 0;
}
main::logit "Starting";