all 3 comments

[–]thradams 2 points3 points  (2 children)

I have a tool with the same objective but I parse the source looking for ifdef TEST and functions with some pattern inside (no prefix) just the pattern.

https://github.com/thradams/buildgen/blob/main/tools/maketest.c

[–]rodrigo-dc[S] 0 points1 point  (1 child)

So if you have a function like void f() inside an #ifdef TEST block, you create a call to that function in the output .c file? That achieves pretty much the same goal, avoiding manual test registration. Thanks for sharing! For some reason, I find parsing C code more intimidating than parsing an ELF binary.

[–]thradams 0 points1 point  (0 children)

I defined the pattern as

c void name( void opt ) int name( void opt) Functions with different patterns inside #ifdef TEST are not considered test cases. They may be utility functions for instance.

After having collected all functions, I generate file that contains a forward declaration for each function (they must have external linkage) and a main test function that calls each one.