From 8fbdf8331e4c0575f284ca045102b8939220c20a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 1 Sep 2021 12:57:06 +0200 Subject: test1173: check references to libcurl options ... that they refer to actual existing libcurl options. Reviewed-by: Daniel Gustafsson Closes #7656 --- tests/data/test1173 | 4 +-- tests/manpage-syntax.pl | 78 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/tests/data/test1173 b/tests/data/test1173 index e23b0e8df..f52afa6bb 100644 --- a/tests/data/test1173 +++ b/tests/data/test1173 @@ -15,11 +15,11 @@ none -Basic man page syntax check +Man page syntax checks -%SRCDIR/manpage-syntax.pl %SRCDIR/../docs/*.1 %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3 +%SRCDIR/manpage-syntax.pl %SRCDIR/../docs/libcurl/symbols-in-versions %SRCDIR/../docs/*.1 %SRCDIR/../docs/libcurl/*.3 %SRCDIR/../docs/libcurl/opts/*.3 diff --git a/tests/manpage-syntax.pl b/tests/manpage-syntax.pl index 1609ba220..e8d183703 100644 --- a/tests/manpage-syntax.pl +++ b/tests/manpage-syntax.pl @@ -28,6 +28,9 @@ use strict; use warnings; +# get the file name first +my $symbolsinversions=shift @ARGV; + # we may get the dir roots pointed out my @manpages=@ARGV; my $errors = 0; @@ -46,6 +49,18 @@ my @order = ( ); my %shline; # section => line number +my %symbol; +sub allsymbols { + open(F, "<$symbolsinversions") || + die "$symbolsinversions: $|"; + while() { + if($_ =~ /^([^ ]*)/) { + $symbol{$1}=$1; + } + } + close(F); +} + sub scanmanpage { my ($file) = @_; my $reqex = 0; @@ -54,24 +69,24 @@ sub scanmanpage { my $shc = 0; my @sh; - print "Check $file\n"; open(M, "<$file") || die "no such file: $file"; - if($file =~ /\/CURL[^\/]*.3/) { + if($file =~ /[\/\\]CURL[^\/\\]*.3/) { # This is the man page for an libcurl option. It requires an example! $reqex = 1; } my $line = 1; while() { - if($_ =~ /^.SH EXAMPLE/i) { + chomp; + if($_ =~ /^\.SH EXAMPLE/i) { $inex = 1; } - elsif($_ =~ /^.SH/i) { + elsif($_ =~ /^\.SH/i) { $inex = 0; } elsif($inex) { $exsize++; } - if($_ =~ /^.SH (.*)/i) { + if($_ =~ /^\.SH ([^\r\n]*)/i) { my $n = $1; # remove enclosing quotes $n =~ s/\"(.*)\"\z/$1/; @@ -94,6 +109,16 @@ sub scanmanpage { print STDERR "$file:$line trailing whitespace\n"; $errors++; } + if($_ =~ /\\f([BI])([^\\]*)\\fP/) { + my $r = $2; + if($r =~ /^(CURL.*)\(3\)/) { + my $rr = $1; + if(!$symbol{$rr}) { + print STDERR "$file:$line link to non-libcurl option $rr!\n"; + $errors++; + } + } + } $line++; } close(M); @@ -101,45 +126,68 @@ sub scanmanpage { if($reqex) { # only for libcurl options man-pages + my $shcount = scalar(@sh); # before @sh gets shifted if($exsize < 2) { print STDERR "$file:$line missing EXAMPLE section\n"; $errors++; } - my $got; + if($shcount < 3) { + print STDERR "$file:$line too few man page sections!\n"; + $errors++; + return; + } + + my $got = "start"; my $i = 0; my $shused = 1; - do { + my @shorig = @sh; + while($got) { + my $finesh; $got = shift(@sh); if($got) { - $i = $blessed{$got}; + if($blessed{$got}) { + $i = $blessed{$got}; + $finesh = $got; # a mandatory one + } } - if($i && $got) { + if($i && defined($finesh)) { # mandatory section if($i != $shused) { - printf STDERR "$file:%u Got $got, when %s was expected\n", - $shline{$got}, + printf STDERR "$file:%u Got %s, when %s was expected\n", + $shline{$finesh}, + $finesh, $order[$shused-1]; $errors++; return; } $shused++; - if($i == 9) { + if($i == scalar(@order)) { # last mandatory one, exit - $got=""; + last; } } - } while($got); + } - if($i != 8) { + if($i != scalar(@order)) { printf STDERR "$file:$line missing mandatory section: %s\n", $order[$i]; + printf STDERR "$file:$line section found at index %u: '%s'\n", + $i, $shorig[$i]; + printf STDERR " Found %u used sections\n", $shcount; $errors++; } } } +allsymbols(); + +if(!$symbol{'CURLALTSVC_H1'}) { + print STDERR "didn't get the symbols-in-version!\n"; + exit; +} + my $ind = 1; for my $s (@order) { $blessed{$s} = $ind++ -- cgit v1.2.1