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: replace fake_criterion_tests section with __attribute__((constructor))s adding to a linked list, fixing the padding bug #474

Merged
merged 3 commits into from
Dec 4, 2024

Conversation

kkysen
Copy link
Contributor

@kkysen kkysen commented Dec 3, 2024

The previous way of appending struct fake_criterion_tests by putting them into a section was buggy because extra padding was added between the elements in the section, so iterating through them from __{start,stop}_fake_criterion_tests didn't work correctly.

This new way uses __attribute__((constructor)) to add each struct fake_criterion_test to a singly linked list. A singly linked list is used for simplicity, though it does mean the tests are run in reverse order within a file, but I don't really think the test order should matter, so this should be okay.

I also added the suite and test name to struct fake_criterion_test and print them out when running tests, which was helpful in distinguishing which tests were being run.

@kkysen kkysen requested a review from ayrtonm December 3, 2024 18:42
…nstructor))`s adding to a linked list, fixing the padding bug

* Fixes #473.

The previous way of appending `struct fake_criterion_test`s by putting them into a section
was buggy because extra padding was added between the elements in the section,
so iterating through them from `__{start,stop}_fake_criterion_tests` didn't work correctly.

This new way uses `__attribute__((constructor))` to add each `struct fake_criterion_test`
to a singly linked list. A singly linked list is used for simplicity,
though it does mean the tests are run in reverse order within a file,
but I don't really think the test order should matter, so this should be okay.
@kkysen kkysen force-pushed the kkysen/fix-fake_criterion_test-iteration branch from e9367d6 to b32c3ce Compare December 3, 2024 18:56
@kkysen kkysen requested a review from ayrtonm December 3, 2024 18:57
@kkysen kkysen merged commit 45c8133 into main Dec 4, 2024
34 checks passed
@kkysen kkysen deleted the kkysen/fix-fake_criterion_test-iteration branch December 4, 2024 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fake_criterion_tests iteration is broken due to padding
2 participants