brarcher [Wed, 25 Dec 2013 03:04:44 +0000 (03:04 +0000)]
modify how HAVE_FORK is determined in code
autotools will define HAVE_FORK only if fork is available.
cmake can do the same thing on Linux, however on Windows
the only way to get HAVE_FORK to appear is to make it always
appear and contain a value. To support both autotools and
cmake, change the compile time check slightly to check that
HAVE_FORK is 1.
brarcher [Wed, 25 Dec 2013 03:04:39 +0000 (03:04 +0000)]
Fix fileno(get_pipe()) for MSVC
MSVC is unable to parse the code:
fileno(get_pipe())
when directly as an argument for ppack() or punpack(). This may
be because fileno() is replaced with _fileno() in a #define.
brarcher [Wed, 25 Dec 2013 03:04:19 +0000 (03:04 +0000)]
cmake: always compile in memory leaking tests
The check_mem_leaks is not configured to compile with cmake.
As the target for cmake is Windows, and Windows does not have
a valgrind that will work, there is no point in supporting
it.
brarcher [Mon, 23 Dec 2013 16:29:42 +0000 (16:29 +0000)]
test_xml_output: add tests for valid duration for tests
This is to check for the case where the duration is not -1
or in [0, CK_DEFAULT_TIMEOUT]. There was an issue with NO_FORK
mode where the duration was not valid.
brarcher [Mon, 23 Dec 2013 15:48:37 +0000 (15:48 +0000)]
move clock_gettime calls outside of setjmp context for NO_FORK mode
The test duration was getting smashed if tests failed in NO_FORK
mode. If the setjmp() function was used to abort a test, the end
time would not get captured. This resulted in arbitrary numbers
being written for the test's duration.
This change moves the settime() calls outside of the setjmp() context,
so the times get captured if the test passes or fails.
brarcher [Sat, 21 Dec 2013 00:04:59 +0000 (00:04 +0000)]
librt_timers.m4: use prev behavior when cross compiling
In the case where we are cross compiling, the POSIX detection of
the timer_create() function is skipped, and instead the usual check
for the existence of all the timer_* functions is done using
AC_REPLACE_FUNCS.
brarcher [Thu, 19 Dec 2013 19:47:11 +0000 (19:47 +0000)]
Do not include memory leaking tests in check_mem_leaks
check_mem_leaks is to be used with valgrind. That will check
if Check is leaking memory. Having tests that also intentionally
leak will give false positives.
brarcher [Thu, 19 Dec 2013 19:47:04 +0000 (19:47 +0000)]
Add #define for disabling unit tests that intentionally leak memory
Some tests intentionally leak memory. Usually this is not a concern.
However, we want to run some of our tests against valgrind, to make
sure that Check itself is not leaking any memory. To enable this,
the tests that intentionally leak memory will be conditionally
compiled out when building a unit tests program for use with
valgrind.
brarcher [Thu, 19 Dec 2013 16:48:27 +0000 (16:48 +0000)]
remove check_mem_leaks from "make check"
when run locally, all is well. Unit tests pass, and
valgrind says there is nothing wrong. When run on
some GNU/Linux build slave machine, running the unit test
dies with an invalid pointer free.
Will need to figure out how to reproduce this locally to
continue.
brarcher [Thu, 19 Dec 2013 04:31:49 +0000 (04:31 +0000)]
NEWS: add lines near the top that happen to mention 0.9.11
The distcheck target requires that the current version,
0.9.11, appear in the first 15 lines. After enough stuff
was added to NEWS, this broke, and the prereleasecheck
target (which uses distcheck) no longer worked.
These lines will have to be removed before the next release.
brarcher [Wed, 18 Dec 2013 23:03:06 +0000 (23:03 +0000)]
librt_timers.m4: check if timer_create() is usable
Adds a custom check for the timer_create() function on the target
system.
It was found that on OpenBSD, the timer_create(), timer_settime(),
and timer_delete() functions were only stubbed out. They set
errno to ENOSYS and return -1. To detect this and replace the timer_*
functions with libcompat's, this m4 file will execute a test
program on the system, checking for the ENOSYS errno.
brarcher [Wed, 18 Dec 2013 21:37:09 +0000 (21:37 +0000)]
check_mem_leaks: add new unit test for use against valgrind
The purpose of this test is to be used by valgrind to check for
memory leaks. Each public API that check exports is used at
least once. Tests which use non-public API, or leak intentionally,
are not included here.
The test should pass when run, and is added to the list of tests to
run with "make check".
Actually using valgrind to check for memory leaks is outside of its
running with "make check". One still would need to manually run
valgrind.
brarcher [Wed, 18 Dec 2013 19:46:56 +0000 (19:46 +0000)]
configure.ac: add option to force Check's replacement of timer_* functions
On OpenBSD 5.4 (and perhaps other BSDs) the timer_* functions
are implemented, but do nothing. Instead, they set errno to
ENOSYS (not available) and return -1. Check would check if
the timer_* functions were missing, and would use its own
replacements if they were. However, because they actually do
exist, Check does not know to replace them.
This adds another configure option, --enable-timer-replacement, which
will force Check's timer replacements instead of detecting the need.
There is still no checking if the replacements are needed or not
for OpenBSD, but at least this gives an option so check will work
properly.
brarcher [Tue, 17 Dec 2013 22:12:20 +0000 (22:12 +0000)]
fix potential leaks when assigning result message
In some cases, a result message has already been allocated,
which is then overwritten by set_fork_info(). Just in case,
check if tr->msg is not null, and if so free the value, before
assigning a new value.
brarcher [Tue, 17 Dec 2013 16:06:53 +0000 (16:06 +0000)]
Add tests for tap logging
These tests follow closely with what the logging tests cover, with
one small change. If fork() is disabled, one test case will
invoked exit() and cause the unit testing program to terminate
early. In that case, the tap output is expected to be incomplete.
brarcher [Tue, 17 Dec 2013 16:06:50 +0000 (16:06 +0000)]
add support for logging in TAP format
Logging in the Test Anything Protcol (TAP) format is useful
in general, but is especially useful on platforms where
fork() is unavailable. The TAP format requires that the
planned number of tests to run be specified, either at the
start or end of a test run. If the number of tests run does not
match the plan, the test run is marked as failed. As running
without fork() leaves the unit testing program open to failure
if a test aborts/segfaults/etc, validating the TAP output is
useful.
brarcher [Tue, 17 Dec 2013 03:28:26 +0000 (03:28 +0000)]
check.h: only mark _ck_assert_failed as noreturn when using fork
When fork is used, _ck_assert_failed will call exit() when a
failure occurs. Marking it as noreturn makes sense in this case.
When fork() is not used, longjmp() is called, which is a type of
return. Marking it as noreturn allows the compiler (gcc) to
make assumptions which are not true. Using longjmp causes
the unit testing program to segfault.
For this reason, the function is only marked as noreturn when
using fork(). Any static source code analysis to catch issues
must be done on a system with fork() to avoid possible false
positives.
brarcher [Mon, 16 Dec 2013 23:27:14 +0000 (23:27 +0000)]
change how assertions are called, to support source code analyzers
The assert functions that check provides are really macros that
funnel down to the _ck_assert_msg() function. That function receives
the result from the operation being checked, then decides if the unit
test should continue or should halt.
The assert function in C is sometimes also a macro. For example, the
following:
The __assert_rtn function is marked as "noreturn", and only gets invoked
when an assertion has failed. Because it only gets called when something
bad has happened, static code analysis can reason about when it is and is
not called, and make assumptions about the code being compiled.
To the point, this change refactors check's assert macros in such a way
that they result in a function being called only when the assertion
fails, and thus static code analyzers (such as clang's scan-build tool)
can reason when something is possible and impossible in test code. As a
result, if one wanted to run static analysis on unit test code, there
would be far fewer false positives.
brarcher [Mon, 16 Dec 2013 16:29:34 +0000 (16:29 +0000)]
web: change layout of landing page
Instead of a plain black/white page with text, the new layout
contains some color, a side pane with links and info on the
latest release, and some links.
All data related to the page is in the new subfolder "web".
The layout was from Open Source Web Design (oswd.org), and is
the NewsPortal layout by "Designs by Darren".
Compiled using gcc 4.7.2 with -Wall gives the following warning.
myfile.c:70:2: warning: initialization discards ‘const’ qualifier from pointer target type [enabled by default]
Adding a const qualifier to the variables in the _ck_assert_ptr macro,
as done for _ck_assert_str makes the problem go away.