This eliminates "redundant redeclaration of '..._setup' [-Wredundant-decls]"
and "redundant redeclaration of '..._teardown' [-Wredundant-decls]" GCC
warnings.
Where not possible (as with `ctest::run`), suppress the warning.
This eliminates "function declaration isn't a prototype [-Wstrict-prototypes]"
GCC warning.
This eliminates "function '...' can never be inlined because it uses variable
argument lists [-Winline]" and "inlining failed in call to '...': function
not inlinable [-Winline]" GCC warnings.
Marking `CTEST_ERR` function as noreturn leads to same warning appearing
for `ctest_fail` function; marking the latter as noreturn as well leads
to warnings in user test cases which is not something we want.
This eliminates "function 'CTEST_ERR' could be declared with attribute
'noreturn' [-Wmissing-noreturn]" Clang warning.
This resulted in gaps between `ctest` structs with GCC on amd64, so adding
aligned(1) attribute to the section fix this.
This eliminates "padding struct 'struct ctest' with 4 bytes to align 'data'
[-Wpadded]" and "padding size of 'struct ctest' with 4 bytes to alignment
boundary [-Wpadded]" Clang warnings.
This eliminates "format string is not a string literal [-Wformat-nonliteral]"
(and after that "format specifies type 'void *' but the argument has type
'... *' [-Wformat-pedantic]") Clang warning.
Not using `__attribute__((unused))` as I think the warning could be useful:
if one is using CTEST2, they should be using `data`.
This eliminates "unused parameter '...' [-Wunused-parameter]" GCC/Clang
warning.
Provide prototypes for setup and teardown test case functions as making
them static is not possible due to weak linking.
Provide prototype for ctest_main function as making it static might break
existing code if someone does `#define ctest_main main`.
This eliminates "no previous prototype for function '...'
[-Wmissing-prototypes]" Clang warning.
For that, declare test data structs static and use "used" attribute which
is more appropriate in this case instead of "unused" attribute.
Make use of `__TNAME()` macro instead of explicitly concatenating suite and
test name in two places where above warning was issued along the way.
Use `intmax_t` and `uintmax_t` for signed/unsigned integer assertions.
Previously used `size_t` isn't good enough as we could have 32-bit system
and still be able to work with 64-bit numbers.
Include `<stddef.h>` instead of `<stdio.h>` (which is included under
`CTEST_MAIN` ifdef anyway) to get `size_t` definition.
Use `PRI*` macros instead of `%llu` which may not be supported on some
systems.
Fix a couple of incorrect formatting instances, e.g. when `%d` was used
for line number output, and line number was being (mistakenly? looks like
copy-paste leftovers) casted to `long long` and `unsigned long long`.
(v)snprintf may return -1 on errors. Hence using its return value to
alter the position of the error message buffer needs to undergo some
checking first.
Add SIGSEGV singal handler to capture signal and print a visible mesage letting
the user know the test has seg fault.
When the signal is caught the handler is fired off to print the message and then
the same signal is sent back again to the process so it can be terminated.
The signal hanlder gets registered before the main() function gets executed
making use of GCC constructor attribute.
The functionality can be enabled defining CTEST_SIG before including ctest.h