Add unit test setup with php_network_connect_socket test #16987
+285
−0
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.
This PR introduces new unit tests using cmocka. The idea is to use those tests for things that are very hard to test using the integration tests (especially the networking related stuff).
Currently it just contains a test for
php_network_connect_socket
that was used for testing #16606 (this was initially introduced as part of that PR but separated here to give more time for review).The build is a bit rusty (single Makefile) but it depends on php-src build to be done first so libphp.a is available. It means it requires a minimal php-src build (
./configure --disable-all --enable-embed=static
). Not sure how to best integrate it to the php-src build so I just chose to have it separate. Maybe @petk can have some suggestions how to improve the build here. It might be also an option to create a separate configure.ac as it should probably check that--wrap
is available (e.g. it's not available on OSX) and cmocka installed.Also it might be worth to add it to the pipeline. This could actually be limited to just specific paths (path filter) so it runs only if the files that are unit tested are changed (in this case it would be just
main/network.c
)