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

Re: [PATCH 02/11] t-reftable-record: add reftable_record_cmp() tests for log records

From
Karthik Nayak <karthik.188@gmail.com>
Date
Jun 25, 2024, 08:36 UTC
Message-ID
<CAOLa=ZTVv5wwNVUA_g2-t37+B=4i-Bs=kC2JxH3m9XMFGxi+Uw@mail.gmail.com>
In-Reply-To
<20240621115708.3626-3-chandrapratap3519@gmail.com>
Chandra Pratap <chandrapratap3519@gmail.com> writes:
Show 65 quoted lines
> In the current testing setup for log records, only
> reftable_log_record_equal() among log record's comparison functions
> is tested.
>
> Modify the existing tests to exercise reftable_log_record_cmp_void()
> (using the wrapper function reftable_record_cmp()) alongside
> reftable_log_record_equal().
> Note that to achieve this, we'll need to replace instances of
> reftable_log_record_equal() with the wrapper function
> reftable_record_equal().
>
> Rename the now modified test to reflect its nature of exercising
> all comparison operations, not just equality.
>
> Mentored-by: Patrick Steinhardt <ps@pks.im>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
> ---
>  t/unit-tests/t-reftable-record.c | 40 +++++++++++++++++++++-----------
>  1 file changed, 27 insertions(+), 13 deletions(-)
>
> diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c
> index 1b357e6c7f..0cf223e51b 100644
> --- a/t/unit-tests/t-reftable-record.c
> +++ b/t/unit-tests/t-reftable-record.c
> @@ -123,24 +123,38 @@ static void test_reftable_ref_record_roundtrip(void)
>  	strbuf_release(&scratch);
>  }
>
> -static void test_reftable_log_record_equal(void)
> +static void test_reftable_log_record_comparison(void)
>  {
> -	struct reftable_log_record in[2] = {
> +	struct reftable_record in[3] = {
>  		{
> -			.refname = xstrdup("refs/heads/master"),
> -			.update_index = 42,
> +			.type = BLOCK_TYPE_LOG,
> +			.u.log.refname = xstrdup("refs/heads/master"),
> +			.u.log.update_index = 42,
>  		},
>  		{
> -			.refname = xstrdup("refs/heads/master"),
> -			.update_index = 22,
> -		}
> +			.type = BLOCK_TYPE_LOG,
> +			.u.log.refname = xstrdup("refs/heads/master"),
> +			.u.log.update_index = 22,
> +		},
> +		{
> +			.type = BLOCK_TYPE_LOG,
> +			.u.log.refname = xstrdup("refs/heads/main"),
> +			.u.log.update_index = 22,
> +		},
>  	};
>
> -	check(!reftable_log_record_equal(&in[0], &in[1], GIT_SHA1_RAWSZ));
> -	in[1].update_index = in[0].update_index;
> -	check(reftable_log_record_equal(&in[0], &in[1], GIT_SHA1_RAWSZ));
> -	reftable_log_record_release(&in[0]);
> -	reftable_log_record_release(&in[1]);
> +	check(!reftable_record_equal(&in[0], &in[1], GIT_SHA1_RAWSZ));
> +	check(!reftable_record_equal(&in[1], &in[2], GIT_SHA1_RAWSZ));
> +	check_int(reftable_record_cmp(&in[1], &in[2]), >, 0);
> +	/* comparison should be reversed for equal keys */
Nit: This is because we then compare the update-index, would be nice to
add that detail too.
Show 22 quoted lines
> +	check_int(reftable_record_cmp(&in[0], &in[1]), <, 0);
> +
> +	in[1].u.log.update_index = in[0].u.log.update_index;
> +	check(reftable_record_equal(&in[0], &in[1], GIT_SHA1_RAWSZ));
> +	check(!reftable_record_cmp(&in[0], &in[1]));
> +
> +	for (size_t i = 0; i < ARRAY_SIZE(in); i++)
> +		reftable_record_release(&in[i]);
>  }
>
>  static void test_reftable_log_record_roundtrip(void)
> @@ -362,7 +376,7 @@ static void test_reftable_index_record_roundtrip(void)
>
>  int cmd_main(int argc, const char *argv[])
>  {
> -	TEST(test_reftable_log_record_equal(), "reftable_log_record_equal works");
> +	TEST(test_reftable_log_record_comparison(), "comparison operations work on log record");
>  	TEST(test_reftable_log_record_roundtrip(), "record operations work on log record");
>  	TEST(test_reftable_ref_record_roundtrip(), "record operations work on ref record");
>  	TEST(test_varint_roundtrip(), "put_var_int and get_var_int work");
> --
> 2.45.2.404.g9eaef5822c
Previous: Chandra PratapNext: Chandra Pratap
Message 22 of 74 in “t: port reftable/record_test.c to the unit testing framework”
  1. Chandra PratapJun 21, 2024
  2. 01/11 t: move reftable/record_test.c to the unit testing frameworkChandra Pratap, Jun 21, 2024
  3. 02/11 t-reftable-record: add reftable_record_cmp() tests for log recordsChandra Pratap, Jun 21, 2024
  4. 03/11 t-reftable-record: add comparison tests for ref recordsChandra Pratap, Jun 21, 2024
  5. 04/11 t-reftable-record: add comparison tests for index recordsChandra Pratap, Jun 21, 2024
  6. 05/11 t-reftable-record: add comparison tests for obj recordsChandra Pratap, Jun 21, 2024
  7. 06/11 t-reftable-record: add reftable_record_is_deletion() test for ref recordsChandra Pratap, Jun 21, 2024
  8. 07/11 t-reftable-record: add reftable_record_is_deletion() test for log recordsChandra Pratap, Jun 21, 2024
  9. 08/11 t-reftable-record: add reftable_record_is_deletion() test for obj recordsChandra Pratap, Jun 21, 2024
  10. 09/11 t-reftable-record: add reftable_record_is_deletion() test for index recordsChandra Pratap, Jun 21, 2024
  11. 10/11 t-reftable-record: add tests for reftable_ref_record_compare_name()Chandra Pratap, Jun 21, 2024
  12. 11/11 t-reftable-record: add tests for reftable_log_record_compare_key()Chandra Pratap, Jun 21, 2024
  13. Chandra PratapJun 21, 2024
  14. Chandra PratapJun 21, 2024
  15. 01/11 t: move reftable/record_test.c to the unit testing frameworkChandra Pratap, Jun 21, 2024
  16. Karthik NayakJun 25, 2024
  17. Chandra PratapJun 25, 2024
  18. Karthik NayakJun 26, 2024
  19. Chandra PratapJun 26, 2024
  20. Han-Wen NienhuysJun 26, 2024
  21. 02/11 t-reftable-record: add reftable_record_cmp() tests for log recordsChandra Pratap, Jun 21, 2024
  22. Karthik NayakJun 25, 2024
  23. 03/11 t-reftable-record: add comparison tests for ref recordsChandra Pratap, Jun 21, 2024
  24. 04/11 t-reftable-record: add comparison tests for index recordsChandra Pratap, Jun 21, 2024
  25. 05/11 t-reftable-record: add comparison tests for obj recordsChandra Pratap, Jun 21, 2024
  26. 06/11 t-reftable-record: add ref tests for reftable_record_is_deletion()Chandra Pratap, Jun 21, 2024
  27. Karthik NayakJun 25, 2024
  28. Eric SunshineJun 25, 2024
  29. Karthik NayakJun 26, 2024
  30. 07/11 t-reftable-record: add log tests for reftable_record_is_deletion()Chandra Pratap, Jun 21, 2024
  31. 08/11 t-reftable-record: add obj tests for reftable_record_is_deletion()Chandra Pratap, Jun 21, 2024
  32. 09/11 t-reftable-record: add index tests for reftable_record_is_deletion()Chandra Pratap, Jun 21, 2024
  33. Karthik NayakJun 25, 2024
  34. Chandra PratapJun 25, 2024
  35. Karthik NayakJun 26, 2024
  36. 10/11 t-reftable-record: add tests for reftable_ref_record_compare_name()Chandra Pratap, Jun 21, 2024
  37. Karthik NayakJun 25, 2024
  38. Chandra PratapJun 25, 2024
  39. 11/11 t-reftable-record: add tests for reftable_log_record_compare_key()Chandra Pratap, Jun 21, 2024
  40. Karthik NayakJun 25, 2024
  41. Karthik NayakJun 25, 2024
  42. [GSoC][PATCH v3 0/11] t: port reftable/record_test.c to the unit testing frameworkChandra Pratap, Jun 28, 2024
  43. 01/11 t: move reftable/record_test.c to the unit testing frameworkChandra Pratap, Jun 28, 2024
  44. Karthik NayakJun 30, 2024
  45. 02/11 t-reftable-record: add reftable_record_cmp() tests for log recordsChandra Pratap, Jun 28, 2024
  46. 03/11 t-reftable-record: add comparison tests for ref recordsChandra Pratap, Jun 28, 2024
  47. 04/11 t-reftable-record: add comparison tests for index recordsChandra Pratap, Jun 28, 2024
  48. 05/11 t-reftable-record: add comparison tests for obj recordsChandra Pratap, Jun 28, 2024
  49. 06/11 t-reftable-record: add ref tests for reftable_record_is_deletion()Chandra Pratap, Jun 28, 2024
  50. 07/11 t-reftable-record: add log tests for reftable_record_is_deletion()Chandra Pratap, Jun 28, 2024
  51. 08/11 t-reftable-record: add obj tests for reftable_record_is_deletion()Chandra Pratap, Jun 28, 2024
  52. 09/11 t-reftable-record: add index tests for reftable_record_is_deletion()Chandra Pratap, Jun 28, 2024
  53. 10/11 t-reftable-record: add tests for reftable_ref_record_compare_name()Chandra Pratap, Jun 28, 2024
  54. Karthik NayakJun 30, 2024
  55. Chandra PratapJul 1, 2024
  56. Karthik NayakJul 1, 2024
  57. Chandra PratapJul 1, 2024
  58. 11/11 t-reftable-record: add tests for reftable_log_record_compare_key()Chandra Pratap, Jun 28, 2024
  59. Karthik NayakJun 30, 2024
  60. Karthik NayakJun 30, 2024
  61. [GSoC][PATCH v4 0/11] t: port reftable/record_test.c to the unit testing framework frameworkChandra Pratap, Jul 2, 2024
  62. 01/11 t: move reftable/record_test.c to the unit testing frameworkChandra Pratap, Jul 2, 2024
  63. 02/11 t-reftable-record: add reftable_record_cmp() tests for log recordsChandra Pratap, Jul 2, 2024
  64. 03/11 t-reftable-record: add comparison tests for ref recordsChandra Pratap, Jul 2, 2024
  65. 04/11 t-reftable-record: add comparison tests for index recordsChandra Pratap, Jul 2, 2024
  66. 05/11 t-reftable-record: add comparison tests for obj recordsChandra Pratap, Jul 2, 2024
  67. 06/11 t-reftable-record: add ref tests for reftable_record_is_deletion()Chandra Pratap, Jul 2, 2024
  68. 07/11 t-reftable-record: add log tests for reftable_record_is_deletion()Chandra Pratap, Jul 2, 2024
  69. 08/11 t-reftable-record: add obj tests for reftable_record_is_deletion()Chandra Pratap, Jul 2, 2024
  70. 09/11 t-reftable-record: add index tests for reftable_record_is_deletion()Chandra Pratap, Jul 2, 2024
  71. 10/11 t-reftable-record: add tests for reftable_ref_record_compare_name()Chandra Pratap, Jul 2, 2024
  72. 11/11 t-reftable-record: add tests for reftable_log_record_compare_key()Chandra Pratap, Jul 2, 2024
  73. Karthik NayakJul 2, 2024
  74. Junio C HamanoJul 2, 2024

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.