Skip to content

Conversation

@mbyx
Copy link
Contributor

@mbyx mbyx commented Aug 13, 2025

Description

Ports the linux platform to also be tested using ctest-next.

Blocked on #4674.

For now it skips tests for pid_type and proc_cm_event C enums (technically they weren't tested before either) because C seems to hide them in userspace.

Sources

Checklist

  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot rustbot added the ctest Issues relating to the ctest crate label Aug 13, 2025
@mbyx mbyx force-pushed the libc-test-linux-port branch from 8811208 to fe15673 Compare August 13, 2025 05:47
@mbyx
Copy link
Contributor Author

mbyx commented Aug 13, 2025

Uh oh, I forgot that the enum problem still existed. The other error seems to be a missing cfg probably. This will probably be blocked for a bit longer then.

@mbyx mbyx force-pushed the libc-test-linux-port branch 2 times, most recently from 4b1f6b9 to ba39417 Compare August 13, 2025 05:57
@mbyx
Copy link
Contributor Author

mbyx commented Aug 13, 2025

So the temporary fix to the enum problem mostly works, but it does still seem like pid_type and its constants are not being found. I'd like to wait a bit longer on this port, and actually figure out why the original ctest does not have to deal with these enums.

@mbyx
Copy link
Contributor Author

mbyx commented Aug 14, 2025

I tested in a completely new crate with the old ctest cloned beside it, it seems that it can't detect an item wrapped inside of the c_enum macro, effectively hiding it from ctest.

Then I started doing some print debugging in the old ctest, and from what I can understand, given a crate that only has the c_enum macro and an invocation of that macro, after expanding the crate with

let krate = ecx.monotonic_expander().expand_crate(krate);

it seems to just leave the macro definition behind, deleting the invocation in its internal representation.

Then I switched to a crate with only the s and __item macros and an invocation of s, but mysteriously that worked without issue. Same with the e and __item macros.

At first I thought it was because of a lack of using __item in c_enum, so I modified c_enum to use it, but even that didn't work.

So I think that all this time ctest has just quietly been ignoring c_enum invocations. (Which would be easy to check, just run libc-test on linux and look at the generated files, (I can't because the original ctest fails on WSL for me it does actually generate the files at least, and they don't have any item that was inside of a c_enum invocation).

@mbyx
Copy link
Contributor Author

mbyx commented Aug 14, 2025

Assuming that in fact c_enum hasn't been checked at all, then for most cases, just adding the enum keyword for known c_enums should work. This is also what worked for freebsd.

Here however, exactly one enum pid_type, seems to be missing, despite being included from sched.h. Is pid_type somehow made private on the C side?

// deprecated since glibc >= 2.29. This allows Rust binaries to link against
// glibc versions older than 2.29.
cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None);
cfg.skip_private(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is done in the global config now, right?

@tgross35 tgross35 changed the title Libc test linux port libc-test: Switch Linux to ctest-next Aug 15, 2025
@mbyx mbyx force-pushed the libc-test-linux-port branch 4 times, most recently from 3f4b787 to b05917e Compare August 15, 2025 10:44
@mbyx
Copy link
Contributor Author

mbyx commented Aug 15, 2025

If pid_type can't be tested, then its best to block this on #4658, so that skipping pid_type is just a one liner.

@mbyx mbyx force-pushed the libc-test-linux-port branch 2 times, most recently from f0758a0 to ee837ae Compare August 21, 2025 08:25
@mbyx
Copy link
Contributor Author

mbyx commented Aug 21, 2025

Just one error left. It seems to be related to 64 and 32 bit time. The test fails on a 32 bit platform with 64 bit time, so it wants to use __suseconds_t but can't find it. @tgross35, would this be related to the multiple time related PRs or is it just a cfg issue?

EDIT: It was the same issue as everything else has been so far, the target wasn't specified for expansion correctly.

@mbyx mbyx requested a review from tgross35 August 28, 2025 08:55
@mbyx mbyx force-pushed the libc-test-linux-port branch 2 times, most recently from f513922 to e73a576 Compare August 29, 2025 10:58
@mbyx mbyx marked this pull request as ready for review August 29, 2025 11:14
@mbyx mbyx force-pushed the libc-test-linux-port branch from e73a576 to 8b3dd58 Compare August 30, 2025 14:34
@tgross35 tgross35 added this pull request to the merge queue Sep 1, 2025
Merged via the queue into rust-lang:main with commit 6f115e5 Sep 1, 2025
50 of 52 checks passed
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Sep 19, 2025
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 22, 2025
(backport <rust-lang#4647>)
(cherry picked from commit 6f115e5)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 22, 2025
(backport <rust-lang#4647>)
(cherry picked from commit 6f115e5)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Sep 22, 2025
(backport <rust-lang#4647>)
(cherry picked from commit 6f115e5)
@tgross35 tgross35 mentioned this pull request Sep 22, 2025
github-merge-queue bot pushed a commit that referenced this pull request Sep 22, 2025
(backport <#4647>)
(cherry picked from commit 6f115e5)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctest Issues relating to the ctest crate stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants