test1486: verify that write-out.md and tool_writeout.c are in sync

- also verify alphabetialal order in the source
- add two missing variables to write-out.md

Closes #13920
This commit is contained in:
Daniel Stenberg 2024-06-11 09:30:29 +02:00
parent e5223f3ce0
commit 61b465208f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 147 additions and 1 deletions

View File

@ -63,6 +63,11 @@ The variables available are:
Output the certificate chain with details. Supported only by the OpenSSL,
GnuTLS, Schannel and Secure Transport backends. (Added in 7.88.0)
## `conn_id`
The connection identifier last used by the transfer. The connection id is
unique number among all connections using the same connection cache.
(Added in 8.2.0)
## `content_type`
The Content-Type of the requested document, if there was any.
@ -309,3 +314,9 @@ same index number as the origin globbed URL. (Added in 7.75.0)
## `url_effective`
The URL that was fetched last. This is most meaningful if you have told curl
to follow location: headers.
## `xfer_id`
The numerical identifier of the last transfer done. -1 if no transfer has been
started yet for the handle. The transfer id is unique among all transfers
performed using the same connection cache.
(Added in 8.2.0)

View File

@ -40,6 +40,7 @@ TESTSCRIPTS = \
test1275.pl \
test1276.pl \
test1477.pl \
test1486.pl \
test1544.pl \
test971.pl

View File

@ -188,7 +188,7 @@ test1447 test1448 test1449 test1450 test1451 test1452 test1453 test1454 \
test1455 test1456 test1457 test1458 test1459 test1460 test1461 test1462 \
test1463 test1464 test1465 test1466 test1467 test1468 test1469 test1470 \
test1471 test1472 test1473 test1474 test1475 test1476 test1477 test1478 \
test1479 test1480 test1481 test1482 test1483 test1484 test1485 \
test1479 test1480 test1481 test1482 test1483 test1484 test1485 test1486 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \

32
tests/data/test1486 Normal file
View File

@ -0,0 +1,32 @@
<testcase>
<info>
<keywords>
source analysis
docs
--write-out
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<name>
Verify that write-out.md and tool_writeout.c are in sync
</name>
<command type="perl">
%SRCDIR/test1486.pl %SRCDIR
</command>
</client>
<verify>
<stdout>
OK
</stdout>
</verify>
</testcase>

102
tests/test1486.pl Executable file
View File

@ -0,0 +1,102 @@
#!/usr/bin/env perl
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
#
#
use strict;
use warnings;
# we may get the dir root pointed out
my $root=$ARGV[0] || ".";
my %insrc; # variable set in source
my %indocs; # variable described in docs
my $srccount = 1;
sub getsrcvars {
open(my $f, "<", "$root/../src/tool_writeout.c");
my $mode = 0;
while(<$f>) {
if(!$mode &&
($_ =~ /^static const struct writeoutvar/)) {
$mode = 1;
}
if($mode) {
if($_ =~ /^}/) {
last;
}
if($_ =~ /^ \{\"([^\"]*)/) {
my $var = $1;
$insrc{$var} = $srccount++;
}
}
}
close($f);
}
sub getdocsvars {
open(my $f, "<", "$root/../docs/cmdline-opts/write-out.md");
while(<$f>) {
if($_ =~ /^\#\# \`([^\`]*)\`/) {
$indocs{$1} = 1;
}
}
close($f);
}
getsrcvars();
getdocsvars();
my $error = 0;
if((scalar(keys %indocs) < 10) || (scalar(keys %insrc) < 10)) {
print "problems to extract variables\n";
$error++;
}
# also verify that the source code lists them alphabetically
my $check = 1;
for(sort keys %insrc) {
if($insrc{$_} && !$indocs{$_}) {
print "$_ is not mentioned in write.out.md\n";
$error++;
}
if($insrc{$_} ne $check) {
print "$_ is not in alphabetical order\n";
$error++;
}
$check++;
}
for(sort keys %indocs) {
if($indocs{$_} && !$insrc{$_}) {
print "$_ documented, but not used in source code\n";
$error++;
}
}
print "OK\n" if(!$error);
exit $error;