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

use C++ for unit tests #646

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

aws-nslick
Copy link
Contributor

feat(test): parse as c++ source

All included headers are fully safe to be parsed as C++, so these unit
tests can now use C++. Rename them to `.cc' files and use a few c++
keywords to enforce that the compiler is actually treating them as such.
Actual C++ cleanups to follow later, hopefully alongside a unit test
framework like gtest or catch2.

Signed-off-by: Nicholas Sielicki [email protected]

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aws-nslick aws-nslick requested review from rajachan, bwbarrett, rauteric and a team as code owners October 4, 2024 06:33
@aws-nslick aws-nslick changed the title Cpp unittests use C++ for unit tests Oct 4, 2024
@aws-nslick aws-nslick force-pushed the cpp-unittests branch 5 times, most recently from 603dc15 to 4ac7d2b Compare October 5, 2024 23:54
@bwbarrett
Copy link
Contributor

I had comments on some of the early patches in this PR from other PRs, so dont' feel comfortable approving the PR. That said, the last commit (the uniq one across your PRs) looks good to me.

@aws-nslick aws-nslick force-pushed the cpp-unittests branch 4 times, most recently from 3e2ca3b to 6f2180b Compare October 9, 2024 20:00
@aws-nslick aws-nslick force-pushed the cpp-unittests branch 4 times, most recently from 6dfbcec to 5243aa5 Compare November 7, 2024 23:56
@aws-nslick aws-nslick added this to the 2.0 milestone Nov 14, 2024
g++7 fails to initialize C-style tagged unions with the following error
message:

> sorry, unimplemented: non-trivial designated initializers not
> supported

Note that gcc7 handles this fine when the file is parsed as C, as well
as g++8 and beyond, and the problem only exists when operating in C++
mode under g++7. AL2 is still using this ancient toolchain, so add a
hack in the case that it is used. This is pretty horrible, and should be
cleaned up sooner rather than later.

Signed-off-by: Nicholas Sielicki <[email protected]>
bad74fc re-triggered -Wnarrowing on rebase. The natural type of the
array rvalue here is size_t[] because it's defined in terms of the
stripe size, and the stripe size array is size_t[]. The entire rval is
then implicitly converted to int[] through assignment, which causes
narrowing. Offsets here should just be size_t in the first place,
though, as it's what the uut is expecting.

Signed-off-by: Nicholas Sielicki <[email protected]>
On builds where lttng is enabled, the inclusion of nccl_ofi_tracepoint.h
pulls in <lttng/ust-utils.h>, which defines templates when __cplusplus
is defined without restraint. Those templates cannot have C linkage.

This file does not really need nccl_ofi_tracepoint.h; it only needs
config.h to test for whether NVTX tracing is enabled, and then it needs
nvtx3 headers in the case that it is so that it may define storage for
the nvtx domain handles.

Signed-off-by: Nicholas Sielicki <[email protected]>
All included headers are fully safe to be parsed as C++, so these unit
tests can now use C++. Rename them to `.cc' files and use a few c++
keywords to enforce that the compiler is actually treating them as such.
Actual C++ cleanups to follow later, hopefully alongside a unit test
framework like gtest or catch2.

Signed-off-by: Nicholas Sielicki <[email protected]>
@rauteric
Copy link
Contributor

rauteric commented Dec 3, 2024

I'm confused that #733 has the same commits as this PR, but that one is passing GitHub workflows and this one is not.

@bwbarrett
Copy link
Contributor

looks like you forgot to update the endpoint hash table unit test.

@bwbarrett
Copy link
Contributor

I'm confused that #733 has the same commits as this PR, but that one is passing GitHub workflows and this one is not.

The offending unit test was removed in that patch series.

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.

3 participants