Re: C Unit testing and mocking
| From: | Christoph M. Becker | Date: | Thu, 19 Dec 2024 12:09:56 +0000 |
| Subject: | Re: C Unit testing and mocking | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-126136@lists.php.net to get a copy of this message | ||
On 16.12.2024 at 21:05, Christoph M. Becker wrote:
> Especially on Windows, where we have different code paths, and sometimes
> even completely different code, it would be great to also have these
> unit tests. Given that link.exe supports /alternatename, a bit of
> additional macro magic might do the trick[2]. I'll try to have a stab
> at this soon.
I had a closer look, and it's getting pretty tricky. First, we would
need a static php.lib (doable, but so far not supported by the build
system). Then, apparently, we would need to get rid of the
__declspec(dllimport) at least for the functions we want to mock when
building php.lib; to do that it might be necessary to use modified
copies of the WindowSDK headers. Ugly.
And then we might need an own unit test suite for Windows; at least as
is, test_network.c makes quite some assumptions regarding code paths
(e.g. that poll(2) is called), which are not portable. I'm not sure
it's worth pursuing this for other platforms than Linux.
Christoph