tests: ensure libcurl.def contains all exports

Add `test1279` to verify that `libcurl.def` lists all exported API
functions found in libcurl headers.

Also:

- extend test suite XML `stdout` tag with the `loadfile` attribute.

- fix `tests/extern-scan.pl` and `test1135` to include websocket API.

- use all headers (sorted) in `test1135` instead of a manual list.

- add options `--sort`, `--heading=` to `tests/extern-scan.pl`.

- add `libcurl.def` to the auto-labeler GHA task.

Follow-up to 2ebc74c36a

Closes #11570
This commit is contained in:
Viktor Szakats 2023-08-01 22:02:43 +00:00
parent d135d040df
commit db70846e2e
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
7 changed files with 187 additions and 109 deletions

2
.github/labeler.yml vendored
View File

@ -48,6 +48,7 @@ build:
- all: ['plan9/**']
- all: ['projects/**']
- all: ['winbuild/**']
- all: ['libcurl.def']
CI:
- any: ['.azure-pipelines.yml']
@ -300,3 +301,4 @@ Windows:
- all: ['projects/**']
- all: ['src/tool_doswin.c']
- all: ['winbuild/**']
- all: ['libcurl.def']

View File

@ -608,7 +608,7 @@ have a text/binary difference.
If `nonewline` is set, we will cut off the trailing newline of this given data
before comparing with the one actually received by the client
### `<stdout [mode="text"] [nonewline="yes"] [crlf="yes"]>`
### `<stdout [mode="text"] [nonewline="yes"] [crlf="yes"] [loadfile="filename"]>`
This verifies that this data was passed to stdout.
Use the mode="text" attribute if the output is in text mode on platforms that
@ -620,6 +620,8 @@ before comparing with the one actually received by the client
`crlf=yes` forces the newlines to become CRLF even if not written so in the
test.
`loadfile="filename"` makes loading the data from an external file.
### `<file name="%LOGDIR/filename" [mode="text"]>`
The file's contents must be identical to this after the test is complete. Use
the mode="text" attribute if the output is in text mode on platforms that have

View File

@ -161,6 +161,7 @@ test1247 test1248 test1249 test1250 test1251 test1252 test1253 test1254 \
test1255 test1256 test1257 test1258 test1259 test1260 test1261 test1262 \
test1263 test1264 test1265 test1266 test1267 test1268 test1269 test1270 \
test1271 test1272 test1273 test1274 test1275 test1276 test1277 test1278 \
test1279 \
\
test1280 test1281 test1282 test1283 test1284 test1285 test1286 test1287 \
test1288 test1289 test1290 test1291 test1292 test1293 test1294 test1295 \

View File

