Обсуждение: Re: [PATCH] Improve code coverage of network address functions

Поиск
Список
Период
Сортировка

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

От
Stepan Neretin
Дата:
Hello Aleksander! I'm a beginner and I would like to see and try your patch. However, I have never worked with coverage in regression tests for PostgreSQL. Could you please tell me how it works and help me understand the process? Thanks!
Best Regards, Stepan Neretin!

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

От
Aleksander Alekseev
Дата:
Hi Stepan,

> Hello Aleksander! I'm a beginner and I would like to see and try your patch. However, I have never worked with
coveragein regression tests for PostgreSQL. Could you please tell me how it works and help me understand the process?
Thanks!

You are going to need some Linux distribution, GCC stack and lcov 1.16
[1]. (Lcov doesn't work with Clang; We seem to experience some
problems with lcov 2.0+, this is being investigated [2])

Apply the patch as usual ( git clone
git://git.postgresql.org/git/postgresql.git ; git am ... ) and run:

```
git clean -dfx && meson setup --buildtype debug
-DPG_TEST_EXTRA="kerberos ldap ssl" -Db_coverage=true -Dldap=disabled
-Dssl=openssl -Dcassert=true -Dtap_tests=enabled
-Dprefix=/home/eax/pginstall build && ninja -C build &&
PG_TEST_EXTRA=1 meson test -C build && ninja -C build coverage-html
```

Note the `-Db_coverage=true` and `ninja -C build coverage-html` parts.
Change `prefix` to an appropriate one. This will take longer than
usual. Your coverage report will be located in
build/meson-logs/coveragereport. You can compare the reports with and
without the patch to ensure that the patch improves code coverage.

[1]: https://github.com/linux-test-project/lcov/releases/tag/v1.16
[2]: https://postgr.es/m/CAJ7c6TN%2BMCh99EZ8YGhXZAdnqvNQYir6E34B_mmcB5KsxCB00A%40mail.gmail.com

-- 
Best regards,
Aleksander Alekseev



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

От
Keisuke Kuroda
Дата:
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