xref: /curl/tests/test1177.pl (revision 50def7c8)
1#!/usr/bin/env perl
2#***************************************************************************
3#                                  _   _ ____  _
4#  Project                     ___| | | |  _ \| |
5#                             / __| | | | |_) | |
6#                            | (__| |_| |  _ <| |___
7#                             \___|\___/|_| \_\_____|
8#
9# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
10#
11# This software is licensed as described in the file COPYING, which
12# you should have received as part of this distribution. The terms
13# are also available at https://curl.se/docs/copyright.html.
14#
15# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16# copies of the Software, and permit persons to whom the Software is
17# furnished to do so, under the terms of the COPYING file.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24###########################################################################
25#
26# Verify that curl_version_info.3 documents all the CURL_VERSION_ bits
27# from the header.
28#
29
30use strict;
31use warnings;
32
33my $manpage=$ARGV[0];
34my $header=$ARGV[1];
35my $source=$ARGV[2];
36my %manversion;
37my %headerversion;
38my %manname;
39my %sourcename;
40my $error=0;
41
42open(my $m, "<", "$manpage");
43while(<$m>) {
44    if($_ =~ / mask bit: (CURL_VERSION_[A-Z0-9_]+)/i) {
45        $manversion{$1}++;
46    }
47    if($_ =~ /^\.ip (.*)/i) {
48        $manname{$1}++;
49    }
50}
51close($m);
52
53open(my $h, "<", "$header");
54while(<$h>) {
55    if($_ =~ /^\#define (CURL_VERSION_[A-Z0-9_]+)/i) {
56        $headerversion{$1}++;
57    }
58}
59close($h);
60
61open(my $s, "<", "$source");
62while(<$s>) {
63    if($_ =~ /FEATURE\("([^"]*)"/) {
64      $sourcename{$1}++;
65    }
66}
67close($s);
68$sourcename{'NTLM_WB'}++; # deprecated, fake its presence in code
69
70for my $h (keys %headerversion) {
71    if(!$manversion{$h}) {
72        print STDERR "$manpage: missing $h\n";
73        $error++;
74    }
75}
76for my $h (keys %manversion) {
77    if(!$headerversion{$h}) {
78        print STDERR "$manpage: $h is not in the header!\n";
79        $error++;
80    }
81}
82for my $n (keys %sourcename) {
83    if(!$manname{$n}) {
84        print STDERR "$manpage: missing feature name $n\n";
85        $error++;
86    }
87}
88for my $n (keys %manname) {
89    if(!$sourcename{$n} && ($n ne "\"no name\"")) {
90        print STDERR "$manpage: $n is not in the source!\n";
91        $error++;
92    }
93}
94
95exit $error;
96