-
Notifications
You must be signed in to change notification settings - Fork 32
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
Wire up support for selftests #102
Open
pks-t
wants to merge
9
commits into
clar-test:main
Choose a base branch
from
pks-t:pks-selftests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+863
−108
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pks-t
force-pushed
the
pks-selftests
branch
30 times, most recently
from
September 7, 2024 05:51
eb1eb99
to
ad46565
Compare
pks-t
force-pushed
the
pks-selftests
branch
9 times, most recently
from
September 7, 2024 07:30
26ec063
to
a041ee9
Compare
pks-t
force-pushed
the
pks-selftests
branch
from
September 19, 2024 15:21
a041ee9
to
8f76ae8
Compare
pks-t
changed the title
WIP: Wire up support for selftests
Wire up support for selftests
Sep 19, 2024
pks-t
force-pushed
the
pks-selftests
branch
from
September 19, 2024 15:29
8f76ae8
to
aa65c47
Compare
When raising an error we print the current file, line and function where the error was raised. This is of course quite helpful to users, but it stands in the way of testing the clar because they make the output of executables dependent on the developer's setup. Add the ability to override these with fixed constants via a new `CLAR_SELFTEST` macro.
We use `exit(-1)` in a lot of places. Exit codes should be in the range of [0, 255] though, so the resulting behaviour is not defined and depends on the platform. Fix this by using `exit(1)` instead.
The "%p" formatter has platform-specific behaviour. On Windows for example it prints as a zero-padded integer, whereas on glibc systems it prints as non-zero-padded integer with "0x" prepended. Address this by instead using PRIxPTR and casting the pointers to the `uintptr_t` type.
The examples are closely coupled with our selftests, which makes it hard to iterate on both. Split them out into their own standalone directory as a prerequisite for wiring up proper testing of the clar.
We are about to wire up proper testing of clar via CI. This will be done by executing the "clar_test" binary we already have in another clar test binary. This requires us to move the current "clar_test" into its own subdirectory such that "generate.py" can then generate the "clar.suite" for each of these two test binaries independently.
The global test counter has been added as a demonstration for how it is possible to modify global resources. Now that we have moved examples into their own directory though it no longer serves that purpose. In fact, it now stands in our way as we are about to introduce testing of the clar itself with various different options. But as we assert that the counter is "8" after all tests have ran, we wouldn't be able to exclude some tests from running. Drop the counter altogether to prepare for the change.
The output for the test that exercise `cl_assert_equal_p()` is indeterministic because we compare on-stack addresses, which naturally change between executions. Adapt the test to instead use fixed values.
While we have had the "clar_test" binary for a very long time already, it was more for demonstration purposes than for real testing of the clar. It could serve as sort of a smoke test if the developer remembered to execute it, but that's about it. In the preceding commits we have moved the "clar_test" into a separate directory, renamed it to "selftest_suite" and made its output deterministic. We can thus now wire up proper testing of the clar by exercising the "selftest_suite" binary via a new "selftest" binary. These tests run the "selftest_test" binary with various different arguments and check both its return code as well as its output.
pks-t
force-pushed
the
pks-selftests
branch
from
September 19, 2024 15:38
aa65c47
to
2dd6ec9
Compare
Wire up support for testing in our CI now that we have proper self tests.
pks-t
force-pushed
the
pks-selftests
branch
from
September 20, 2024 04:20
2dd6ec9
to
e088b4d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on CMake support added via #100.