Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: ensure libcurl.def contains all exports #11570

Closed
wants to merge 15 commits into from

Conversation

vszakats
Copy link
Member

@vszakats vszakats commented Aug 1, 2023

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 2ebc74c

Closes #11570

@vszakats
Copy link
Member Author

vszakats commented Aug 1, 2023

I'd preferred using tests/extern-scan.pl to extract the CURL_EXTERN list, but that script has extra bits in its output. Can those be deleted and the raw symbol names kept? It's also missing websockets.h.

@bagder
Copy link
Member

bagder commented Aug 1, 2023

Can those be deleted and the raw symbol names kept?

That seems reasonable. extern-scan.pl is (only) used by test 1135, so it's just a matter of making sure that is still happy.

@vszakats
Copy link
Member Author

vszakats commented Aug 1, 2023

Updated the Perl script to use raw symbol names, added websockets functions, then reused it from the GHA task.

@bagder
Copy link
Member

bagder commented Aug 2, 2023

Hm, on second thoughts. Couldn't perhaps test 1135 get extended to do this check as well or something? It would be nice if we could detect this problem locally already when working on a new thing.

@vszakats
Copy link
Member Author

vszakats commented Aug 2, 2023

Forgot about the local aspect, but indeed, this would be useful. I just have idea how to implement it there. Would need to sort results, insert EXPORTS on top and compare with the external file.

@vszakats
Copy link
Member Author

vszakats commented Aug 2, 2023

Gave it a try, terrible Perl practices beware.

Having symbols sorted isn't strictly necessary (and might even be a bad thing if DLL users rely on export ordinals, though I don't think anyone would do that on Windows specifically). With extern-scan.pl the raw order is also stable (as long as the declarations in the headers are), so might as well drop it. Though I prefer to keep lists sorted if possible.

UPDATE: I've updated the logic to omit sorting, this allowed to integrate the libcurl.def check into existing test1135. But, I'm now wondering what the VMS / OS/400-related comment in test1135 means and whether we should move that comment to libcurl.def itself? I'm not sure how the existing solution would ensure that we always append new symbols to the end of the list. E.g. a new 'easy' API can only be added in the middle of the whole list, even if adding it as last inside easy.h. I must be missing something.

# The VMS and OS/400 builds extract the CURL_EXTERN protos and use in
# the build. We break binary compatibility by changing order. Only add
# new entries last or bump the SONAME.

@vszakats vszakats force-pushed the gha-check-libcurl-def branch 2 times, most recently from 5755fea to 58493df Compare August 2, 2023 13:42
@vszakats vszakats changed the title gha: ensure libcurl.def matches exports from headers tests: ensure libcurl.def contains all exports Aug 2, 2023
@dfandrich
Copy link
Contributor

dfandrich commented Aug 2, 2023 via email

@vszakats
Copy link
Member Author

vszakats commented Aug 2, 2023

@dfandrich Seems doable, it'd need a parser that extracts those extern symbols from curl.inc.in. Then sort it, along with libcurl.def, then compare them. There still remains a lot of details that can go out of sync with curl headers.

There is also a gnv_libcurl_symbols.opt for VMS. Similar to libcurl.def, with (much) more boilerplate and a hand-crafted symbol order for compatibility. Also outdated.

As a consequence, change libcurl.def to use a non-sorted list of
exports. It's less tidy, but more compatible and attempts to keep the
original intent of this test to keep VMS and OS/400 happy by not
changing symbol order and always append new items.

I'm not quite sure how this works in practice, as the order of the
headers checked is fixed, so say a new easy API cannot be added to the
end of the whole list. I might be missing something.

We may or may not want to move this comment from test1135 to libcurl.def
itself:

```
; The VMS and OS/400 builds extract the CURL_EXTERN protos and use in
; the build. We break binary compatibility by changing order. Only add
; new entries last or bump the SONAME.
```
This fixes finding the external file.
@vszakats
Copy link
Member Author

vszakats commented Aug 2, 2023

Settling on a version that keeps libcurl.def sorted and adds a separate test for it.

The next issue is that tests/extern-scan.pl needs a manually maintained list of libcurl headers. I might tackle that.

@@ -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"]>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this was a cool idea. Me like!

tests/extern-scan.pl Outdated Show resolved Hide resolved
@vszakats vszakats closed this in db70846 Aug 3, 2023
@vszakats vszakats deleted the gha-check-libcurl-def branch August 3, 2023 11:08
ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
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 2ebc74c

Closes curl#11570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build CI Continuous Integration tests
Development

Successfully merging this pull request may close these issues.

None yet

3 participants