[GSoC][PATCH v7 0/7] t: port reftable/pq_test.c to the unit testing framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The reftable library comes with self tests, which are exercised
as part of the usual end-to-end tests and are designed to
observe the end-user visible effects of Git commands. What it
exercises, however, is a better match for the unit-testing
framework, merged at 8bf6fbd0 (Merge branch 'js/doc-unit-tests',
2023-12-09), which is designed to observe how low level
implementation details, at the level of sequences of individual
function calls, behave.

Hence, port reftable/pq_test.c to the unit testing framework and
improve upon the ported test. The first two patches in the series
are preparatory cleanup, the third patch moves the test to the unit
testing framework, and the rest of the patches improve upon the
ported test.

Mentored-by: Patrick Steinhardt <ps@xxxxxx>
Mentored-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
Signed-off-by: Chandra Pratap <chandrapratap3519@xxxxxxxxx>

---
Changes in v7:
- Fix a typo in patch 1
- Fix do-while style error in patch 6 and 7

CI/PR for v7: https://github.com/gitgitgadget/git/pull/1745

Chandra Pratap(7):
reftable: remove unncessary curly braces in reftable/pq.c
reftable: change the type of array indices to 'size_t' in reftable/pq.c
t: move reftable/pq_test.c to the unit testing framework
t-reftable-pq: make merged_iter_pqueue_check() static
t-reftable-pq: make merged_iter_pqueue_check() callable by reference
t-reftable-pq: add test for index based comparison
t-reftable-pq: add tests for merged_iter_pqueue_top()

Makefile                     |   2 +-
reftable/pq.c                |  29 +++-----
reftable/pq.h                |   1 -
reftable/pq_test.c           |  74 ---------------------
reftable/reftable-tests.h    |   1 -
t/helper/test-reftable.c     |   1 -
t/unit-tests/t-reftable-pq.c | 152 +++++++++++++++++++++++++++++++++++++++++++
7 files changed, 163 insertions(+), 97 deletions(-)

Range-diff against v6:

1:  acd9d26aaf ! 1:  91719cc47f reftable: remove unncessary curly braces in reftable/pq.c
    @@ Metadata
     Author: Chandra Pratap <chandrapratap3519@xxxxxxxxx>

      ## Commit message ##
    -    reftable: remove unncessary curly braces in reftable/pq.c
    +    reftable: remove unnecessary curly braces in reftable/pq.c

         According to Documentation/CodingGuidelines, control-flow statements
         with a single line as their body must omit curly braces. Make
2:  2e0986207b = 2:  2e5e72d5c5 reftable: change the type of array indices to 'size_t' in reftable/pq.c
3:  df06b6d604 = 3:  5db9e92f20 t: move reftable/pq_test.c to the unit testing framework
4:  40745ab18e = 4:  9334b1fe9e t-reftable-pq: make merged_iter_pqueue_check() static
5:  ee8432ac4a = 5:  9d8c33d1fc t-reftable-pq: make merged_iter_pqueue_check() callable by reference
6:  f5c30187e1 ! 6:  7a67861652 t-reftable-pq: add test for index based comparison
    @@ t/unit-tests/t-reftable-pq.c: static void t_pq(void)
     +		merged_iter_pqueue_add(&pq, &e);
     +		merged_iter_pqueue_check(&pq);
     +		i = (i * 7) % N;
    -+	}
    -+	while (i != 1);
    ++	} while (i != 1);
     +
     +	for (i = N - 1; i > 0; i--) {
     +		struct pq_entry e = merged_iter_pqueue_remove(&pq);
7:  394540a789 ! 7:  5ac60563e4 t-reftable-pq: add tests for merged_iter_pqueue_top()
    @@ t/unit-tests/t-reftable-pq.c: static void t_pq_record(void)
      		if (last)
      			check_int(strcmp(last, e.rec->u.ref.refname), <, 0);
     @@ t/unit-tests/t-reftable-pq.c: static void t_pq_index(void)
    - 	while (i != 1);
    + 	} while (i != 1);

      	for (i = N - 1; i > 0; i--) {
     +		struct pq_entry top = merged_iter_pqueue_top(pq);
    @@ t/unit-tests/t-reftable-pq.c: static void t_pq_index(void)
     +		merged_iter_pqueue_add(&pq, &e);
     +		merged_iter_pqueue_check(&pq);
     +		i = (i * 7) % N;
    -+	}
    -+	while (i != 1);
    ++	} while (i != 1);
     +
     +	for (i = N - 1; i > 0; i--) {
     +		struct pq_entry top = merged_iter_pqueue_top(pq);





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux