Branden Archer [Wed, 29 Jun 2016 02:12:23 +0000 (22:12 -0400)]
Do not report failure line numbers if file not setup
When running the master suite failure line numbers are written to
a file. Usually this is fine. However, the check_mem_leak.c test
re-uses the same tests. As a result, every time a failure is hit
a SEGV occurs because the file is never setup.
The memory leak test does not check against the line numbers,
so omitting these are fine. This fix prevents lots of SEGV
failures when running check_mem_leak.c under valgrind.
Branden Archer [Sun, 19 Jun 2016 20:52:26 +0000 (16:52 -0400)]
Disallow a test case from being added to a suite twice
It was possible to add a test case to a suite more than
once. When the suite is freed later on the test case is
freed twice, causing a double free error.
Although is likely a bug from the test writer, this change
allows check to disallow double additions to prevent
double freeing a test case.
Branden Archer [Sun, 19 Jun 2016 20:49:20 +0000 (16:49 -0400)]
Remove double addition of test suite
The original purpose of adding the default timeout tests twice
does not seem to be relevant anymore; the timeout tests have been
split into several different types, each using either the
tcase_set_timeout or an environment variable. The tc_timeout_default
suite never has anything but the default timeout set, so the
spirit of why it was originally added no longer applies.
In addition, if the suite were formally torn down it would cause
a double free error.
Branden Archer [Thu, 26 May 2016 03:15:17 +0000 (23:15 -0400)]
Add test case where %n is passed into a ck_assert call
In the past it was possible to cause issues if arguments
were passed into ck_assert* macros which included %n.
Exist unit tests check for output format options, such as
%d and %f. No test existed for %n, which writes a value to
memory if used.
Ulrich Eckhardt observed that passing something with a %n in it
would result in issues running Check 0.9.10. Although the
issue is already resolved, this commit adds the test case mentioned in
Ulrich's GitHub issue: https://github.com/libcheck/check/issues/41
the ltmain.sh script, generated by libtoolize, does not seem to honor the AC_CONFIG_AUX_DIR parameter. As a
result, the configure script will fail. To work around this, remove the AC_CONFIG_AUX_DIR option
to place all generated scripts into the current directory.
This is half an issue report and half a pull request.
The reason for this is that while autoreconf -fi works for most of the
needed scripts it doesn't copy ltmain.sh into build-aux which results
the following ./configure failure:
configure.ac:137: error: required file 'build-aux/ltmain.sh' not found
This patch, which is a similar one I've provided to cloog[0] which
allows ./configure to at least complete.
I'm not sure what you think since obviously the directory was used for
some reason, likely to reduce top-level directory clutter, but this at
least works for me.
Joshua D. Boyd [Tue, 22 Mar 2016 04:50:34 +0000 (00:50 -0400)]
In cmake build, use mkstemp when present
This fixes this error, seen when building with cmake:
check/src/check_msg.c:247: warning: the use of 'tempnam' is dangerous, better use `mkstemp'
CMakeLists.txt checks for mkstemp being present and sents a cmake
variable HAVE_MKSTEMP. The check_msg.c file will use mkstemp if
HAVE_MKSTEMP is true, but the cmake variable wasn't causing HAVE_MKSTEMP
to be defined for the C compiler.
lib/strsignal.c: strsignal() should be not be declared const
POSIX requires strsignal() to return a pointer to a char, not a pointer
to a const char. [1] On uClibc, and possibly other libcs, this causes
problems with the correct declaration in string.h.
[1] man 3 strsignal
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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.