public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Florian Weimer <fw@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc] nss: Enhance tst-reload1 coverage and logging Date: Fri, 23 Sep 2022 17:31:30 +0000 (GMT) [thread overview] Message-ID: <20220923173130.407473858D38@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fecf481f0f853ec52f54075bbf06f31638298374 commit fecf481f0f853ec52f54075bbf06f31638298374 Author: Florian Weimer <fweimer@redhat.com> Date: Fri Sep 23 19:30:57 2022 +0200 nss: Enhance tst-reload1 coverage and logging Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Diff: --- nss/tst-reload1.c | 51 +++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) 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 ();
reply other threads:[~2022-09-23 17:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220923173130.407473858D38@sourceware.org \ --to=fw@sourceware.org \ --cc=glibc-cvs@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: linkBe 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).