No subject


Thu Jul 12 09:23:04 CDT 2007


Modified:
    branches/1.2/xpp/init_card_2_30

Modified: branches/1.2/xpp/init_card_2_30
URL: http://svn.digium.com/view/zaptel/branches/1.2/xpp/init_card_2_30?view=diff&rev=4518&r1=4517&r2=4518
==============================================================================
--- branches/1.2/xpp/init_card_2_30 (original)
+++ branches/1.2/xpp/init_card_2_30 Tue Sep  9 07:48:46 2008
@@ -50,7 +50,7 @@
 my %opts;
 $ENV{XPP_BASE} = '/proc/xpp';
 
-getopts('o:', \%opts);
+getopts('o:v:', \%opts);
 
 my $debug;
 
@@ -264,7 +264,7 @@
 	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 @@
 	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 @@
 
 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";




More information about the zaptel-commits mailing list