@ -28,94 +28,97 @@ Verify CURL_EXTERN order
<verify>
<stdout>
CURL_EXTERN int curl_strequal
CURL_EXTERN int curl_strnequal
CURL_EXTERN curl_mime *curl_mime_init
CURL_EXTERN void curl_mime_free
CURL_EXTERN curl_mimepart *curl_mime_addpart
CURL_EXTERN CURLcode curl_mime_name
CURL_EXTERN CURLcode curl_mime_filename
CURL_EXTERN CURLcode curl_mime_type
CURL_EXTERN CURLcode curl_mime_encoder
CURL_EXTERN CURLcode curl_mime_data
CURL_EXTERN CURLcode curl_mime_filedata
CURL_EXTERN CURLcode curl_mime_data_cb
CURL_EXTERN CURLcode curl_mime_subparts
CURL_EXTERN CURLcode curl_mime_headers
CURL_EXTERN CURLFORMcode curl_formadd
CURL_EXTERN int curl_formget
CURL_EXTERN void curl_formfree
CURL_EXTERN char *curl_getenv
CURL_EXTERN char *curl_version
CURL_EXTERN char *curl_easy_escape
CURL_EXTERN char *curl_escape
CURL_EXTERN char *curl_easy_unescape
CURL_EXTERN char *curl_unescape
CURL_EXTERN void curl_free
CURL_EXTERN CURLcode curl_global_init
CURL_EXTERN CURLcode curl_global_init_mem
CURL_EXTERN void curl_global_cleanup
CURL_EXTERN CURLsslset curl_global_sslset
CURL_EXTERN struct curl_slist *curl_slist_append
CURL_EXTERN void curl_slist_free_all
CURL_EXTERN time_t curl_getdate
CURL_EXTERN CURLSH *curl_share_init
CURL_EXTERN CURLSHcode curl_share_setopt
CURL_EXTERN CURLSHcode curl_share_cleanup
CURL_EXTERN curl_version_info_data *curl_version_info
CURL_EXTERN const char *curl_easy_strerror
CURL_EXTERN const char *curl_share_strerror
CURL_EXTERN CURLcode curl_easy_pause
CURL_EXTERN CURL *curl_easy_init
CURL_EXTERN CURLcode curl_easy_setopt
CURL_EXTERN CURLcode curl_easy_perform
CURL_EXTERN void curl_easy_cleanup
CURL_EXTERN CURLcode curl_easy_getinfo
CURL_EXTERN CURL *curl_easy_duphandle
CURL_EXTERN void curl_easy_reset
CURL_EXTERN CURLcode curl_easy_recv
CURL_EXTERN CURLcode curl_easy_send
CURL_EXTERN CURLcode curl_easy_upkeep
CURL_EXTERN int curl_mprintf
CURL_EXTERN int curl_mfprintf
CURL_EXTERN int curl_msprintf
CURL_EXTERN int curl_msnprintf
CURL_EXTERN int curl_mvprintf
CURL_EXTERN int curl_mvfprintf
CURL_EXTERN int curl_mvsprintf
CURL_EXTERN int curl_mvsnprintf
CURL_EXTERN char *curl_maprintf
CURL_EXTERN char *curl_mvaprintf
CURL_EXTERN CURLM *curl_multi_init
CURL_EXTERN CURLMcode curl_multi_add_handle
CURL_EXTERN CURLMcode curl_multi_remove_handle
CURL_EXTERN CURLMcode curl_multi_fdset
CURL_EXTERN CURLMcode curl_multi_wait
CURL_EXTERN CURLMcode curl_multi_poll
CURL_EXTERN CURLMcode curl_multi_wakeup
CURL_EXTERN CURLMcode curl_multi_perform
CURL_EXTERN CURLMcode curl_multi_cleanup
CURL_EXTERN CURLMsg *curl_multi_info_read
CURL_EXTERN const char *curl_multi_strerror
CURL_EXTERN CURLMcode curl_multi_socket
CURL_EXTERN CURLMcode curl_multi_socket_action
CURL_EXTERN CURLMcode curl_multi_socket_all
CURL_EXTERN CURLMcode curl_multi_timeout
CURL_EXTERN CURLMcode curl_multi_setopt
CURL_EXTERN CURLMcode curl_multi_assign
CURL_EXTERN char *curl_pushheader_bynum
CURL_EXTERN char *curl_pushheader_byname
CURL_EXTERN CURLU *curl_url
CURL_EXTERN void curl_url_cleanup
CURL_EXTERN CURLU *curl_url_dup
CURL_EXTERN CURLUcode curl_url_get
CURL_EXTERN CURLUcode curl_url_set
CURL_EXTERN const char *curl_url_strerror
CURL_EXTERN const struct curl_easyoption *curl_easy_option_by_name
CURL_EXTERN const struct curl_easyoption *curl_easy_option_by_id
CURL_EXTERN const struct curl_easyoption *curl_easy_option_next
CURL_EXTERN CURLHcode curl_easy_header
CURL_EXTERN struct curl_header *curl_easy_nextheader
curl_strequal
curl_strnequal
curl_mime_init
curl_mime_free
curl_mime_addpart
curl_mime_name
curl_mime_filename
curl_mime_type
curl_mime_encoder
curl_mime_data
curl_mime_filedata
curl_mime_data_cb
curl_mime_subparts
curl_mime_headers
curl_formadd
curl_formget
curl_formfree
curl_getenv
curl_version
curl_easy_escape
curl_escape
curl_easy_unescape
curl_unescape
curl_free
curl_global_init
curl_global_init_mem
curl_global_cleanup
curl_global_sslset
curl_slist_append
curl_slist_free_all
curl_getdate
curl_share_init
curl_share_setopt
curl_share_cleanup
curl_version_info
curl_easy_strerror
curl_share_strerror
curl_easy_pause
curl_easy_init
curl_easy_setopt
curl_easy_perform
curl_easy_cleanup
curl_easy_getinfo
curl_easy_duphandle
curl_easy_reset
curl_easy_recv
curl_easy_send
curl_easy_upkeep
curl_easy_header
curl_easy_nextheader
curl_mprintf
curl_mfprintf
curl_msprintf
curl_msnprintf
curl_mvprintf
curl_mvfprintf
curl_mvsprintf
curl_mvsnprintf
curl_maprintf
curl_mvaprintf
curl_multi_init
curl_multi_add_handle
curl_multi_remove_handle
curl_multi_fdset
curl_multi_wait
curl_multi_poll
curl_multi_wakeup
curl_multi_perform
curl_multi_cleanup
curl_multi_info_read
curl_multi_strerror
curl_multi_socket
curl_multi_socket_action
curl_multi_socket_all
curl_multi_timeout
curl_multi_setopt
curl_multi_assign
curl_pushheader_bynum
curl_pushheader_byname
curl_easy_option_by_name
curl_easy_option_by_id
curl_easy_option_next
curl_url
curl_url_cleanup
curl_url_dup
curl_url_get
curl_url_set
curl_url_strerror
curl_ws_recv
curl_ws_send
curl_ws_meta
</stdout>
</verify>

