t/unit-tests: convert unit-tests to use clar
Subsystems (2)
cover t/unit-tests: convert unit-tests to use clar
Hello,
This small patch series transitions the existing unit test files to the Clar testing framework. This change is part of our ongoing effort to standardize our testing approach and enhance maintainability.
Thanks
Seyi
Seyi Kuforiji (4):
t/unit-tests: handle dashes in test suite filenames t/unit-tests: convert mem-pool test to use clar test framework t/unit-tests: adapt priority queue test to use clar test framework t/unit-tests: convert reftable tree test to use clar test framework
Makefile | 6 +- t/meson.build | 6 +- t/unit-tests/generate-clar-decls.sh | 1 + t/unit-tests/t-mem-pool.c | 31 ---------- t/unit-tests/t-prio-queue.c | 91 ---------------------------- t/unit-tests/t-reftable-tree.c | 86 -------------------------- t/unit-tests/u-mem-pool.c | 26 ++++++++ t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++ t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++ 9 files changed, 205 insertions(+), 214 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c delete mode 100644 t/unit-tests/t-prio-queue.c delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-mem-pool.c create mode 100644 t/unit-tests/u-prio-queue.c create mode 100644 t/unit-tests/u-reftable-tree.c
Signature · 1 line
2.34.1
PATCH 1/4 t/unit-tests: handle dashes in test suite filenames
Adapt script to translate dashes (-) in test suite filenames to underscores (_) to ensure proper extraction of test function names. generate-clar-decls.sh does not pick up dashes in filenames such as u-mem-pool.c, which prevents the scripts from being run. This will be used by subsequent commits which follows the same construct.
--- t/unit-tests/generate-clar-decls.sh | 1 + 1 file changed, 1 insertion(+)
t/unit-tests/generate-clar-decls.sh +1 -0
@@ -14,6 +14,7 @@ do suite_name=$(basename "$suite") suite_name=${suite_name%.c} suite_name=${suite_name#u-} + suite_name=$(echo "$suite_name" | tr '-' '_') sed -ne "s/^\(void test_${suite_name}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\)$/extern \1;/p" "$suite" || exit 1 done >"$OUTPUT"
Signature · 1 line
2.34.1
Re: [PATCH 1/4] t/unit-tests: handle dashes in test suite filenames
Quoted 5 lines · Seyi Kuforiji
Adapt script to translate dashes (
-) in test suite filenames to underscores (_) to ensure proper extraction of test function names.generate-clar-decls.shdoes not pick up dashes in filenames such asu-mem-pool.c, which prevents the scripts from being run. This will be used by subsequent commits which follows the same construct.
Nit: it would be nice to provide a bit more context. What might not be immediately be obvious is that the script extracts function signatures that match a specific pattern derived from the unit test file's name, so pointing that out would likely help.
Also note that "u-mem-pool.c" is not a script, so saying that these are getting run as scripts is misleading. I'd rather say something like "which prevents the unit tests declared in those suites from being executed".
The change itself looks good to me!
Patrick
PATCH 2/4 t/unit-tests: convert mem-pool test to use clar test framework
In reply to Seyi KuforijiAdapt the mem-pool test script to use clar framework by using clar assertions where necessary. Following the consensus to convert the unit-tests scripts found in the t/unit-tests folder to clar driven by Patrick Steinhardt. Test functions are created as a standalone to test different test cases.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-mem-pool.c | 31 ------------------------------- t/unit-tests/u-mem-pool.c | 26 ++++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c create mode 100644 t/unit-tests/u-mem-pool.c
Makefile +1 -1
@@ -1338,6 +1338,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/% THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype +CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1347,7 +1348,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o UNIT_TEST_PROGRAMS += t-example-decorate UNIT_TEST_PROGRAMS += t-hash UNIT_TEST_PROGRAMS += t-hashmap -UNIT_TEST_PROGRAMS += t-mem-pool UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree
t/meson.build +1 -1
@@ -1,5 +1,6 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', + 'unit-tests/u-mem-pool.c', 'unit-tests/u-strvec.c', ]
@@ -43,7 +44,6 @@ unit_test_programs = [ 'unit-tests/t-example-decorate.c', 'unit-tests/t-hash.c', 'unit-tests/t-hashmap.c', - 'unit-tests/t-mem-pool.c', 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c',
t/unit-tests/t-mem-pool.c deleted +0 -31
@@ -1,31 +0,0 @@ -#include "test-lib.h" -#include "mem-pool.h" - -static void setup_static (void (*f)(struct mem_pool *),size_t block_alloc) -{ -struct mem_pool pool = { .block_alloc = block_alloc }; -f (&pool); -mem_pool_discard (&pool,0 ); -} - -static void t_calloc_100 (struct mem_pool *pool) -{ -size_t size =100 ; -char *buffer =mem_pool_calloc (pool,1 , size); -for (size_t i =0 ; i < size; i++) - check_int(buffer[i], ==, 0); -if (!check (pool->mp_block !=NULL )) -return ; -check (pool->mp_block->next_free !=NULL ); -check (pool->mp_block->end !=NULL ); -} - -int cmd_main(int argc UNUSED, const char **argv UNUSED) -{ -TEST (setup_static (t_calloc_100,1024 *1024 ), -"mem_pool_calloc returns 100 zeroed bytes with big block" ); -TEST (setup_static (t_calloc_100,1 ), -"mem_pool_calloc returns 100 zeroed bytes with tiny block" ); - -return test_done (); -}
t/unit-tests/u-mem-pool.c new file +26 -0
@@ -0,0 +1,26 @@ +#include "unit-test.h" +#include "mem-pool.h" + +static void t_calloc_100 (size_t block_alloc) +{ +struct mem_pool pool = { .block_alloc = block_alloc }; +size_t size =100 ; +char *buffer =mem_pool_calloc (&pool,1 , size); +for (size_t i =0 ; i < size; i++) +cl_assert_equal_i (0 , buffer[i]); +cl_assert (pool.mp_block !=NULL ); +cl_assert (pool.mp_block->next_free !=NULL ); +cl_assert (pool.mp_block->end !=NULL ); +mem_pool_discard (&pool,0 ); +} + +void test_mem_pool__big_block (void ) +{ +t_calloc_100 (1024 *1024 ); + +} + +void test_mem_pool__tiny_block (void ) +{ +t_calloc_100 (1 ); +}
Signature · 1 line
2.34.1
Re: [PATCH 2/4] t/unit-tests: convert mem-pool test to use clar test framework
Quoted 4 lines · Seyi Kuforiji
Adapt the mem-pool test script to use clar framework by using clar assertions where necessary. Following the consensus to convert the unit-tests scripts found in the t/unit-tests folder to clar driven by Patrick Steinhardt.
I think it's a minor detail that isn't really worth mentioning that I was the one introducing the clar, so I'd leave my name out of it. This also applies to subsequent commit messages.
Quoted 27 lines
t/unit-tests/t-mem-pool.c deleted +0
-21@@ -1,31 +0,0 @@ -#include "test-lib.h" -#include "mem-pool.h" - -static void setup_static (void (*f)(struct mem_pool *),size_t block_alloc) -{ -struct mem_pool pool = { .block_alloc = block_alloc }; -f (&pool); -mem_pool_discard (&pool,0 ); -} - -static void t_calloc_100 (struct mem_pool *pool) -{ -size_t size =100 ; -char *buffer =mem_pool_calloc (pool,1 , size); -for (size_t i =0 ; i < size; i++) - check_int(buffer[i], ==, 0); -if (!check (pool->mp_block !=NULL )) -return ; -check (pool->mp_block->next_free !=NULL ); -check (pool->mp_block->end !=NULL ); -}
t/unit-tests/t-mem-pool.c line 31
Quoted 10 lines
t/unit-tests/t-mem-pool.c deleted +0
-10- -int cmd_main(int argc UNUSED, const char **argv UNUSED) -{ -TEST (setup_static (t_calloc_100,1024 *1024 ), -"mem_pool_calloc returns 100 zeroed bytes with big block" ); -TEST (setup_static (t_calloc_100,1 ), -"mem_pool_calloc returns 100 zeroed bytes with tiny block" ); - -return test_done (); -}
Mh, too bad that Git doesn't render it as a
t/unit-tests/u-mem-pool.c line 4
Quoted 10 lines
t/unit-tests/u-mem-pool.c new file +4
-0@@ -0,0 +1,26 @@ +#include "unit-test.h" +#include "mem-pool.h" + +static void t_calloc_100 (size_t block_alloc)
Can we maybe give this a more descriptive name? Something like test_many_pool_allocations() maybe?
Quoted 6 lines
t/unit-tests/u-mem-pool.c new file +6
-0+{ +struct mem_pool pool = { .block_alloc = block_alloc }; +size_t size =100 ; +char *buffer =mem_pool_calloc (&pool,1 , size); +for (size_t i =0 ; i < size; i++) +cl_assert_equal_i (0 , buffer[i]);
t/unit-tests/u-mem-pool.c line 20
Quoted 10 lines
t/unit-tests/u-mem-pool.c new file +10
-0+cl_assert (pool.mp_block !=NULL ); +cl_assert (pool.mp_block->next_free !=NULL ); +cl_assert (pool.mp_block->end !=NULL ); +mem_pool_discard (&pool,0 ); +} + +void test_mem_pool__big_block (void ) +{ +t_calloc_100 (1024 *1024 ); +
There is a needless empty line here.
Other than that the changes look good to me.
Patrick
Re: [PATCH 2/4] t/unit-tests: convert mem-pool test to use clar test framework
Quoted 9 lines · Patrick Steinhardt
Quoted 4 lines · Seyi Kuforiji
Adapt the mem-pool test script to use clar framework by using clar assertions where necessary. Following the consensus to convert the unit-tests scripts found in the t/unit-tests folder to clar driven by Patrick Steinhardt.
I think it's a minor detail that isn't really worth mentioning that I was the one introducing the clar, so I'd leave my name out of it. This also applies to subsequent commit messages.
Besides, that part of the description does not read quite grammatical and the rest of the sentence is missing. I.e. "Following the lead by somebody, WE DO SOMETHING".
PATCH 3/4 t/unit-tests: adapt priority queue test to use clar test framework
In reply to Seyi KuforijiConvert the prio-queue test script to clar framework by using clar assertions where necessary. Following the consensus to convert the unit-tests scripts found in the t/unit-tests folder to clar driven by Patrick Steinhardt. Test functions are created as a standalone to test different cases.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-prio-queue.c | 91 ----------------------------------- t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 93 deletions(-) delete mode 100644 t/unit-tests/t-prio-queue.c create mode 100644 t/unit-tests/u-prio-queue.c
Makefile +1 -1
@@ -1339,6 +1339,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool +CLAR_TEST_SUITES += u-prio-queue CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1351,7 +1352,6 @@ UNIT_TEST_PROGRAMS += t-hashmap UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree -UNIT_TEST_PROGRAMS += t-prio-queue UNIT_TEST_PROGRAMS += t-reftable-basics UNIT_TEST_PROGRAMS += t-reftable-block UNIT_TEST_PROGRAMS += t-reftable-merged
t/meson.build +1 -1
@@ -1,6 +1,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', + 'unit-tests/u-prio-queue.c', 'unit-tests/u-strvec.c', ]
@@ -47,7 +48,6 @@ unit_test_programs = [ 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c', - 'unit-tests/t-prio-queue.c', 'unit-tests/t-reftable-basics.c', 'unit-tests/t-reftable-block.c', 'unit-tests/t-reftable-merged.c',
t/unit-tests/t-prio-queue.c deleted +0 -91
91 lines not on this page · raw message
t/unit-tests/u-prio-queue.c new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 3/4] t/unit-tests: adapt priority queue test to use clar test framework
t/unit-tests/t-prio-queue.c
Quoted 5 lines · Seyi Kuforiji
t/unit-tests/t-prio-queue.c deleted +0
-0
Hm. A bit surprising that Git decides to not render this as a rename, as most of test_prio_queue() is unchanged.
Quoted 22 lines
t/unit-tests/u-prio-queue.c new file +16
-0@@ -0,0 +1,94 @@ +#include "unit-test.h" +#include "prio-queue.h" + +static int intcmp(const void *va, const void *vb, void *data UNUSED) +{ +const int *a = va, *b = vb; +return *a - *b; +} + + +#define MISSING -1 +#define DUMP -2 +#define STACK -3 +#define GET -4 +#define REVERSE -5 +
t/unit-tests/u-prio-queue.c line 26
Quoted 10 lines
t/unit-tests/u-prio-queue.c new file +10
-0+static int show (int *v) +{ +return v ? *v :MISSING ; +} + +static void test_prio_queue (int *input,size_t input_size, +int *result,size_t result_size) +{ +struct prio_queue pq = { intcmp }; +size_t j =0 ;
This is a size_t now, which is different compared to before. Might be worthwhile to point out why you did this in the commit message.
Quoted 6 lines
t/unit-tests/u-prio-queue.c new file +6
-0+for (size_t i =0 ; i < input_size; i++) { +void *peek, *get; +switch (input[i]) { +case GET : + peek =prio_queue_peek (&pq); + get =prio_queue_get (&pq);
t/unit-tests/u-prio-queue.c line 43
Quoted 10 lines
t/unit-tests/u-prio-queue.c new file +10
-0+cl_assert (peek == get); +cl_assert (j < result_size); +cl_assert_equal_i (result[j],show (get)); + j++; +break ; +case DUMP : +while ((peek =prio_queue_peek (&pq))) { + get =prio_queue_get (&pq); +cl_assert (peek == get); +cl_assert ((size_t )j < result_size);
This here is the reason, to avoid -Wsign-compare. But the cast here isn't necessary now that you've adapted j to be a size_t anyway.
Quoted 41 lines
t/unit-tests/u-prio-queue.c new file +41
-0+cl_assert_equal_i (result[j],show (get)); + j++; + } +break ; +case STACK : + pq.compare =NULL ; +break ; +case REVERSE : +prio_queue_reverse (&pq); +break ; +default : +prio_queue_put (&pq, &input[i]); +break ; + } + } +cl_assert_equal_i (j, result_size); +clear_prio_queue (&pq); +} + +#define TEST_INPUT (input, result) \ + test_prio_queue(input, ARRAY_SIZE(input), result, ARRAY_SIZE(result)) + +void test_prio_queue__basic (void ) +{ +TEST_INPUT (((int []){2 ,6 ,3 ,10 ,9 ,5 ,7 ,4 ,5 ,8 ,1 ,DUMP }), + ((int []){1 ,2 ,3 ,4 ,5 ,5 ,6 ,7 ,8 ,9 ,10 })); +} + +void test_prio_queue__mixed (void ) +{ +TEST_INPUT (((int []){6 ,2 ,4 ,GET ,5 ,3 ,GET ,GET ,1 ,DUMP }), + ((int []){2 ,3 ,4 ,1 ,5 ,6 })); +} + +void test_prio_queue__empty (void ) +{ +TEST_INPUT (((int []){1 ,2 ,GET ,GET ,GET ,1 ,2 ,GET ,GET ,GET }), + ((int []){1 ,2 ,MISSING ,1 ,2 ,MISSING })); +} + +void test_prio_queue__stack (void )
t/unit-tests/u-prio-queue.c line 94
Quoted 10 lines
t/unit-tests/u-prio-queue.c new file +10
-0+{ +TEST_INPUT (((int []){STACK ,8 ,1 ,5 ,4 ,6 ,2 ,3 ,DUMP }), + ((int []){3 ,2 ,6 ,4 ,5 ,1 ,8 })); +} + +void test_prio_queue__reverse_stack (void ) +{ +TEST_INPUT (((int []){STACK ,1 ,2 ,3 ,4 ,5 ,6 ,REVERSE ,DUMP }), + ((int []){1 ,2 ,3 ,4 ,5 ,6 })); +}
All of these look like failthful conversions to me.
Patrick
PATCH 4/4 t/unit-tests: convert reftable tree test to use clar test framework
In reply to Seyi KuforijiAdapts reftable tree test script to clar framework by using clar assertions where necessary. Following the consensus to convert the unit-tests scripts found in the t/unit-tests folder to clar driven by Patrick Steinhardt.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-reftable-tree.c | 86 ---------------------------------- t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 88 deletions(-) delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-reftable-tree.c
Makefile +1 -1
@@ -1340,6 +1340,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-prio-queue +CLAR_TEST_SUITES += u-reftable-tree CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1360,7 +1361,6 @@ UNIT_TEST_PROGRAMS += t-reftable-reader UNIT_TEST_PROGRAMS += t-reftable-readwrite UNIT_TEST_PROGRAMS += t-reftable-record UNIT_TEST_PROGRAMS += t-reftable-stack -UNIT_TEST_PROGRAMS += t-reftable-tree UNIT_TEST_PROGRAMS += t-strbuf UNIT_TEST_PROGRAMS += t-strcmp-offset UNIT_TEST_PROGRAMS += t-trailer
t/meson.build +1 -1
@@ -2,6 +2,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', 'unit-tests/u-prio-queue.c', + 'unit-tests/u-reftable-tree.c', 'unit-tests/u-strvec.c', ]
@@ -56,7 +57,6 @@ unit_test_programs = [ 'unit-tests/t-reftable-readwrite.c', 'unit-tests/t-reftable-record.c', 'unit-tests/t-reftable-stack.c', - 'unit-tests/t-reftable-tree.c', 'unit-tests/t-strbuf.c', 'unit-tests/t-strcmp-offset.c', 'unit-tests/t-trailer.c',
t/unit-tests/t-reftable-tree.c deleted +0 -86
86 lines not on this page · raw message
t/unit-tests/u-reftable-tree.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.34.1
v2 cover t/unit-tests: convert unit-tests to use clar
In reply to Seyi KuforijiHello,
This small patch series transitions the existing unit test files to the Clar testing framework. This change is part of our ongoing effort to standardize our testing approach and enhance maintainability.
changes in v2:
- Some small fixes were made to the commit messages
- changes was made to the code format
Thanks
Seyi
Seyi Kuforiji (4):
t/unit-tests: handle dashes in test suite filenames t/unit-tests: convert mem-pool test to use clar test framework t/unit-tests: adapt priority queue test to use clar test framework t/unit-tests: convert reftable tree test to use clar test framework
Makefile | 6 +- t/meson.build | 6 +- t/unit-tests/generate-clar-decls.sh | 1 + t/unit-tests/t-mem-pool.c | 31 ---------- t/unit-tests/t-prio-queue.c | 91 ---------------------------- t/unit-tests/t-reftable-tree.c | 86 -------------------------- t/unit-tests/u-mem-pool.c | 25 ++++++++ t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++ t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++ 9 files changed, 204 insertions(+), 214 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c delete mode 100644 t/unit-tests/t-prio-queue.c delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-mem-pool.c create mode 100644 t/unit-tests/u-prio-queue.c create mode 100644 t/unit-tests/u-reftable-tree.c
Range-diff against v1:
1: 00bb4d2880 = 1: 00bb4d2880 t/unit-tests: handle dashes in test suite filenames 2: 59abf45f08 = 2: 59abf45f08 t/unit-tests: convert mem-pool test to use clar test framework 3: 6e01da141d = 3: 6e01da141d t/unit-tests: adapt priority queue test to use clar test framework 4: b397a5f131 = 4: b397a5f131 t/unit-tests: convert reftable tree test to use clar test framework
Signature · 1 line
2.34.1
PATCH v2 1/4 t/unit-tests: handle dashes in test suite filenames
The script is designed to extract function signatures that match a specific pattern derived from the unit test file's name. generate-clar-decls.sh does not pick up dashes in filenames, which prevents the scripts from being run.
Adapt script to translate dashes (-) in test suite filenames to underscores (_) to correctly extract the function signatures and run the corresponding tests. This will be used by subsequent commits which follows the same construct.
--- t/unit-tests/generate-clar-decls.sh | 1 + 1 file changed, 1 insertion(+)
t/unit-tests/generate-clar-decls.sh +1 -0
@@ -14,6 +14,7 @@ do suite_name=$(basename "$suite") suite_name=${suite_name%.c} suite_name=${suite_name#u-} + suite_name=$(echo "$suite_name" | tr '-' '_') sed -ne "s/^\(void test_${suite_name}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\)$/extern \1;/p" "$suite" || exit 1 done >"$OUTPUT"
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] t/unit-tests: handle dashes in test suite filenames
Quoted 4 lines · Seyi Kuforiji
The script is designed to extract function signatures that match a specific pattern derived from the unit test file's name.
generate-clar-decls.shdoes not pick up dashes in filenames, which prevents the scripts from being run.
As said in my first round, saying "scripts" here is misleading as the unit tests aren't scripts in the first place. How about:
The "generate-clar-decls.sh" script is designed to extract function signatures that match a specific pattern derived from the unit test file's name. The script does not know to massage file names with dashes, which will make it search for functions that look like, for example, test_mem-pool_*. Having dashes in function names is not allowed though, so these patterns won't ever match a legal function name.
Patrick
PATCH v2 2/4 t/unit-tests: convert mem-pool test to use clar test framework
In reply to Seyi KuforijiAdapt the mem-pool test script to use clar framework by using clar assertions where necessary.Test functions are created as a standalone to test different test cases.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-mem-pool.c | 31 ------------------------------- t/unit-tests/u-mem-pool.c | 25 +++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c create mode 100644 t/unit-tests/u-mem-pool.c
Makefile +1 -1
@@ -1338,6 +1338,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/% THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype +CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1347,7 +1348,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o UNIT_TEST_PROGRAMS += t-example-decorate UNIT_TEST_PROGRAMS += t-hash UNIT_TEST_PROGRAMS += t-hashmap -UNIT_TEST_PROGRAMS += t-mem-pool UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree
t/meson.build +1 -1
@@ -1,5 +1,6 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', + 'unit-tests/u-mem-pool.c', 'unit-tests/u-strvec.c', ]
@@ -43,7 +44,6 @@ unit_test_programs = [ 'unit-tests/t-example-decorate.c', 'unit-tests/t-hash.c', 'unit-tests/t-hashmap.c', - 'unit-tests/t-mem-pool.c', 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c',
t/unit-tests/t-mem-pool.c deleted +0 -31
@@ -1,31 +0,0 @@ -#include "test-lib.h" -#include "mem-pool.h" - -static void setup_static (void (*f)(struct mem_pool *),size_t block_alloc) -{ -struct mem_pool pool = { .block_alloc = block_alloc }; -f (&pool); -mem_pool_discard (&pool,0 ); -} - -static void t_calloc_100 (struct mem_pool *pool) -{ -size_t size =100 ; -char *buffer =mem_pool_calloc (pool,1 , size); -for (size_t i =0 ; i < size; i++) - check_int(buffer[i], ==, 0); -if (!check (pool->mp_block !=NULL )) -return ; -check (pool->mp_block->next_free !=NULL ); -check (pool->mp_block->end !=NULL ); -} - -int cmd_main(int argc UNUSED, const char **argv UNUSED) -{ -TEST (setup_static (t_calloc_100,1024 *1024 ), -"mem_pool_calloc returns 100 zeroed bytes with big block" ); -TEST (setup_static (t_calloc_100,1 ), -"mem_pool_calloc returns 100 zeroed bytes with tiny block" ); - -return test_done (); -}
t/unit-tests/u-mem-pool.c new file +25 -0
@@ -0,0 +1,25 @@ +#include "unit-test.h" +#include "mem-pool.h" + +static void test_many_pool_allocations (size_t block_alloc) +{ +struct mem_pool pool = { .block_alloc = block_alloc }; +size_t size =100 ; +char *buffer =mem_pool_calloc (&pool,1 , size); +for (size_t i =0 ; i < size; i++) +cl_assert_equal_i (0 , buffer[i]); +cl_assert (pool.mp_block !=NULL ); +cl_assert (pool.mp_block->next_free !=NULL ); +cl_assert (pool.mp_block->end !=NULL ); +mem_pool_discard (&pool,0 ); +} + +void test_mem_pool__big_block (void ) +{ +test_many_pool_allocations (1024 *1024 ); +} + +void test_mem_pool__tiny_block (void ) +{ +test_many_pool_allocations (1 ); +}
Signature · 1 line
2.34.1
PATCH v2 3/4 t/unit-tests: adapt priority queue test to use clar test framework
In reply to Seyi KuforijiConvert the prio-queue test script to clar framework by using clar assertions where necessary. Test functions are created as a standalone to test different cases.
update the type of the variable j from int to size_t, this ensures compatibility with the type used for result_size, which is also size_t, preventing a potential warning or error caused by comparisons between signed and unsigned integers.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-prio-queue.c | 91 ----------------------------------- t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 93 deletions(-) delete mode 100644 t/unit-tests/t-prio-queue.c create mode 100644 t/unit-tests/u-prio-queue.c
Makefile +1 -1
@@ -1339,6 +1339,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool +CLAR_TEST_SUITES += u-prio-queue CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1351,7 +1352,6 @@ UNIT_TEST_PROGRAMS += t-hashmap UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree -UNIT_TEST_PROGRAMS += t-prio-queue UNIT_TEST_PROGRAMS += t-reftable-basics UNIT_TEST_PROGRAMS += t-reftable-block UNIT_TEST_PROGRAMS += t-reftable-merged
t/meson.build +1 -1
@@ -1,6 +1,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', + 'unit-tests/u-prio-queue.c', 'unit-tests/u-strvec.c', ]
@@ -47,7 +48,6 @@ unit_test_programs = [ 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c', - 'unit-tests/t-prio-queue.c', 'unit-tests/t-reftable-basics.c', 'unit-tests/t-reftable-block.c', 'unit-tests/t-reftable-merged.c',
t/unit-tests/t-prio-queue.c deleted +0 -91
91 lines not on this page · raw message
t/unit-tests/u-prio-queue.c new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 4/4 t/unit-tests: convert reftable tree test to use clar test framework
In reply to Seyi KuforijiAdapts reftable tree test script to clar framework by using clar assertions where necessary.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-reftable-tree.c | 86 ---------------------------------- t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 88 deletions(-) delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-reftable-tree.c
Makefile +1 -1
@@ -1340,6 +1340,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-prio-queue +CLAR_TEST_SUITES += u-reftable-tree CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1360,7 +1361,6 @@ UNIT_TEST_PROGRAMS += t-reftable-reader UNIT_TEST_PROGRAMS += t-reftable-readwrite UNIT_TEST_PROGRAMS += t-reftable-record UNIT_TEST_PROGRAMS += t-reftable-stack -UNIT_TEST_PROGRAMS += t-reftable-tree UNIT_TEST_PROGRAMS += t-strbuf UNIT_TEST_PROGRAMS += t-strcmp-offset UNIT_TEST_PROGRAMS += t-trailer
t/meson.build +1 -1
@@ -2,6 +2,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', 'unit-tests/u-prio-queue.c', + 'unit-tests/u-reftable-tree.c', 'unit-tests/u-strvec.c', ]
@@ -56,7 +57,6 @@ unit_test_programs = [ 'unit-tests/t-reftable-readwrite.c', 'unit-tests/t-reftable-record.c', 'unit-tests/t-reftable-stack.c', - 'unit-tests/t-reftable-tree.c', 'unit-tests/t-strbuf.c', 'unit-tests/t-strcmp-offset.c', 'unit-tests/t-trailer.c',
t/unit-tests/t-reftable-tree.c deleted +0 -86
86 lines not on this page · raw message
t/unit-tests/u-reftable-tree.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 5 lines · Seyi Kuforiji
Range-diff against v1:
1: 00bb4d2880 = 1: 00bb4d2880 t/unit-tests: handle dashes in test suite filenames 2: 59abf45f08 = 2: 59abf45f08 t/unit-tests: convert mem-pool test to use clar test framework 3: 6e01da141d = 3: 6e01da141d t/unit-tests: adapt priority queue test to use clar test framework 4: b397a5f131 = 4: b397a5f131 t/unit-tests: convert reftable tree test to use clar test framework
I think you passed wrong commit ranges for the range-diff :)
Anyway, I scanned through the changes and saw that all my feedback was addressed. I've got one more proposal for the first commit message, but other than that the series looks good to me.
Thanks!
Patrick
Hello,
This small patch series transitions the existing unit test files to the Clar testing framework. This change is part of our ongoing effort to standardize our testing approach and enhance maintainability.
changes in v3:
- Some small fixes were made to the commit messages
Thanks
Seyi
Seyi Kuforiji (4):
t/unit-tests: handle dashes in test suite filenames t/unit-tests: convert mem-pool test to use clar test framework t/unit-tests: adapt priority queue test to use clar test framework t/unit-tests: convert reftable tree test to use clar test framework
Makefile | 6 +- t/meson.build | 6 +- t/unit-tests/generate-clar-decls.sh | 1 + t/unit-tests/t-mem-pool.c | 31 ---------- t/unit-tests/t-prio-queue.c | 91 ---------------------------- t/unit-tests/t-reftable-tree.c | 86 -------------------------- t/unit-tests/u-mem-pool.c | 25 ++++++++ t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++ t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++ 9 files changed, 204 insertions(+), 214 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c delete mode 100644 t/unit-tests/t-prio-queue.c delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-mem-pool.c create mode 100644 t/unit-tests/u-prio-queue.c create mode 100644 t/unit-tests/u-reftable-tree.c
Range-diff against v2:
1: 00bb4d2880 ! 1: f9e163a181 t/unit-tests: handle dashes in test suite filenames
@@ Metadata
## Commit message ##
t/unit-tests: handle dashes in test suite filenames
- The script is designed to extract function signatures that match a
- specific pattern derived from the unit test file's name.
- generate-clar-decls.sh does not pick up dashes in filenames, which
- prevents the scripts from being run.
+ "generate-clar-decls.sh" script is designed to extract function
+ signatures that match a specific pattern derived from the unit test
+ file's name. The script does not know to massage file names with dashes,
+ which will make it search for functions that look like, for example,
+ test_mem-pool_*. Having dashes in function names is not allowed
+ though, so these patterns won't ever match a legal function name.
Adapt script to translate dashes (-) in test suite filenames to underscores (_) to correctly extract the function signatures and run
-: ---------- > 2: f46438f53e t/unit-tests: convert mem-pool test to use clar test framework -: ---------- > 3: f5cabebd3a t/unit-tests: adapt priority queue test to use clar test framework -: ---------- > 4: 5323873612 t/unit-tests: convert reftable tree test to use clar test framework
Signature · 1 line
2.34.1
PATCH v3 1/4 t/unit-tests: handle dashes in test suite filenames
"generate-clar-decls.sh" script is designed to extract function signatures that match a specific pattern derived from the unit test file's name. The script does not know to massage file names with dashes, which will make it search for functions that look like, for example, test_mem-pool_*. Having dashes in function names is not allowed though, so these patterns won't ever match a legal function name.
Adapt script to translate dashes (-) in test suite filenames to underscores (_) to correctly extract the function signatures and run the corresponding tests. This will be used by subsequent commits which follows the same construct.
--- t/unit-tests/generate-clar-decls.sh | 1 + 1 file changed, 1 insertion(+)
t/unit-tests/generate-clar-decls.sh +1 -0
@@ -14,6 +14,7 @@ do suite_name=$(basename "$suite") suite_name=${suite_name%.c} suite_name=${suite_name#u-} + suite_name=$(echo "$suite_name" | tr '-' '_') sed -ne "s/^\(void test_${suite_name}__[a-zA-Z_0-9][a-zA-Z_0-9]*(void)\)$/extern \1;/p" "$suite" || exit 1 done >"$OUTPUT"
Signature · 1 line
2.34.1
PATCH v3 2/4 t/unit-tests: convert mem-pool test to use clar test framework
In reply to Seyi KuforijiAdapt the mem-pool test script to use clar framework by using clar assertions where necessary.Test functions are created as a standalone to test different test cases.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-mem-pool.c | 31 ------------------------------- t/unit-tests/u-mem-pool.c | 25 +++++++++++++++++++++++++ 4 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 t/unit-tests/t-mem-pool.c create mode 100644 t/unit-tests/u-mem-pool.c
Makefile +1 -1
@@ -1338,6 +1338,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/% THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype +CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1347,7 +1348,6 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o UNIT_TEST_PROGRAMS += t-example-decorate UNIT_TEST_PROGRAMS += t-hash UNIT_TEST_PROGRAMS += t-hashmap -UNIT_TEST_PROGRAMS += t-mem-pool UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree
t/meson.build +1 -1
@@ -1,5 +1,6 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', + 'unit-tests/u-mem-pool.c', 'unit-tests/u-strvec.c', ]
@@ -43,7 +44,6 @@ unit_test_programs = [ 'unit-tests/t-example-decorate.c', 'unit-tests/t-hash.c', 'unit-tests/t-hashmap.c', - 'unit-tests/t-mem-pool.c', 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c',
t/unit-tests/t-mem-pool.c deleted +0 -31
@@ -1,31 +0,0 @@ -#include "test-lib.h" -#include "mem-pool.h" - -static void setup_static (void (*f)(struct mem_pool *),size_t block_alloc) -{ -struct mem_pool pool = { .block_alloc = block_alloc }; -f (&pool); -mem_pool_discard (&pool,0 ); -} - -static void t_calloc_100 (struct mem_pool *pool) -{ -size_t size =100 ; -char *buffer =mem_pool_calloc (pool,1 , size); -for (size_t i =0 ; i < size; i++) - check_int(buffer[i], ==, 0); -if (!check (pool->mp_block !=NULL )) -return ; -check (pool->mp_block->next_free !=NULL ); -check (pool->mp_block->end !=NULL ); -} - -int cmd_main(int argc UNUSED, const char **argv UNUSED) -{ -TEST (setup_static (t_calloc_100,1024 *1024 ), -"mem_pool_calloc returns 100 zeroed bytes with big block" ); -TEST (setup_static (t_calloc_100,1 ), -"mem_pool_calloc returns 100 zeroed bytes with tiny block" ); - -return test_done (); -}
t/unit-tests/u-mem-pool.c new file +25 -0
@@ -0,0 +1,25 @@ +#include "unit-test.h" +#include "mem-pool.h" + +static void test_many_pool_allocations (size_t block_alloc) +{ +struct mem_pool pool = { .block_alloc = block_alloc }; +size_t size =100 ; +char *buffer =mem_pool_calloc (&pool,1 , size); +for (size_t i =0 ; i < size; i++) +cl_assert_equal_i (0 , buffer[i]); +cl_assert (pool.mp_block !=NULL ); +cl_assert (pool.mp_block->next_free !=NULL ); +cl_assert (pool.mp_block->end !=NULL ); +mem_pool_discard (&pool,0 ); +} + +void test_mem_pool__big_block (void ) +{ +test_many_pool_allocations (1024 *1024 ); +} + +void test_mem_pool__tiny_block (void ) +{ +test_many_pool_allocations (1 ); +}
Signature · 1 line
2.34.1
Re: [PATCH v3 2/4] t/unit-tests: convert mem-pool test to use clar test framework
Quoted 2 lines · Seyi Kuforiji
Adapt the mem-pool test script to use clar framework by using clar assertions where necessary.Test functions are created as a standalone to
Nit: missing space post period. Rest of tha patch looks good!
Quoted 1 line
test different test cases.
[snip]
PATCH v3 3/4 t/unit-tests: adapt priority queue test to use clar test framework
In reply to Seyi KuforijiConvert the prio-queue test script to clar framework by using clar assertions where necessary. Test functions are created as a standalone to test different cases.
update the type of the variable j from int to size_t, this ensures compatibility with the type used for result_size, which is also size_t, preventing a potential warning or error caused by comparisons between signed and unsigned integers.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-prio-queue.c | 91 ----------------------------------- t/unit-tests/u-prio-queue.c | 94 +++++++++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 93 deletions(-) delete mode 100644 t/unit-tests/t-prio-queue.c create mode 100644 t/unit-tests/u-prio-queue.c
Makefile +1 -1
@@ -1339,6 +1339,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool +CLAR_TEST_SUITES += u-prio-queue CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1351,7 +1352,6 @@ UNIT_TEST_PROGRAMS += t-hashmap UNIT_TEST_PROGRAMS += t-oid-array UNIT_TEST_PROGRAMS += t-oidmap UNIT_TEST_PROGRAMS += t-oidtree -UNIT_TEST_PROGRAMS += t-prio-queue UNIT_TEST_PROGRAMS += t-reftable-basics UNIT_TEST_PROGRAMS += t-reftable-block UNIT_TEST_PROGRAMS += t-reftable-merged
t/meson.build +1 -1
@@ -1,6 +1,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', + 'unit-tests/u-prio-queue.c', 'unit-tests/u-strvec.c', ]
@@ -47,7 +48,6 @@ unit_test_programs = [ 'unit-tests/t-oid-array.c', 'unit-tests/t-oidmap.c', 'unit-tests/t-oidtree.c', - 'unit-tests/t-prio-queue.c', 'unit-tests/t-reftable-basics.c', 'unit-tests/t-reftable-block.c', 'unit-tests/t-reftable-merged.c',
t/unit-tests/t-prio-queue.c deleted +0 -91
91 lines not on this page · raw message
t/unit-tests/u-prio-queue.c new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 3/4] t/unit-tests: adapt priority queue test to use clar test framework
Quoted 5 lines · Seyi Kuforiji
Convert the prio-queue test script to clar framework by using clar assertions where necessary. Test functions are created as a standalone to test different cases.
update the type of the variable
jfrom int tosize_t, this ensures
Nit: s/update/Update
Quoted 4 lines
compatibility with the type used for
result_size, which is alsosize_t, preventing a potential warning or error caused by comparisons between signed and unsigned integers.
[snip]
PATCH v3 4/4 t/unit-tests: convert reftable tree test to use clar test framework
In reply to Seyi KuforijiAdapts reftable tree test script to clar framework by using clar assertions where necessary.
--- Makefile | 2 +- t/meson.build | 2 +- t/unit-tests/t-reftable-tree.c | 86 ---------------------------------- t/unit-tests/u-reftable-tree.c | 78 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 88 deletions(-) delete mode 100644 t/unit-tests/t-reftable-tree.c create mode 100644 t/unit-tests/u-reftable-tree.c
Makefile +1 -1
@@ -1340,6 +1340,7 @@ THIRD_PARTY_SOURCES += $(UNIT_TEST_DIR)/clar/clar/% CLAR_TEST_SUITES += u-ctype CLAR_TEST_SUITES += u-mem-pool CLAR_TEST_SUITES += u-prio-queue +CLAR_TEST_SUITES += u-reftable-tree CLAR_TEST_SUITES += u-strvec CLAR_TEST_PROG = $(UNIT_TEST_BIN)/unit-tests$(X) CLAR_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(CLAR_TEST_SUITES))
@@ -1360,7 +1361,6 @@ UNIT_TEST_PROGRAMS += t-reftable-reader UNIT_TEST_PROGRAMS += t-reftable-readwrite UNIT_TEST_PROGRAMS += t-reftable-record UNIT_TEST_PROGRAMS += t-reftable-stack -UNIT_TEST_PROGRAMS += t-reftable-tree UNIT_TEST_PROGRAMS += t-strbuf UNIT_TEST_PROGRAMS += t-strcmp-offset UNIT_TEST_PROGRAMS += t-trailer
t/meson.build +1 -1
@@ -2,6 +2,7 @@ clar_test_suites = [ 'unit-tests/u-ctype.c', 'unit-tests/u-mem-pool.c', 'unit-tests/u-prio-queue.c', + 'unit-tests/u-reftable-tree.c', 'unit-tests/u-strvec.c', ]
@@ -56,7 +57,6 @@ unit_test_programs = [ 'unit-tests/t-reftable-readwrite.c', 'unit-tests/t-reftable-record.c', 'unit-tests/t-reftable-stack.c', - 'unit-tests/t-reftable-tree.c', 'unit-tests/t-strbuf.c', 'unit-tests/t-strcmp-offset.c', 'unit-tests/t-trailer.c',
t/unit-tests/t-reftable-tree.c deleted +0 -86
86 lines not on this page · raw message
t/unit-tests/u-reftable-tree.c new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 8 lines · Seyi Kuforiji
Hello,
This small patch series transitions the existing unit test files to the Clar testing framework. This change is part of our ongoing effort to standardize our testing approach and enhance maintainability.
changes in v3:
- Some small fixes were made to the commit messages
Thanks, the series looks good to me now.
Quoted 17 lines
Range-diff against v2:
1:00bb4d2880! 1:f9e163a181t/unit-tests: handle dashes in test suite filenames
@@ Metadata
## Commit message ##
t/unit-tests: handle dashes in test suite filenames- The script is designed to extract function signatures that match a
- specific pattern derived from the unit test file's name.
-generate-clar-decls.shdoes not pick up dashes in filenames, which
- prevents the scripts from being run.
+ "generate-clar-decls.sh" script is designed to extract function
+ signatures that match a specific pattern derived from the unit test
+ file's name. The script does not know to massage file names with dashes,
+ which will make it search for functions that look like, for example,
+test_mem-pool_*. Having dashes in function names is not allowed
+ though, so these patterns won't ever match a legal function name.
Quoted 5 lines
Adapt script to translate dashes (
-) in test suite filenames to underscores (_) to correctly extract the function signatures and run-: ---------- > 2: f46438f53e t/unit-tests: convert mem-pool test to use clar test framework -: ---------- > 3: f5cabebd3a t/unit-tests: adapt priority queue test to use clar test framework -: ---------- > 4: 5323873612 t/unit-tests: convert reftable tree test to use clar test framework
The range-diff is still not correct :P Now it seems like you only passed the first commit of your v2 to it, instead of the tip of the v2 branch.
Patrick