-
Notifications
You must be signed in to change notification settings - Fork 675
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
Added Common++ unit test project based on Gtest. #1507
base: dev
Are you sure you want to change the base?
Conversation
- Added IPAddress multicast unit tests. - Added IPNetwork includes unit tests. - Formatting
…L as it does not consider functions in the global namespace. - Pulled operator<< for IpAddress into the `pcpp` namespace. - Pulled operator<< for IpV4Address into the `pcpp` namespace. - Pulled operator<< for IpV6Address into the `pcpp` namespace. - Pulled operator<< for IpNetwork into the `pcpp` namespace. - Pulled operator<< for IpV4Network into the `pcpp` namespace. - Pulled operator<< for IpV6Network into the `pcpp` namespace. - Pulled operator<< for MacAddress into the `pcpp` namespace.
…s of the same nature.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1507 +/- ##
==========================================
- Coverage 83.14% 81.98% -1.16%
==========================================
Files 276 282 +6
Lines 47315 47978 +663
Branches 9528 9893 +365
==========================================
- Hits 39338 39334 -4
- Misses 7089 7944 +855
+ Partials 888 700 -188
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
So far, it hasn't been integrated into the workflow or the codecov as I'm not really sure how precisely that is achieved. |
@Dimi1010 @tigercosmos @egecetin @clementperon let's discuss this change: if we want to move away from the existing tests infra I think it should be a consternated effort to migrate all tests to Gtest. It'll take time, but may be feasible if all of us are working on it together. The question is: can we all commit to work on it before the next version? |
@seladb What is the expected date of the new release? If it will be about 25.04 it is easy to work on it by planning. The more important question is, we talked about the gtest in #1463 to improve performance. Is everyone thinking moving Gtest is better, or anyone have any doubts (for performance, maintainability or maybe interface related)? It is better to share it if have any, before starting to work. In my opinion, it will reduce maintaining requirements because of gtest has lots of developers and they already fix their bugs and has a good interface for a C++ code and have integration with the external tools/extensions but for performance I don't expect a drastically improvement. So, I think moving to gtest is feasible. |
I hope we can release faster, hopefully before 25.04. To be honest, I don't think performance is a good enough reason to switch to Gtest. The main reason would be having more standardize code and less custom-made stuff. But as I mentioned, it will require a lot of work (and most of it is boring - rewrite tests...), so the question is - can we commit to that and do we think it's worth the effort? |
I think it will be beneficial overall. The rollout can be done in phases (project by project) similar to the way we did the clang-format roll out. I could probably work through it slowly as I get free time. Also, a lot of the current tests could probably benefit by the expanded non-critical failure support, I know we have something similar in the PTF framework but its not exactly the same. In GTest a non-critical failure (EXPECT_*) the test is still marked as failed, but continues to run to catch other errors in the unit test if they exist. Fatal failures (ASSERT_*) are mostly used for conditions that invalidate the rest of the unit test. The fact that the current framework only catches 1 error per unit test has been somewhat annoying to me. |
The difference between this and clang-format is that this project will be much slower and more tedious because we need to go over all the tests and port them one by one. Maybe we can open a separate branch for it so we don't merge unfinished work to Anyway, this will require more time and commitment from everyone, and I wonder if we can/want to do it. However, if we open a separate branch and it doesn't block anything then the risk is quite minimal 🤔
|
Summary
This PR introduces dedicated unit tests for the Common++ module based on the GoogleTest framework as well as several minor improvements.
What's Changed?
Unit tests
Test/Common++
has been added with unit tests.IPAddress
,IPv4Address
,IPv6Address
- tests provided inIPAddressTests.cpp
IPNetwork
,IPv4Network
,IPv6Network
- tests provided inIPAddressTests.cpp
MacAddress
- tests provided inMacAddressTests.cpp
PointereVector<T>
- tests provided inPointerVectorTests.cpp
LRUList<T>
- tests provided inLRUListTests.cpp
byteArrayToHexString
- tests provided inGeneralUtilsTests.cpp
hexStringToByteArray
- tests provided inGeneralUtilsTests.cpp
cross_platform_memmem
- tests provided inGeneralUtilsTests.cpp
align
- tests provided inGeneralUtilsTests.cpp
googletest
(v1.12.0) during the cmake build process.googletest
macro definitions for pre-commit'scppcheck
step.MemoryLeakDetectorTest
that can be used to extend a unit test to check for memory leaks.MemPlumber
implementation to detect memory leaks.Fixes and additions
MacAddress
that takes anstd::array<uint8_t, 6>
.pcpp::literals
containing literals for quickly constructingIPv4Address
(_ipv4
) andIPv6Address
(_ipv6
).std::ostream
operator<<
overloads for inside thepcpp
namespace to fix ADL resolution issues for the following classes:IPAddress
IPv4Address
IPv6Address
IPNetwork
IPv4Network
IPv6Network
MacAddress