31
tests/data/test1279 Normal file
View File

@ -0,0 +1,31 @@
<testcase>
<info>
<keywords>
source analysis
CURL_EXTERN
libcurl.def
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<name>
Verify libcurl.def against CURL_EXTERN declarations
</name>
<command type="perl">
%SRCDIR/extern-scan.pl --heading=EXPORTS --sort %SRCDIR/..
</command>
</client>
<verify>
<stdout loadfile="%SRCDIR/../libcurl.def">
</stdout>
</verify>
</testcase>

View File

@ -28,18 +28,41 @@
use strict;
use warnings;
# we may get the dir root pointed out
my $root=$ARGV[0] || ".";
my $sort = 0;
my @incs = (
"$root/include/curl/curl.h",
"$root/include/curl/easy.h",
"$root/include/curl/mprintf.h",
"$root/include/curl/multi.h",
"$root/include/curl/urlapi.h",
"$root/include/curl/options.h",
"$root/include/curl/header.h",
);
# we may get the dir root pointed out
my $root = shift @ARGV;
while(defined $root) {
if($root =~ /--heading=(.*)/) {
print "$1\n";
$root = shift @ARGV;
next;
}
elsif($root =~ /--sort/) {
$sort = 1;
$root = shift @ARGV;
next;
}
last;
}
if(!defined $root) {
$root = ".";
}
$root = "$root/include/curl";
opendir(D, "$root") || die "Cannot open directory $root: $!\n";
my @dir = readdir(D);
closedir(D);
my @incs;
foreach (sort(@dir)) {
if($_ =~ /\.h$/) {
push(@incs, "$root/$_");
}
}
my $verbose=0;
my $summary=0;
@ -49,8 +72,8 @@ my @syms;
my %doc;
my %rem;
sub scanheader {
my ($f)=@_;
my @out;
foreach my $f (@incs) {
open H, "<$f" || die;
my $first = "";
while(<H>) {
@ -59,7 +82,8 @@ sub scanheader {
if (/^(^CURL_EXTERN .*)\(/) {
my $decl = $1;
$decl =~ s/\r$//;
print "$decl\n";
$decl =~ /([a-z_]+)$/;
push(@out, "$1");
}
elsif (/^(^CURL_EXTERN .*)/) {
# handle two-line declarations
@ -72,7 +96,8 @@ sub scanheader {
my $decl = $1;
$decl =~ s/\r$//;
$first .= $decl;
print "$first\n";
$first =~ /([a-z_]+)$/;
push(@out, "$1");
}
$first = "";
}
@ -80,6 +105,10 @@ sub scanheader {
close H;
}
foreach my $i (@incs) {
scanheader($i);
if($sort) {
@out = sort(@out);
}
foreach (@out) {
print("$_\n");
}

View File

@ -1195,6 +1195,19 @@ sub singletest_check {
my @stripfile = getpart("verify", "stripfile");
my @validstdout = getpart("verify", "stdout");
# get all attributes
my %hash = getpartattr("verify", "stdout");
my $loadfile = $hash{'loadfile'};
if ($loadfile) {
open(my $tmp, "<", "$loadfile") || die "Cannot open file $loadfile: $!";
@validstdout = <$tmp>;
close($tmp);
# Enforce LF newlines on load
s/\r\n/\n/g for @validstdout;
}
if (@validstdout) {
# verify redirected stdout
my @actual = loadarray(stdoutfilename($logdir, $testnum));
@ -1213,9 +1226,6 @@ sub singletest_check {
@actual = @newgen;
}
# get all attributes
my %hash = getpartattr("verify", "stdout");
# get the mode attribute
my $filemode=$hash{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {