From: "Ghanshyam Thakkar" <shyamthakkar001@gmail.com>
To: <phillip.wood@dunelm.org.uk>, <git@vger.kernel.org>
Cc: "Jonathan Nieder" <jrnieder@gmail.com>,
"Josh Steadmon" <steadmon@google.com>,
"Junio C Hamano" <gitster@pobox.com>,
<christian.couder@gmail.com>,
"Christian Couder" <chriscool@tuxfamily.org>,
"Kaartic Sivaraam" <kaartic.sivaraam@gmail.com>
Subject: Re: [GSoC][PATCH v2] t: migrate helper/test-oidmap.c to unit-tests/t-oidmap.c
Date: Tue, 02 Jul 2024 21:55:48 +0530 [thread overview]
Message-ID: <D2F6Z5WUBKKQ.2A00IY9IF37SI@gmail.com> (raw)
In-Reply-To: <16e06a6d-5fd0-4132-9d82-5c6f13b7f9ed@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> wrote:
> Hi Ghanshyam
>
> On 28/06/2024 13:20, Ghanshyam Thakkar wrote:
> > helper/test-oidmap.c along with t0016-oidmap.sh test the oidmap.h
> > library which is built on top of hashmap.h.
> >
> > Migrate them to the unit testing framework for better performance,
> > concise code and better debugging. Along with the migration also plug
> > memory leaks and make the test logic independent for all the tests.
> > The migration removes 'put' tests from t0016, because it is used as
> > setup to all the other tests, so testing it separately does not yield
> > any benefit.
> >
> > Helped-by: Phillip Wood <phillip.wood123@gmail.com>
> > Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> > Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
> > Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
> > ---
> > This version addresses Phillip's review about detecting duplicates in
> > oidmap when iterating over it and removing put_and_check_null() to move
> > the relevant code to setup() instead. And contains some grammer fixes
> > in the comment.
>
> This version with Junio's fixup addresses my previous comments. One more
> thing occurred to me as I was reading it again
>
> > +static void t_iterate(struct oidmap *map)
> > +{
> > + struct oidmap_iter iter;
> > + struct test_entry *entry;
>
> I wonder if we want to add a bit of paranoia with
>
> int count = 0;
>
> > + oidmap_iter_init(map, &iter);
> > + while ((entry = oidmap_iter_next(&iter))) {
> > + int ret;
> > + if (!check_int((ret = key_val_contains(entry)), ==, 0)) {
> > + switch (ret) {
> > + case -1:
> > + break; /* error message handled by get_oid_arbitrary_hex() */
> > + case 1:
> > + test_msg("obtained entry was not given in the input\n"
> > + " name: %s\n oid: %s\n",
> > + entry->name, oid_to_hex(&entry->entry.oid));
> > + break;
> > + case 2:
> > + test_msg("duplicate entry detected\n"
> > + " name: %s\n oid: %s\n",
> > + entry->name, oid_to_hex(&entry->entry.oid));
> > + break;
> > + default:
> > + test_msg("BUG: invalid return value (%d) from key_val_contains()",
> > + ret);
> > + break;
> > + }
> > + }
> } else {
> count++;
> }
> > + }
> check_int(count, ARRAY_SIZE(key_val));
>
> to check that we iterate over all the entries as well as checking the
> size of the hashmap here.
>
> > + check_int(hashmap_get_size(&map->map), ==, ARRAY_SIZE(key_val));
Yeah, good idea. I'll include it in v3.
Thanks.
next prev parent reply other threads:[~2024-07-02 16:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 17:50 [GSoC][PATCH] t: migrate helper/test-oidmap.c to unit-tests/t-oidmap.c Ghanshyam Thakkar
2024-06-20 9:45 ` Jonathan Nieder
2024-06-25 1:35 ` Ghanshyam Thakkar
2024-06-25 10:14 ` Phillip Wood
2024-06-25 19:16 ` Ghanshyam Thakkar
2024-06-26 8:59 ` phillip.wood123
2024-06-28 12:20 ` [GSoC][PATCH v2] " Ghanshyam Thakkar
2024-07-01 20:32 ` Josh Steadmon
2024-07-01 21:19 ` Junio C Hamano
2024-07-01 21:14 ` Junio C Hamano
2024-07-01 22:20 ` Junio C Hamano
2024-07-02 3:48 ` Ghanshyam Thakkar
2024-07-02 15:17 ` Phillip Wood
2024-07-02 15:24 ` Phillip Wood
2024-07-02 16:25 ` Ghanshyam Thakkar [this message]
2024-07-02 18:55 ` Junio C Hamano
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=D2F6Z5WUBKKQ.2A00IY9IF37SI@gmail.com \
--to=shyamthakkar001@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=steadmon@google.com \
/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 NNTP newsgroup(s).