Jan Pokorný [Tue, 1 Mar 2016 17:41:58 +0000 (18:41 +0100)]
Fix segfault when memmoving with negative/enormous n
I observed a segmentation fault caused by trying to memmove by -15,
which makes 18446744073709551601 on my 64-bit platform after an argument
type promotion (from int into size_t). In my case, this was connected
with filling up disk during the test facilitated by check, hence I derive
that the main issue was that not enough bytes for particular type of
message was actually read (and previously written, for that matter) and
because of this incompleteness, get_result happily consumed more bytes
than was read.
Additional debugging info at the point of segfault (src/check_pack.c):
> 468│ /* Move remaining data in buffer to the beginning */
> 469├> memmove(buf, buf + n, nparse);
> 470│ /* If EOF has not been seen */
> 471│ if(nread > 0)
>
> (gdb) p nparse
> $1 = -15
> (gdb) p n
> $2 = 23
> (gdb) p nread
> $3 = 0
Georg Sauthoff [Tue, 29 Dec 2015 17:10:52 +0000 (18:10 +0100)]
Use only POSIX conforming features of printf
This fixes 3 test failures on Solaris 10.
POSIX standardized printf, but the hex style \xHH sequences
aren't included in the standard. POSIX printf does understand
octal style \NNN sequences, though.
This should also work with shells where printf is a builtin (e.g.
on Lubuntu which probably uses dash).
Tested with xpg4-sh on Solaris 10 and bash/zsh/dash on Linux.
brarcher [Wed, 23 Dec 2015 16:59:04 +0000 (16:59 +0000)]
checkmk: use double slash in regular expression
For many awk implementations using both a single and double slash
escapes in regex expressions in strings works correctly. However,
it was observed on Solaris that a single slash results in the
literal value being added to the string (e.g. \n was a newline)
and only the double slash works as expected.
As there should be no harm, updating the regex expressions to use
double slashes.
Previously output XML files could contain illegal characters.
Some of these characters could be encoded, and others should
not be output at all.
This change will attempt to encode characters if they are not
printable or are special. Note that if a test contains a UTF-8
charater it will not be printed out accurately.
In order to get the tests for encoding XML characters to work,
the characters separating fields in a shell variable needed to
be changed. Originally white space would separate fields,
meaning shell would eat the extra whitespace in the tests.
Because of the change, the xml output test needed to be
reworked to not rely on white space field separators.
Additionally, the printf program is used to properly un-escape
strings used in the tests.
brarcher [Sun, 2 Aug 2015 16:59:36 +0000 (16:59 +0000)]
configure: Remove duplicated use of AC_USE_SYSTEM_EXTENSIONS
Either the first or the second one is redundant so one should be
removed but beware, there's a bug introduced in automake 1.14
(fixed in 1.15) that would potentially cause trouble if you put it
before AM_INIT_AUTOMAKE.
More info about this automake bug here:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15981
This header is necessary one some platforms where some portions
of check.h are unrecognized. For example, using the MSVC compiler
on Windows the pid_t usage in check.h results in a compiler error.
brarcher [Sun, 14 Jun 2015 16:07:03 +0000 (16:07 +0000)]
configure: fix check micro version
This was not updated during the last release. Although it is technically
still out of date (as this is now check 0.9.14+), it is at least
a little more correct.
brarcher [Sun, 14 Jun 2015 15:55:02 +0000 (15:55 +0000)]
cmake: Include time.h on several checks to prevent false negatives
The clock_t, clockid_t and timer_t types are deemed not found when they
are actually available if time.h is included. Include the header during
the checks.
brarcher [Thu, 7 May 2015 03:16:26 +0000 (03:16 +0000)]
Catch SIGINT and SIGTERM and kill running tests
Tests are forked and placed into their own process group.
If the test runner process receives a terminal signal it
exits but the test continue running. This could result
in test processes running indefinitely if they do not
exit themselves.
This changes catches SIGINT and SIGTERM signals and kills
the test processes.
Note that other signals, such as SIGSEGV and SIGFPE will still
result in test processes being leaked.
brarcher [Thu, 7 May 2015 03:16:23 +0000 (03:16 +0000)]
Change behavior of calls for fork() on non-fork() platforms
It was requested by users of Windows (e.g. non-fork() supporting
platforms) that calls to set CK_FORK mode be ignored if fork()
is not supported. This is to avoid the need to detect the
current platform and conditionally compile unit test code.
brarcher [Thu, 12 Mar 2015 02:50:43 +0000 (02:50 +0000)]
Do not remove check.info during 'clean' target
It was observed that if one does not have texinfo installed
and invoked "make clean" then a subsequent build will fail
because the docs cannot be built. The issue is that
"make clean" will remove check.info and require it be rebuilt.
brarcher [Fri, 28 Nov 2014 05:50:22 +0000 (05:50 +0000)]
report correct error if teardown after failure in no fork mode
In nofork mode, the location of a failed assertion within a test
case is lost if that test case has a checked teardown fixture
(even if that fixture function is empty).
The reason why this happens is this: the end of the message sequence
coming down the pipe is CK_MSG_LOC (location of failing test),
CK_MSG_FAIL, CK_MSG_CTX (TEARDOWN). It is this final message that
confuses things, because rcvmsg_update_ctx() updates rmsg->lastctx
(which I suspect is the right thing for it to do), which is the ctx
value used by the first 'if' body in construct_test_result() in its
call to tr_set_loc_by_ctx().
The solution is to initialize tr->ctx to rmsg->failctx if
it is not CK_CTX_INVALID.
The AM_PROG_AR macro was introduced into Automake 1.11.2
(Dec 2011), which is used in Check's configure script and
in the example's. Check for this version of Automake
instead.
Do not vsnprintf expression string passed to ck_abort()
If ck_abort() detects a failure, the expression which was
evaluated is passed to _ck_assert_failed to print.
However, the previous behavior was to send the expression
to vsnprintf(), which would expect it to be properly formatted.
If the expression in ck_abort() contained % characters, such as:
ck_abort(bar%foo == 0)
the "%f" portion would be printed as some non-existent floating
point number.
Now, if there is no message passed (and the expression is to
be used) simply report the expression as is. Only format
something with vsnprintf() if there is actual data that
expects formatting.
tests: escape % before passing string to ck_abort_msg()
ch_abort_msg() expects printf arguments. Passing in a constant
string that happens to have '%' in it will not end as expected,
as the underlying vsnprintf will attempt to format them.
As some unit tests now attempt to have improper output involving
'%' in expressions, it is now possible that the failure message
which is expected during Check's unit tests involve '%'. As such,
only a properly escaped string should be passed to ck_abort_msg().
This change will force the string passed to ck_abort_msg() in the
test_check_failure_msgs unit test to properly escape any '%'
found, so that if a failure did happen the correct text is printed
to the screen.
An automated build has been setup for the Check project on
OpenCSW's BuildBot, which builds for Solaris. The link leads
to the latest build status of Check on several architectures.
brarcher [Tue, 24 Jun 2014 13:00:29 +0000 (13:00 +0000)]
autotools: remove AIX fix for broken xlc v6 compiler
The issue with the xlc v6 compiler on AIX seems to be a compiler
bug which is resolved in future releases of the compiler.
This fix, as it turns out, did not properly detect the bug
or resolve the issue. Unless it becomes really important,
the attempt to get around the bug is removed from Check.
brarcher [Mon, 23 Jun 2014 04:13:54 +0000 (04:13 +0000)]
Add comment for why test should be CK_FORK mode only
Some of these tests, now that checked fixtures can be used
with CK_NOFORK mode, may be enabled regardless of fork()
availability. This specific test, however, will not work as is
without fork().
brarcher [Mon, 23 Jun 2014 04:13:52 +0000 (04:13 +0000)]
rework how line numbers are verified in check_check_sub.c
Line number checking failures in check_check_sub.c are broken
and were broken since r527 (2009-02-02).
_STR(__LINE__) as is evaluates to "__LINE__", which results in -1
being returned from atoi. A -1 means to not check the line
number of the failure. As a result, no line numbers were checked
since r527. Checking with strtol finds the conversion failure,
which is what identified this bug.
Note that more redirection can be used to convert __LINE__ to a string,
e.g.:
#define LINE_TO_STRING(Y) #Y
#define _LINE_TO_STRING(Y) LINE_TO_STRING(Y)
#define _STR(Y) _LINE_TO_STRING(Y)
However, then the line converted to a string is the line which references
the macro. I.e., not the line number of the test, which was expected.
The tests of the failure line numbers are valuable. To fix them,
instead of determining the values at compile time, they are determined
at run time. Whenever a test should fail, record_failure_line_num()
will be used to record the line number to a temporary file.
This in several cases required splitting up a test which was used
to induce a success and a failure. For such functions, there is
now a clear function to use when a success is required (no call
to record_failure_line_num()) and one to use when a failure
is required at a specific location (to call record_failure_line_num()).
The FILE pointer is created at the setup of the sub suite, and
deleted on the cleanup. The test_check_failure_lnos test then
will, for each failure, read the next line in the file and make
sure it matches the value reported by Check.