Re: C Unit testing and mocking
On Thu, Dec 19, 2024 at 1:10 PM Christoph M. Becker <[email protected]>
wrote:
> 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.
>
>
Agreed that running the tests on Windows might not be worth the effort.
However, many of the tests likely aren't strictly Linux-specific, so even
if they only run on Linux, they can still help improve the quality of code
across all platforms. So it's good for Windows as well :)
Regards,
Jakub
Thread (13 messages)