-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add unit test setup with php_network_connect_socket test #16987
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
base: master
Are you sure you want to change the base?
Conversation
It might be a good idea to pursue the RFC process, if we want to introduce a new unit testing framework. Besides that these tests need maintainance, there might be other options than cmocka.
Maybe we could have a dedicated SAPI (or possible use embed)? |
So I did some comparison and decided to just sum it up on internals and open the discussion there. Unless there are some objections I don't feel we necessarily need RFC as it is just an internal change (most votes don't care about this). In terms of maintenance, if it's limited to only critical parts, it should be fine but of course there is a bit extra thing to check but I think it's for good.
I think embed SAPI is fine for now as it has all that is currently needed. |
We are adding extra (non-phpt) test suites in [1] and [2]. In order to avoid touching CI files too often (which are maintained in 8.1 and merged in upper branches), we add a single entry point to call the extra tests. The entry point can be updated in branches without synchronizing all the way from 8.1. CI files still need to be touched to install dependencies of these tests, but this should be manageable as these do not change often and are the same in every branch. Closes GH-19242. [1] #16987 [2] #18939
11190fa
to
ef8c917
Compare
ef8c917
to
44316e4
Compare
run: | | ||
set -x | ||
cd tests/unit | ||
make test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest adding a trailing newline
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
)