Commit Graph

91 Commits

Author SHA1 Message Date
Bas van den Berg
99c916e2d8 Makefile: use $CC instead of hardcoded gcc 2017-03-05 13:41:02 +01:00
Bas van den Berg
0ea727141b Merge branch 'mikedld-warnings-elimination' 2017-03-05 13:40:50 +01:00
Mike Gelfand
301626b2b2 Make function declarations proper prototypes
Where not possible (as with `ctest::run`), suppress the warning.

This eliminates "function declaration isn't a prototype [-Wstrict-prototypes]"
GCC warning.
2017-03-05 12:59:23 +03:00
Mike Gelfand
f5525fe227 Don't inline non-inlinable functions
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.
2017-03-05 12:55:12 +03:00
Mike Gelfand
5bb5e4310f Suppress noreturn attribute suggestion
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.
2017-03-04 23:14:40 +03:00
Mike Gelfand
e5d42fc3c3 Reorder ctest struct fields for better packing
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.
2017-03-04 23:02:01 +03:00
Mike Gelfand
fb62076f4f Mark printf-like functions as such
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.
2017-03-04 22:12:30 +03:00
Mike Gelfand
7ca2060993 Explicitly mark data variable unused
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.
2017-03-04 21:55:35 +03:00
Mike Gelfand
26ab614fac Declare test case functions static
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.
2017-03-04 21:40:07 +03:00
Mike Gelfand
16b78ef57c Prefix the rest of symbols with CTEST_IMPL_ and ctest_ for symmetry 2017-03-04 21:18:44 +03:00
Mike Gelfand
8e2f92d666 Don't use names starting with two underscores
Instead use CTEST_IMPL_ prefix for internal macros.

This eliminates "macro name is a reserved identifier [-Wreserved-id-macro]"
Clang warning.
2017-03-04 21:02:16 +03:00
Bas van den Berg
ae3a381d28 added ASSERT_INTERVAL to test for intervals 2016-02-22 15:43:03 +01:00
Bas van den Berg
7a78010830 updated copyright for 2016 2016-02-22 15:39:34 +01:00
Mike Gelfand
7a7bc6caed Fix "'...' was marked unused but was used" warnings
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.
2016-01-09 14:13:48 +03:00
Bas van den Berg
58dd9bf9d2 Readme: hint type on code fragments 2016-01-07 22:37:39 +01:00
Bas van den Berg
a66d37d10b describe features in Readme, remove from Makefile 2016-01-07 22:36:21 +01:00
Mike Gelfand
97289c76ab Pass const char* where mutability is not required 2016-01-06 20:42:10 +01:00
Bas van den Berg
bafa19e686 changed COLOR_OK -> CTEST_COLOR_OK to make it same as other features 2016-01-06 20:38:12 +01:00
Mike Gelfand
586b6bc056 Use proper types and format specifiers with *printf
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`.
2016-01-06 15:29:01 +03:00
Bas van den Berg
c0e79d4189 fix TearDown cast 2015-11-30 20:36:36 +01:00
Christian Wressnegger
447d03f49e explicitly cast the output of find_symbol function 2015-11-30 15:11:35 +01:00
Bas van den Berg
097d3ede68 CTEST_USE_COLORS -> CTEST_NO_COLORS (default on, users can disable) 2015-11-23 20:11:02 +01:00
Christian Wressnegger
dfb8d97ab4 CTEST_USECOLORS -> CTEST_USE_COLORS 2015-11-23 20:05:46 +01:00
Christian Wressnegger
e5e75b649e maintain a defintion (CTEST_USECOLORS) for the use of colors 2015-11-23 20:05:46 +01:00
Christian Wressnegger
5a49d09a7c make use of the new ASSERT_*_U functions in "test_large_numbers" test 2015-11-23 19:57:07 +01:00
Christian Wressnegger
1baa829a02 differentiate beetween signed and unsigned comparisons 2015-11-23 19:57:07 +01:00
Christian Wressnegger
cb64b0beb9 int might not be large enough to correctly represent the buffer's size 2015-11-23 19:57:07 +01:00
Yury Melnichek
69bdd083ac Fix unused parameter warning. 2015-11-23 14:21:47 +03:00
Bas van den Berg
9c8a166416 style changes 2015-11-14 23:20:43 +01:00
Christian Wressnegger
e01e09d71e explicit time conversion within getCurrentTime function 2015-11-14 23:16:57 +01:00
Bas van den Berg
dcaf6fb141 removed unused my_name var 2015-11-14 23:16:24 +01:00
Christian Wressnegger
d6eeccb8a6 maintain a common vprint_errormsg function for printing error messages
(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.
2015-11-14 23:16:02 +01:00
Christian Wressnegger
d33eb63466 fix Windows build (using MinGW) 2015-11-14 23:15:52 +01:00
Shaden Smith
a1d99cc932 added support for comparing doubles 2015-09-02 19:53:56 +02:00
Bas van den Berg
5ea9f2dbf4 Fixed Issue 10: separate LICENSE file, thanks Shaden 2015-09-02 19:49:29 +02:00
Bas van den Berg
21dd34029b updated Readme for signals 2015-09-02 19:46:04 +02:00
Bas van den Berg
0f7e32599f print note to say some tests are supposed to fail in example 2015-07-17 08:55:35 +02:00
Bas van den Berg
8c98c7d86a Segfault: dont use constructor feature, but just register in main 2014-09-04 15:41:03 +02:00
Nicolás Pernas Maradei
9aee42fa2c Capture SIGSEGV signals
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
2014-09-03 23:29:45 +01:00
Bas van den Berg
a48634c301 added sample output image 2014-09-02 13:15:30 +02:00
Bas van den Berg
1bc771c43e Fixed warning on 64bit systems 2014-09-02 13:10:54 +02:00
Bas van den Berg
1eacdce528 CTEST_ERR now does longjmp and doesn't return.
This can be used to create custom fail functions like
2014-07-10 14:06:19 +02:00
Bas van den Berg
17a2ab6940 made CTEST_ERR public 2014-07-10 14:04:06 +02:00
Bas van den Berg
0a9ae5bd30 added const for correctness 2014-07-08 12:00:05 +02:00
Bas van den Berg
2094e1ee36 added ASSERT_DATA to compare buffers 2013-02-27 09:05:42 +01:00
Bas van den Berg
797e8b2604 added markup to README 2013-01-24 07:56:56 +01:00
Bas van den Berg
20e239946a Merge pull request #4 from lgov/master
Fix segfault when testing NULL pointer with expected string + update assert_ to take long instead of ints.
2012-10-17 22:50:21 -07:00
lgov
283533539b * ctest.h
(assert_not_equal): Change types to long to make it support both int and long.
* mytests.c
  (test_large_numbers): New test.
2012-10-17 21:24:35 +02:00
lgov
5681670cc1 * ctest.h
(assert_equal): Change types to long to make it support both int and long.
2012-10-17 21:17:23 +02:00
lgov
044be62091 Fix segfault when testing NULL pointer with expected string.
* ctest.h
  (assert_str): Check for NULL-pointers before invoking strcmp.

* mytests.c
  (test_null_null, test_null_string,
   test_string_null, test_string_diff_ptrs): Add some new tests.
2012-10-16 23:55:37 +02:00