brarcher [Mon, 27 Jan 2014 03:18:24 +0000 (03:18 +0000)]
change argument for 'close' from 2 -> 1
The close variable determines if the file will be closed
after logging completes. It is used as a flag, and only really
needs to be '0' or '1'. A value of '2' is just confusing.
brarcher [Sat, 25 Jan 2014 18:18:25 +0000 (18:18 +0000)]
removing pedantic warning
This results in printing warnings about the assert macros and
comma pasting, such as the following:
In file included from check_check_master.c:6:
../src/check.h:301:75: warning: Use of comma pasting extension is non-portable
[-pedantic]
...__LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
^
To remove this warning, the macros would need to be reworked.
brarcher [Sat, 25 Jan 2014 18:18:21 +0000 (18:18 +0000)]
removing -Wmissing-noreturn
This warnings points out that many unit tests could be
declared as 'noreturn'. As all tests could or could not
return (it is up to them), the warning is being dropped.
brarcher [Sat, 25 Jan 2014 18:18:17 +0000 (18:18 +0000)]
simplify path and file name handling and honor const rules
the path and file name variables are not const, but were assigned
const strings. However, both variables could be reassigned
non const data, and the path_name could be allocated data.
To prevent this mix, they are both non-const and initially NULL.
If they are NULL during the print, they are replaced before printing.
Further, the path_name is now always free'd at the end, as it is
either NULL or allocated memory.
brarcher [Sat, 25 Jan 2014 18:18:14 +0000 (18:18 +0000)]
no longer violate the const part of 'const char *' in send functions.
FailMsg and LocMsg contain char* fields which are not const. Assigning
the passed const char* to a FailMsg or LocMsg violates the const.
To avoid this, a copy of the data is made using strdup. Yes, the
extra copy is functionally unnecessary, but to honor the const
it must be done.
The alternative is to make the char* fields in FailMsg and LocMsg
const. This will not work, however, as those fields are sometimes
assigned malloc'ed data in the code and free'd. You cannot pass
a const pointer to free without a warning.
brarcher [Sat, 25 Jan 2014 18:18:12 +0000 (18:18 +0000)]
Removing const identifier from List data structure
The const identifier on the data field of List would imply that
nothing is ever done to modify or destroy the data. However, the
data can be accessed later and modified or freed, as was being done
in places. By removing the const identifiers, the implied safety
of the stored values (which is being violated anyway) is not
advertised in the API.
brarcher [Sat, 25 Jan 2014 18:18:08 +0000 (18:18 +0000)]
change expected exit values of tests to consistently be signed chars
when a forked process finishes, waitpid() will return the status
as an int. Several macros determine what the status means.
WEXITSTATUS() is defined as returning the low-order 8 bits of the status
argument that the child process passed to _exit() or exit(), or the
value the child process returned from main(). It makes sense for the
value to be stored as either a signed or unsigned char. As the
decision is arbitrary (e.g. it only matters internally to check),
signed is used to keep consistent with the _tcase_add_test function.
brarcher [Sat, 25 Jan 2014 18:18:05 +0000 (18:18 +0000)]
Changing duration returned from DIFF_IN_USEC to unsigned long
In the case that the diff returned from the start and end of the test
overflowed an unsigned int, making the container for the result
an unsigned long. (This is the type returned from the macro anyway).
brarcher [Thu, 9 Jan 2014 03:51:55 +0000 (03:51 +0000)]
check_check_pack: use NULL as 'invalid string' instead of a literal
Just in case something does go wrong, the string literal could
end up being free'd. To prevent this, use NULL as the "this should
not happen" example instead.
brarcher [Mon, 6 Jan 2014 13:25:14 +0000 (13:25 +0000)]
test_vars: also check @IS_MSVC@ content
On autotools if @IS_MSVC@ is not defined, it is left as a string
literal, instead of being nothing. Because of that, the content
is now also checked. For CMake and MSVC, @IS_MSVC@ will be '1'.
Otherwise, it can be anything else.
brarcher [Mon, 6 Jan 2014 04:41:46 +0000 (04:41 +0000)]
Only create datetime string if localtime_r succeeded
On MSVC localtime_r (which redirects to localtime in libcompat)
can fail. The reason is not yet known. Instead of printing
garbage in this case, simply do not print the date time.
brarcher [Mon, 6 Jan 2014 04:41:41 +0000 (04:41 +0000)]
libcompat: remove alternatives for localtime_r
returning to the previous localtime_r implementation that uses
localtime. The _localtime64_s implementation had issues, in that
it wanted to write to the "now" variable. (Should have been
passed "result" instead). Further, on MSVC (for which this replacement
is being considered) localtime redirects to _localtime64_s anyway.
For how Check is using localtime_r, just using localtime is
sufficient.
brarcher [Sat, 4 Jan 2014 18:34:08 +0000 (18:34 +0000)]
test_output.sh: add tests for srunner_print()
There were no tests for srunner_print(). These tests, when run
with the STDOUT_DUMP output type, will output the normal
output to stdout, then call
srunner_print()
on each output type, dumping that to stdout.
brarcher [Sat, 4 Jan 2014 18:34:01 +0000 (18:34 +0000)]
check_log.c: remove unnecessary checks for CK_ENV
this code is unnecessary, as srunner_register_lfun will
determine the real print mode before stdout_lfun gets called.
That is, CK_ENV will never be passed.
brarcher [Sat, 4 Jan 2014 18:33:49 +0000 (18:33 +0000)]
Add new test case for Check error printouts
When check hits an eprintf() call, this is a "Check error printout".
This test case, only available when fork() is available, will
test the instances when check should hit an eprintf() and exit.
brarcher [Sat, 4 Jan 2014 18:33:35 +0000 (18:33 +0000)]
check.h: export suite_tcase() function
Because it did not have CK_EXPORT in front of it, the symbol
was not being exported. It looks like this function should
be callable, but it could not before.
brarcher [Thu, 2 Jan 2014 02:43:22 +0000 (02:43 +0000)]
cmake: remove HAVE_* for snprintf in config.h.in
Having these caused MSVC to not compile, not having them
makes Linux fail prior to adding these definitions
in CMakeLists.txt. As they now cause problems for MSVC, but
the CMakeLists.txt definitions allow Linux to compile, there
should not be any issue.
brarcher [Thu, 2 Jan 2014 02:43:07 +0000 (02:43 +0000)]
Check for __GNUC__ consistently
Some tests will only be executed if compiled on gcc. However,
some of the tables did not have the related entries
compiled out when compiled on MSVC. This lead to crashes during
tests. Removing the entries correctly prevents this.
brarcher [Thu, 2 Jan 2014 02:42:43 +0000 (02:42 +0000)]
check_check_sub: sleep during test_eternal
For some reason on Linux (maybe other systems) if
check_check is canceled (e.g. Ctrl+C) when the test_eternal
is running, check_check will still run in the background
on this test. Because the test is in a tight loop,
it eats lots of CPU. Replacing the busy loop with the sleep
does not fix the problem, but at least when it happens
it will not take lots of CPU.
brarcher [Thu, 2 Jan 2014 02:42:40 +0000 (02:42 +0000)]
libcompat: remove replacement for sleep()
Before working on MSVC support, the replacement sleep() call
only called assert(). Instead, it was assumed that the related
code would not be called, as the only platform that did not
provide a sleep() call also did not provide fork() (e.g. Windows),
so the related code never got executed.
As we still do not provide a fork(), the sleep() replacement is
unnecessary as it is never called. If, in the future, Check
provides a fork() replacement, then a sleep() replacement will
make sense.
brarcher [Thu, 2 Jan 2014 02:42:37 +0000 (02:42 +0000)]
libcompat: remove unsetenv replacement
no system to date has been found that provides setenv
but not unsetenv. If setenv is unavailable, all related
tests are disabled at compile time. This stub replacement
does not serve any purpose. If in the future a system
with unsetenv is found that does provide setenv, then
the unit tests will need to disable all tests that
require unsetenv.
brarcher [Thu, 2 Jan 2014 02:42:33 +0000 (02:42 +0000)]
libcompat: remove putenv replacement
the putenv replacement did nothing except call abort().
There is no platform (yet) which did not have putenv()
but did have fork(). For this reason, the assert()
has yet to be hit, meaning that the stub itself is
pointless.
If in the future a platform is found to have fork() but
not putenv(), then the related tests need to be disabled
at compile time using something like
#if defined(HAVE_DECL_PUTENV)
along with a related AC_CHECK_DECLS check.
brarcher [Thu, 2 Jan 2014 02:42:29 +0000 (02:42 +0000)]
libcompat: do not offer to replace setenv
if setenv is missing on the system, the only thing that is
affected are unit tests. Check itself does not need setenv.
In this case, the affected unit tests are not compiled in.
This change removed the stub setenv replacement which was
never called, even when a system did not provide it.
brarcher [Thu, 2 Jan 2014 02:42:26 +0000 (02:42 +0000)]
replace how setenv availability is detected
The generated config.h file defines HAVE_DECL_SETENV, which
was checked at compile time in libcompat to create
HAVE_WORKING_SETENV. There is no reason to have the latter, when
the former can be used directly.
brarcher [Tue, 31 Dec 2013 20:39:33 +0000 (20:39 +0000)]
test_xml_output: do not use -n with echo
On some systems (e.g. OSX) a script will use the built-in version
of echo, which does not support arguments. Instead of getting no
newline, instead there is an extra "-n" in the output.
brarcher [Tue, 31 Dec 2013 20:39:31 +0000 (20:39 +0000)]
autotools: include pthread.h when checking for clockid_t/timer_t
Must include pthread.h to check for clockid_t and timer_t. This is
because MinGW and MinGW-w64 both put the time related definitions
in pthread headers and not in sys/types.h. Without optionally
including pthread.h, the check for these types may mistakenly fail.
brarcher [Fri, 27 Dec 2013 18:18:17 +0000 (18:18 +0000)]
consolidate all output tests into ex_output.c
This way, it will be simpler to add more outputs. Simply extend
this file. Further, if any bugs are found and needed to be
regression tested, they are added to only one place.