git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/5] t/unit-tests: convert oidmap test to use clar

From
Seyi Chamber <kuforiji98@gmail.com>
Date
Feb 24, 2025, 10:56 UTC
Message-ID
<CAGedMtfEMkA80NkozBucNKeN-wNqeqk2PqJVcvNg9obyZ7Ei2w@mail.gmail.com>
In-Reply-To
<efa58be8-e958-429a-a5bd-8df442f28bee@gmail.com>
On Fri, 21 Feb 2025 at 11:04, <phillip.wood123@gmail.com> wrote:
Show 11 quoted lines
>
> Hi Seyi
>
> On 20/02/2025 08:29, Seyi Kuforiji wrote:
> > Adapt oidmap test script to clar framework by using clar assertions
> > where necessary. `cl_parse_any_oid` handles the necessary checks needed
> > for the test to run smoothly.
>
> I'm not sure what the last half of this sentence means. What checks are
> performed and how does that lead to the test running smoothly?
>

`cl_parse_any_oid()` ensures the hash algorithm is set before parsing. This prevents issues from an uninitialized or invalid hash algorithm. Without these checks, the test could behave unpredictably. I’ll update the commit message to make this clearer.

Show 13 quoted lines
> > Introduce 'test_oidmap__initialize` handles the to set up of the global
> > oidmap map with predefined key-value pairs, and `test_oidmap__cleanup`
> > frees the oidmap and its entries when all tests are completed.
> >
> > This streamlines the test suite, making individual tests self-contained
> > and reducing redundant code.
>
> This seems to be saying that by sharing global state we're making the
> tests self-contained - I'm not sure how that can be true. We need to
> move to sharing a single oidmap between all the tests because clar's
> setup and teardown functions don't take a context pointer. That's fine
> but I don't see how it makes the tests self-contained.
>
Right! Thank you. I'll adjust the commit message accordingly.
Show 41 quoted lines
> Everything up to this point looks good.
>
> >       while ((entry = oidmap_iter_next(&iter))) {
> > -             int ret;
> > -             if (!check_int((ret = key_val_contains(entry, seen)), ==, 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++;
> > -             }
> > +             cl_assert_equal_i(key_val_contains(entry, seen), 0);
>
> I think wed' be better to use clar_fail_f() so that we can keep the
> helpful error messages. Using cl_assert_equal_i() isn't terrible as if
> the test fails at least we know the error code but as we already have
> the logic in place to provide better messages lets adapt it.
>
> There is a change of behavior here as before we'd loop through the whole
> list of entries detecting all the errors. Now we quit on the first
> error. I don't think that matters but it would be good to point out the
> change in the commit message.
>
> Best Wishes
>
> Phillip

Noted! thank you. Seyi

Previous: phillip.wood123@gmail.comNext: Seyi Kuforiji
Message 13 of 30 in “t/unit-tests: convert unit-tests to use clar”
  1. 0/5 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 20, 2025
  2. 1/5 t/unit-tests: implement oid helper functions in unit-tests.{c,h}Seyi Kuforiji, Feb 20, 2025
  3. Phillip WoodFeb 20, 2025
  4. Patrick SteinhardtFeb 21, 2025
  5. Patrick SteinhardtFeb 21, 2025
  6. phillip.wood123@gmail.comFeb 21, 2025
  7. 2/5 t/unit-tests: convert oid-array test to use clarSeyi Kuforiji, Feb 20, 2025
  8. Phillip WoodFeb 20, 2025
  9. Seyi ChamberFeb 24, 2025
  10. phillip.wood123@gmail.comFeb 24, 2025
  11. 3/5 t/unit-tests: convert oidmap test to use clarSeyi Kuforiji, Feb 20, 2025
  12. phillip.wood123@gmail.comFeb 21, 2025
  13. Seyi ChamberFeb 24, 2025
  14. 4/5 t/unit-tests: convert oidtree test to use clarSeyi Kuforiji, Feb 20, 2025
  15. phillip.wood123@gmail.comFeb 21, 2025
  16. 5/5 t/unit-tests: remove lib-oid.{c,h,o}Seyi Kuforiji, Feb 20, 2025
  17. phillip.wood123@gmail.comFeb 21, 2025
  18. 0/4 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 24, 2025
  19. 1/4 t/unit-tests: implement clar specific oid helper functionsSeyi Kuforiji, Feb 24, 2025
  20. Junio C HamanoFeb 24, 2025
  21. Seyi ChamberFeb 25, 2025
  22. Patrick SteinhardtFeb 25, 2025
  23. 2/4 t/unit-tests: convert oid-array test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  24. 3/4 t/unit-tests: convert oidmap test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  25. 4/4 t/unit-tests: convert oidtree test to use clar test frameworkSeyi Kuforiji, Feb 24, 2025
  26. 0/4 t/unit-tests: convert unit-tests to use clarSeyi Kuforiji, Feb 25, 2025
  27. 1/4 t/unit-tests: implement clar specific oid helper functionsSeyi Kuforiji, Feb 25, 2025
  28. 2/4 t/unit-tests: convert oid-array test to use clar test frameworkSeyi Kuforiji, Feb 25, 2025
  29. 3/4 t/unit-tests: convert oidmap test to use clar test frameworkSeyi Kuforiji, Feb 25, 2025
  30. 4/4 t/unit-tests: convert oidtree test to use clar test frameworkSeyi Kuforiji, Feb 25, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.