Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:126168
X-Original-To: internals@lists.php.net
Delivered-To: internals@lists.php.net
Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5])
	by qa.php.net (Postfix) with ESMTPS id 955801A00BD
	for <internals@lists.php.net>; Sun, 22 Dec 2024 15:30:55 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1734881273; bh=xQDL95H57V6jcASuoInP8EXgui9jKyyFJOiPZ4yE3/s=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc:From;
	b=E6lqY+hRMeTHbB8hHDo78tgn+V9cRItcokWG89MUTcfB2aZ0vyWSWrjhJGjlT2o3u
	 WXTvECacyTdQLdKVOv/AhRo0i42SA5ZXUXzVsOlfJAZKcO1suLZibPO4SaGQxbE35Z
	 6FAdGzDn17jSUH/0Au/HXrUACx22AuRQI19HXoYrTDldoCkg2azXDAd/4F2IdwKd95
	 bYxAD7ALCORJkaRVvdUNHVJbIpV+tjvF+aQNlqRSK6qKTeyPJRxbcmDLbxRgH9ALDN
	 ynYP48thZskHDeztapM2H+uNchXPwymr64sLwHIC3hsZh9ZUviDKxIR9vNiyY8MzG2
	 wNf5NLiJJfh+g==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id D5068180069
	for <internals@lists.php.net>; Sun, 22 Dec 2024 15:27:52 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Level: *
X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_50,DMARC_NONE,
	FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,
	HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,
	SPF_PASS autolearn=no autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <jakub.php@gmail.com>
Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by php-smtp4.php.net (Postfix) with ESMTPS
	for <internals@lists.php.net>; Sun, 22 Dec 2024 15:27:52 +0000 (UTC)
Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-29e5c0c46c3so1968999fac.3
        for <internals@lists.php.net>; Sun, 22 Dec 2024 07:30:53 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1734881453; x=1735486253;
        h=cc:to:subject:message-id:date:from:in-reply-to:references
         :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
         :reply-to;
        bh=soCvArW0u7EUss4j4C/6MLItPAJGZUkLzykzqyB5PHI=;
        b=hTCx0CZcBwZL+xX14rtAw+vJIN9/OSKObvg8UlRgXRrYJbdsGvYXcH+a4f6veg2oYD
         8f3DY8AmeEfldQ/zBAvX8ZgnSjDz2wSCRpZSLf98tkead2MxQE/khMXYEPI9ECD6eo6a
         f8AlEVjQSkamWMe6yDFgxTMxPzW8TBCuwYnYGaJdNxQRn6H1FjU9nEXoCRDlkBx73tV2
         6xPqcNd3kqD7dz5iG0b02jo3NZ0GPzLgzAriEE3GR5Z7shKmHZ78CcUswi74CQyfFENE
         vbcovPRia4sEqc/ubbm69ojhb2sL4sK5w4PTV7HVrB+LmxQWC1YemETJraa/tBRp3mSl
         3qhw==
X-Gm-Message-State: AOJu0YyyLmXgYelAFSUrMgRA9mFDO2TnaFnT+oqi9mO40HSJ6xsm+1dW
	oPMOJEmtFoFJiZlZLMLiOi2kYIaSCl4sX2R7GWcGLX/c4E14vxjNAoa5BIrbuAxEvMQv5OZ1w6F
	lYlnYdDbq9uz6keShvqv4X+9B54A=
X-Gm-Gg: ASbGnct3dNPZuAL2cUdKqFmiYez4j8nI8aL2c3uGTnY46Kfyi1e+IiS89ZMf2WZYP09
	u+qu3JHGcH/jk4O7+13e3Gh6xneqsxJG25Xgd
X-Google-Smtp-Source: AGHT+IHvUIrnkwiniGWDYB0ljr6mEcHsJKYwwgYzp3WicuMozol6jNOwfcRDbQIGOfRrwkvMR5OEiRwvLi6e/1zGwHs=
X-Received: by 2002:a05:6870:8928:b0:29e:6814:19d with SMTP id
 586e51a60fabf-2a7fb18a63emr6060828fac.9.1734881453448; Sun, 22 Dec 2024
 07:30:53 -0800 (PST)
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
References: <CAEKnhAEFJKPWWL0EKu_JBPgwBEe+Pk3GDzR7HQm3J-g7=Wk0BA@mail.gmail.com>
 <7228b901-a6a9-4aa9-8425-5ad51f66a853@gmx.de> <a77ccf73-f451-435b-bbbc-ee6ffcf0e52c@gmx.de>
In-Reply-To: <a77ccf73-f451-435b-bbbc-ee6ffcf0e52c@gmx.de>
Date: Sun, 22 Dec 2024 16:30:42 +0100
Message-ID: <CAEKnhAF4_CUB27jT1NxEALi9HjF7pOj4AHS6zT6eqB1Mt9u8Bw@mail.gmail.com>
Subject: Re: [PHP-DEV] C Unit testing and mocking
To: "Christoph M. Becker" <cmbecker69@gmx.de>
Cc: PHP internals list <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="000000000000c2a46a0629dd907f"
From: bukka@php.net (Jakub Zelenka)

--000000000000c2a46a0629dd907f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 19, 2024 at 1:10=E2=80=AFPM Christoph M. Becker <cmbecker69@gmx=
.de>
wrote:

> On 16.12.2024 at 21:05, Christoph M. Becker wrote:
>
> > Especially on Windows, where we have different code paths, and sometime=
s
> > 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

--000000000000c2a46a0629dd907f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote g=
mail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Dec 19,=
 2024 at 1:10=E2=80=AFPM Christoph M. Becker &lt;<a href=3D"mailto:cmbecker=
69@gmx.de">cmbecker69@gmx.de</a>&gt; wrote:<br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex">On 16.12.2024 at 21:05, Christoph M. Becker wro=
te:<br>
<br>
&gt; Especially on Windows, where we have different code paths, and sometim=
es<br>
&gt; even completely different code, it would be great to also have these<b=
r>
&gt; unit tests.=C2=A0 Given that link.exe supports /alternatename, a bit o=
f<br>
&gt; additional macro magic might do the trick[2].=C2=A0 I&#39;ll try to ha=
ve a stab<br>
&gt; at this soon.<br>
<br>
I had a closer look, and it&#39;s getting pretty tricky.=C2=A0 First, we wo=
uld<br>
need a static php.lib (doable, but so far not supported by the build<br>
system).=C2=A0 Then, apparently, we would need to get rid of the<br>
__declspec(dllimport) at least for the functions we want to mock when<br>
building php.lib; to do that it might be necessary to use modified<br>
copies of the WindowSDK headers.=C2=A0 Ugly.<br>
<br>
And then we might need an own unit test suite for Windows; at least as<br>
is, test_network.c makes quite some assumptions regarding code paths<br>
(e.g. that poll(2) is called), which are not portable.=C2=A0 I&#39;m not su=
re<br>
it&#39;s worth pursuing this for other platforms than Linux.<br><br></block=
quote><div><br></div><div>Agreed that running the tests on Windows might no=
t be worth the effort. However, many of the tests likely aren&#39;t strictl=
y Linux-specific, so even if they only run on Linux, they can still help im=
prove the quality of code across all platforms. So it&#39;s good for Window=
s as well :)<br></div><div><br></div><div>Regards,</div><div><br></div><div=
>Jakub</div></div></div>

--000000000000c2a46a0629dd907f--