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

From: Keisuke Kuroda <keisuke(dot)kuroda(dot)3862(at)gmail(dot)com>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Improve code coverage of network address functions
Date: 2025-01-16 08:30:48
Message-ID: CANDwggL44zGOuYsNrTC3NSoMqmxG4dZoRbhQRT+O+JOk7sAJYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I could not send it to the mailing list, so I'm resending it.
___
Hi Aleksander,

I have tested your patch.
I have confirmed that the coverage improves
to the expected value(69.8%->80.1%)
Your patch looks good to me.

## test and make coverage

source: commit 9a45a89c38f3257b13e09edf382e32fa28b918c2 (HEAD)

./configure --enable-coverage --enable-tap-tests --with-llvm CFLAGS=-O0
make check-world
make coverage-html

## Proposal to add a test for the set_masklen function

I think we could add the following test to
further improve the coverage.

Adding the following cases to the set_masklen()
test would further improve coverage.
* netmask = -1
* netmask > maxvalue(33 when ipv4)

```
-- check to treat netmask as maximum value when -1
SELECT set_masklen(cidr(text(c)), -1) FROM INET_TBL;
set_masklen
--------------------
192.168.1.0/32
192.168.1.0/32
192.168.1.0/32
192.168.1.0/32
192.168.1.0/32
192.168.1.0/32
10.0.0.0/32
10.0.0.0/32
10.1.2.3/32
10.1.2.0/32
10.1.0.0/32
10.0.0.0/32
10.0.0.0/32
10.0.0.0/32
10:23::f1/128
10:23::8000/128
::ffff:1.2.3.4/128
(17 rows)

-- check that rejects invalid netmask
SELECT set_masklen(inet(text(i)), 33) FROM INET_TBL;
ERROR: invalid mask length: 33
SELECT set_masklen(cidr(text(c)), 33) FROM INET_TBL;
ERROR: invalid mask length: 33
```

This would increase coverage from 80.1% to 80.5%.
The improvement value is small, but it would
be worth adding. What do you think?

As a side note,
the macaddr/macaddr8 type processing
in the convert_network_to_scalar() does not seem
to be testing. This is related to
the macaddr/macaddr8 type histograms and do not
appear to work in a simple test.
This should be considered for another time.

Best Regards,
Keisuke Kuroda
NTT Comware

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2025-01-16 08:40:51 Re: Show WAL write and fsync stats in pg_stat_io
Previous Message Richard Guo 2025-01-16 08:18:18 Re: Eager aggregation, take 3