Re: [PATCH] Improve code coverage of network address functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Cc: Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Improve code coverage of network address functions
Date: 2025-01-20 19:35:26
Message-ID: 3078101.1737401726@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> writes:
> On Thu, Oct 31, 2024 at 9:30 AM Aleksander Alekseev
> <aleksander(at)timescale(dot)com> wrote:
>> Recently I played with lcov [1]. In the process it was discovered that
>> the following functions are not executed by our tests:
>>
>> - abbrev(inet)
>> - set_masklen(cidr,int4)
>> - netmask(inet)
>> - hostmask(inet)

> The new tests for the first four look reasonable to me.

Agreed.

>> - inet_client_addr()
>> - inet_client_port()
>> - inet_server_addr()
>> - inet_server_port()

> These may be more controversial. (Personally, I'm -0.5.) I agree that
> making sure they exist/don't crash is a benefit, but to use my machine
> as an example, the interesting code with crash potential in
> inet_server_addr() still isn't exercised during `meson test`.

Yeah, I think that on normal testing setups where the test client is
connecting via a Unix socket, we are not going to get any useful
coverage this way. It used to be that we might get coverage on
Windows builds, but even that isn't true anymore IIUC. So I'm
inclined to leave this out as not worth the cycles.

> (A test
> driver in src/test/modules, which could pull the socket information to
> verify it, might be a better way to go.)

To do anything interesting, the test would have to make the server
open a TCP port, which would be rightly seen as a security hazard.
So it'd have to be confined to a not-run-by-default test case.

Maybe we could add this to the existing src/test/ssl/ tests,
which already deal with that hazard?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2025-01-20 19:48:53 Re: attndims, typndims still not enforced, but make the value within a sane threshold
Previous Message Christoph Berg 2025-01-20 19:23:10 tzdata 2025a and timestamptz.out