From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 1/2] nss: Enhance tst-reload1 coverage and logging
Date: Fri, 23 Sep 2022 09:33:54 -0400 [thread overview]
Message-ID: <d24da9a1-5d6a-32d6-3cd2-f9954cb33222@gotplt.org> (raw)
In-Reply-To: <0e287934ef500ec39ac8610dde04f2ea4a9d4010.1663931559.git.fweimer@redhat.com>
On 2022-09-23 07:13, Florian Weimer via Libc-alpha wrote:
> ---
> nss/tst-reload1.c | 51 +++++++++++++++++++++++++++--------------------
> 1 file changed, 29 insertions(+), 22 deletions(-)
LGTM.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
>
> diff --git a/nss/tst-reload1.c b/nss/tst-reload1.c
> index fdc5bdd65b..9cc6115c96 100644
> --- a/nss/tst-reload1.c
> +++ b/nss/tst-reload1.c
> @@ -121,7 +121,7 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> TEST_VERIFY (p != NULL);
> if (p != NULL)
> {
> - TEST_VERIFY (strcmp (p->pw_name, pt[i].pw_name) == 0);
> + TEST_COMPARE_STRING (p->pw_name, pt[i].pw_name);
> }
> }
>
> @@ -132,8 +132,8 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> TEST_VERIFY (p != NULL);
> if (p != NULL)
> {
> - TEST_VERIFY (strcmp (p->pw_name, pt[i].pw_name) == 0);
> - TEST_VERIFY (p->pw_uid == pt[i].pw_uid);
> + TEST_COMPARE_STRING (p->pw_name, pt[i].pw_name);
> + TEST_COMPARE (p->pw_uid, pt[i].pw_uid);
> }
> }
> endpwent ();
> @@ -144,10 +144,12 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> TEST_VERIFY (h != NULL);
> if (h != NULL)
> {
> - TEST_VERIFY (strcmp (h->h_name, ht[i].h_name) == 0);
> + TEST_COMPARE_STRING (h->h_name, ht[i].h_name);
> + TEST_COMPARE (h->h_addrtype, AF_INET);
> TEST_VERIFY (h->h_addr_list[0] != NULL);
> - if (h->h_addr_list[0])
> - TEST_VERIFY (strcmp (h->h_addr_list[0], ht[i].h_addr_list[0]) == 0);
> + if (h->h_addr_list[0] != NULL)
> + TEST_COMPARE_BLOB (h->h_addr_list[0], h->h_length,
> + ht[i].h_addr_list[0], ht[i].h_length);
> }
> }
>
> @@ -158,14 +160,16 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> int herrno, res;
>
> res = gethostbyname2_r (ht[i].h_name, AF_INET,
> - &r, buf, TESTBUFLEN, &rp, &herrno);
> - TEST_VERIFY (res == 0);
> + &r, buf, TESTBUFLEN, &rp, &herrno);
> + TEST_COMPARE (res, 0);
> if (res == 0)
> {
> - TEST_VERIFY (strcmp (r.h_name, ht[i].h_name) == 0);
> + TEST_COMPARE_STRING (r.h_name, ht[i].h_name);
> + TEST_COMPARE (r.h_addrtype, AF_INET);
> TEST_VERIFY (r.h_addr_list[0] != NULL);
> - if (r.h_addr_list[0])
> - TEST_VERIFY (strcmp (r.h_addr_list[0], ht[i].h_addr_list[0]) == 0);
> + if (r.h_addr_list[0] != NULL)
> + TEST_COMPARE_BLOB (r.h_addr_list[0], r.h_length,
> + ht[i].h_addr_list[0], ht[i].h_length);
> }
> }
>
> @@ -175,10 +179,11 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> TEST_VERIFY (h != NULL);
> if (h != NULL)
> {
> - TEST_VERIFY (strcmp (h->h_name, ht[i].h_name) == 0);
> + TEST_COMPARE_STRING (h->h_name, ht[i].h_name);
> TEST_VERIFY (h->h_addr_list[0] != NULL);
> - if (h->h_addr_list[0])
> - TEST_VERIFY (strcmp (h->h_addr_list[0], ht[i].h_addr_list[0]) == 0);
> + if (h->h_addr_list[0] != NULL)
> + TEST_COMPARE_BLOB (h->h_addr_list[0], h->h_length,
> + ht[i].h_addr_list[0], ht[i].h_length);
> }
> }
>
> @@ -198,17 +203,19 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
>
> ap = NULL;
> res = getaddrinfo (ht[i].h_name, NULL, &hint, &ap);
> - TEST_VERIFY (res == 0);
> + TEST_COMPARE (res, 0);
> TEST_VERIFY (ap != NULL);
> if (res == 0 && ap != NULL)
> {
> j = 0; /* which address in the list */
> while (ap)
> {
> + TEST_COMPARE (ap->ai_family, AF_INET);
> +
> struct sockaddr_in *in = (struct sockaddr_in *)ap->ai_addr;
> unsigned char *up = (unsigned char *)&in->sin_addr;
>
> - TEST_VERIFY (memcmp (up, ht[i].h_addr_list[j], 4) == 0);
> + TEST_COMPARE_BLOB (up, 4, ht[i].h_addr_list[j], 4);
>
> ap = ap->ai_next;
> ++j;
> @@ -233,7 +240,7 @@ must_be_tests (struct passwd *pt, struct hostent *ht)
> host_buf, sizeof(host_buf),
> NULL, 0, NI_NOFQDN);
>
> - TEST_VERIFY (res == 0);
> + TEST_COMPARE (res, 0);
> if (res == 0)
> TEST_VERIFY (strcmp (ht[i].h_name, host_buf) == 0);
> else
> @@ -285,8 +292,8 @@ test_cross_switch_consistency (void)
> TEST_VERIFY (p != NULL);
> if (p != NULL)
> {
> - TEST_VERIFY (strcmp (p->pw_name, pwd_table_1[i].pw_name) == 0);
> - TEST_VERIFY (p->pw_uid == pwd_table_1[i].pw_uid);
> + TEST_COMPARE_STRING (p->pw_name, pwd_table_1[i].pw_name);
> + TEST_COMPARE (p->pw_uid, pwd_table_1[i].pw_uid);
> }
>
> /* After the first lookup, switch to conf2 and verify */
> @@ -296,7 +303,7 @@ test_cross_switch_consistency (void)
> xrename ("/etc/nsswitch.conf2", "/etc/nsswitch.conf");
>
> p = getpwnam (pwd_table_2[0].pw_name);
> - TEST_VERIFY (p->pw_uid == pwd_table_2[0].pw_uid);
> + TEST_COMPARE (p->pw_uid, pwd_table_2[0].pw_uid);
> }
>
> /* But the original loop should still be on conf1. */
> @@ -311,8 +318,8 @@ test_cross_switch_consistency (void)
> TEST_VERIFY (p != NULL);
> if (p != NULL)
> {
> - TEST_VERIFY (strcmp (p->pw_name, pwd_table_2[i].pw_name) == 0);
> - TEST_VERIFY (p->pw_uid == pwd_table_2[i].pw_uid);
> + TEST_COMPARE_STRING (p->pw_name, pwd_table_2[i].pw_name);
> + TEST_COMPARE (p->pw_uid, pwd_table_2[i].pw_uid);
> }
> }
> endpwent ();
>
> base-commit: 774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6
prev parent reply other threads:[~2022-09-23 13:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-23 11:13 Florian Weimer
2022-09-23 11:13 ` [PATCH 2/2] nss: Use shared prefix in IPv4 address in tst-reload1 Florian Weimer
2022-09-23 13:34 ` Siddhesh Poyarekar
2022-09-23 13:33 ` Siddhesh Poyarekar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d24da9a1-5d6a-32d6-3cd2-f9954cb33222@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).