]> granicus.if.org Git - check/log
check
11 years agocheck.h: only mark _ck_assert_failed as noreturn when using fork
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.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@871 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agochange how assertions are called, to support source code analyzers
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:

void foo(int *p)
{
   assert(p != NULL);
}

on OSX when preprocessed actually becomes:

void foo(int *p)
{
   (_builtin_expect(!(p != NULL), 0) ? __assert_rtn(__func_, "t.c", 4, "p != NULL") : (void)0);
}

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.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@870 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoweb: change link font size to be identical to left pane text size
brarcher [Mon, 16 Dec 2013 23:27:11 +0000 (23:27 +0000)]
web: change link font size to be identical to left pane text size

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@869 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agodoc: make it clear that autotools is not necessary to use check
brarcher [Mon, 16 Dec 2013 21:35:14 +0000 (21:35 +0000)]
doc: make it clear that autotools is not necessary to use check

Autotools is used to build Check, but it is not necessary
to use autotools for unit tests linked against Check.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@868 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoweb: add banner for CloudBees, and link at bottom of page
brarcher [Mon, 16 Dec 2013 21:23:23 +0000 (21:23 +0000)]
web: add banner for CloudBees, and link at bottom of page

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@867 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoweb: add tab to tutorial
brarcher [Mon, 16 Dec 2013 21:17:42 +0000 (21:17 +0000)]
web: add tab to tutorial

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@866 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agocheck.texi: add border around all source file examples
brarcher [Mon, 16 Dec 2013 16:29:36 +0000 (16:29 +0000)]
check.texi: add border around all source file examples

The border (cartouche) around the source code listings
makes it a little easier to figure out where the
example starts and stops.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@865 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoweb: change layout of landing page
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".

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@864 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agocheck_check_pack: remove unnecessary assignment
brarcher [Mon, 16 Dec 2013 16:29:27 +0000 (16:29 +0000)]
check_check_pack: remove unnecessary assignment

clang's scan-build static analyzer pointed out that the
assignment was unnecessary, as was ignored.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@863 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoMove Branden Archer to the maintainer's list
brarcher [Sat, 7 Dec 2013 05:05:17 +0000 (05:05 +0000)]
Move Branden Archer to the maintainer's list

Branden is now a maintainer.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@862 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agofix ck_assert_ptr_* causing const compilation warnings
brarcher [Sat, 7 Dec 2013 05:05:15 +0000 (05:05 +0000)]
fix ck_assert_ptr_* causing const compilation warnings

A test sequence such as:

const struct my_vtable expected_element;
struct my_vtable* test_element;
ck_assert_ptr_eq(test_element, &expected_element);

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.

Issue #91, patch submitted by user lordlod24.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@861 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agorestore development header to NEWS
brarcher [Tue, 5 Nov 2013 03:02:01 +0000 (03:02 +0000)]
restore development header to NEWS

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@860 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years ago* Update for release
brarcher [Tue, 5 Nov 2013 02:12:17 +0000 (02:12 +0000)]
* Update for release

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@857 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest*_output.sh: append SRCDIR to filenames
brarcher [Tue, 5 Nov 2013 02:09:21 +0000 (02:09 +0000)]
test*_output.sh: append SRCDIR to filenames

In case check is built out-of-tree, the SRCDIR is appended to
filenames. This will prevent a false-positive unit tests failures.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@856 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoadd check_stdint.h to DISTCLEANFILES
brarcher [Tue, 5 Nov 2013 02:09:19 +0000 (02:09 +0000)]
add check_stdint.h to DISTCLEANFILES

check_stdint.h should be cleaned during the distclean-generic make target,
but not the clean make target.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@855 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_vars: grab the srcdir variable
brarcher [Tue, 5 Nov 2013 02:09:17 +0000 (02:09 +0000)]
test_vars: grab the srcdir variable

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@854 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdd a .gitignore file
brarcher [Tue, 5 Nov 2013 02:09:15 +0000 (02:09 +0000)]
Add a .gitignore file

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@853 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoupdate svn URL in release process
brarcher [Tue, 5 Nov 2013 02:09:13 +0000 (02:09 +0000)]
update svn URL in release process

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@852 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years ago* Update for release
brarcher [Wed, 30 Oct 2013 03:22:55 +0000 (03:22 +0000)]
* Update for release

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@851 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUpdate for release
brarcher [Wed, 30 Oct 2013 03:18:17 +0000 (03:18 +0000)]
Update for release

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@850 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoTODO: note Cygwin and MinGW support for v0.9.11
brarcher [Wed, 30 Oct 2013 03:13:20 +0000 (03:13 +0000)]
TODO: note Cygwin and MinGW support for v0.9.11

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@849 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoNEWS: add info on support for MinGW/msys environment on Windows
brarcher [Thu, 24 Oct 2013 02:14:57 +0000 (02:14 +0000)]
NEWS: add info on support for MinGW/msys environment on Windows

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@848 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agochange check for valid clockid
brarcher [Thu, 24 Oct 2013 02:14:55 +0000 (02:14 +0000)]
change check for valid clockid

cygwin does not support CLOCK_MONOTONIC. However, a call to
clock_gettime(CLOCK_MONOTONIC, ...) will pass, whereas
a timer_create(CLOCK_MONOTONIC, ...) will fail. Use the
timer_create() call for the check instead.

However, be careful to only make the check if librt is available,
otherwise it is a waste. Or worse, if librt and alarm() are
unavailable, a timer_delete() will result in an assert(0).

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@847 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoconfigure.ac: do not compile with -ansi for now
brarcher [Mon, 21 Oct 2013 03:26:29 +0000 (03:26 +0000)]
configure.ac: do not compile with -ansi for now

There is currently a bug on the MinGW/MinGW-w64 platforms:
   sourceforge.net/p/mingw/bugs/2024
where compiling with -ansi will not define the off64_t type,
but including unistd.h will require it to be defined else
a compile error will result.

Attempting to define a replacement in config.h also fails; config.h
will work for check's code, but the code that libtool produces
then fails, meaning unit tests fail to compile.

When the MinGW bug is resolved, we can start compiling with -ansi again.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@846 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoconfigure.ac: also use pthread.h for time struct checks
brarcher [Mon, 21 Oct 2013 03:26:27 +0000 (03:26 +0000)]
configure.ac: also use pthread.h for time struct checks

In MinGW and MinGW-w64, the timespec and itimerspec structs
are defined in pthread.h instead of time.h. To properly
check for this, we now also will include pthread.h if it is
available on the system.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@845 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoconfigure.ac: move pthread check earlier
brarcher [Mon, 21 Oct 2013 03:26:26 +0000 (03:26 +0000)]
configure.ac: move pthread check earlier

The time checks will need to know if pthread exists in
a future commit.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@844 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agocheck_check_exit.c: Include libcompat.h
brarcher [Mon, 21 Oct 2013 03:26:24 +0000 (03:26 +0000)]
check_check_exit.c: Include libcompat.h

for consistency

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@843 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoconfigure.ac: remove left over debug
brarcher [Mon, 21 Oct 2013 03:26:22 +0000 (03:26 +0000)]
configure.ac: remove left over debug

oops, forgot to remove debug before checking in.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@842 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosnprintf: disable 'long long', as is not supported in C90
brarcher [Mon, 14 Oct 2013 23:03:27 +0000 (23:03 +0000)]
snprintf: disable 'long long', as is not supported in C90

-Wlong-long warns that C90 does not support the 'long long' data type.
However, the snprintf replacement provides support for it. As
check does not use long long anywhere, and also does not
use it to print anything, references to the data types are removed
from the snprintf replacement.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@841 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosnprintf: remove missing default case warning
brarcher [Mon, 14 Oct 2013 23:03:25 +0000 (23:03 +0000)]
snprintf: remove missing default case warning

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@840 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosnprintf: removing missing prototype warnings
brarcher [Mon, 14 Oct 2013 23:03:21 +0000 (23:03 +0000)]
snprintf: removing missing prototype warnings

These prototypes are all in libcompat.h, and as there is no need
for this file to include libcompat.h, the missing headers are
put into this file.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@839 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoFix enable_fork check
brarcher [Mon, 14 Oct 2013 23:03:19 +0000 (23:03 +0000)]
Fix enable_fork check

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@838 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdd configure option to force snprintf replacement
brarcher [Mon, 14 Oct 2013 23:03:17 +0000 (23:03 +0000)]
Add configure option to force snprintf replacement

The configure argument --enable-snprintf-replacement will be used
for force the snprintf replacement in libcompat to be compiled,
even on systems that provide a C99 compliant replacement.

This will be useful for vetting the replacement, as a system
without a C99 snprintf may not be readily available.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@837 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoSilence warning about missing exit() prototype
brarcher [Sun, 6 Oct 2013 21:17:39 +0000 (21:17 +0000)]
Silence warning about missing exit() prototype

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@836 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoPrevent setting a timeout with fork unavailable
brarcher [Sun, 6 Oct 2013 21:17:37 +0000 (21:17 +0000)]
Prevent setting a timeout with fork unavailable

If fork() is unavailable, then setting a timeout is meaningless,
as tests are unable to be cut off if they overrun their time.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@835 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDo not compile set env functions without a working setenv
brarcher [Sun, 6 Oct 2013 21:17:35 +0000 (21:17 +0000)]
Do not compile set env functions without a working setenv

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@834 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoSilence warning about no new line at end of file
brarcher [Sun, 6 Oct 2013 21:17:33 +0000 (21:17 +0000)]
Silence warning about no new line at end of file

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@833 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDo not compile unused tests
brarcher [Fri, 4 Oct 2013 01:38:19 +0000 (01:38 +0000)]
Do not compile unused tests

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@832 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosilence warning about wrong type passed to localtime_r
brarcher [Fri, 4 Oct 2013 01:38:17 +0000 (01:38 +0000)]
silence warning about wrong type passed to localtime_r

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@831 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosilence warning about invalid prototype
brarcher [Fri, 4 Oct 2013 01:38:15 +0000 (01:38 +0000)]
silence warning about invalid prototype

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@830 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosilence warnings about unused parameters if fork is unavailable
brarcher [Fri, 4 Oct 2013 01:38:12 +0000 (01:38 +0000)]
silence warnings about unused parameters if fork is unavailable

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@829 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agosilence warning about ck_do_nothing being able to return
brarcher [Fri, 4 Oct 2013 01:38:08 +0000 (01:38 +0000)]
silence warning about ck_do_nothing being able to return

The prototype for ck_do_nothing marks it as noreturn.
gcc thought that the function could still return. Adding
an exit() call at the end (although the assert() will not
let it get that far) to silence the warning.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@828 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years ago* allow silent rules (don't show compiler flags)
cpickett [Thu, 3 Oct 2013 17:13:33 +0000 (17:13 +0000)]
* allow silent rules (don't show compiler flags)

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@827 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoChange %p to %#x for printing pointers
brarcher [Thu, 3 Oct 2013 02:40:17 +0000 (02:40 +0000)]
Change %p to %#x for printing pointers

The MinGW platform prints %p as a 0 extended %d. As %#x is
equivalent to %p, replacing it in hopes that MinGW will print
what is expected.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@826 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDon't declare localtime_r when it's a macro
brarcher [Thu, 3 Oct 2013 02:01:50 +0000 (02:01 +0000)]
Don't declare localtime_r when it's a macro

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@825 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoRemove -Werror from automake
brarcher [Thu, 3 Oct 2013 02:01:48 +0000 (02:01 +0000)]
Remove -Werror from automake

On newer versions of automake, doc/Makefile.am causes a warning:

It appears this file (or files included by it) are triggering
an undocumented, soon-to-be-removed automake hack.
Future automake versions will no longer place in the builddir
(rather than in the srcdir) the generated '.info' files that
appear to be cleaned, by e.g. being listed in CLEANFILES or
DISTCLEANFILES. If you want your '.info' files to be placed in the
builddir rather than in the srcdir, you have to use the
shiny new 'info-in-builddir' automake option.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@824 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUpdate NEWS with MinGW support.
brarcher [Wed, 2 Oct 2013 02:56:09 +0000 (02:56 +0000)]
Update NEWS with MinGW support.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@823 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDefine 'struct timespec' if unavailable in time.h
brarcher [Wed, 2 Oct 2013 02:55:02 +0000 (02:55 +0000)]
Define 'struct timespec' if unavailable in time.h

MinGW does not provide a definition for 'struct timespec' in time.h
Providing a definition in libcompat.h if detected.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@822 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoClarify NEWS about MinGW-w64 support - no fork used
brarcher [Tue, 1 Oct 2013 22:21:11 +0000 (22:21 +0000)]
Clarify NEWS about MinGW-w64 support - no fork used

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@821 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUpdate NEWS with information on Cygwin support for Windows
brarcher [Tue, 1 Oct 2013 22:21:09 +0000 (22:21 +0000)]
Update NEWS with information on Cygwin support for Windows

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@820 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoIf clocks are not defined, set to (hopefully) invalid value
brarcher [Tue, 1 Oct 2013 22:21:08 +0000 (22:21 +0000)]
If clocks are not defined, set to (hopefully) invalid value

Likely, if clock_gettime() is implemented on a system, the first
valid clock will be set to '0'. If not all clock are defined,
by setting our fake definitions to '0', we may accidental use a
valid clock when we did not mean to. Setting the clocks to '-1'
in hopes to avoid this.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@819 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDefine monotonic and realtime clock, even if librt is available
brarcher [Tue, 1 Oct 2013 22:21:06 +0000 (22:21 +0000)]
Define monotonic and realtime clock, even if librt is available

Cygwin has librt and implements clock_gettime(), but does not
define CLOCK_MONOTONIC.

Moving these definitions outside of the check for librt, as they
may be needed even if the system has librt.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@818 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoRemove warnings about combining initialization and declaration
brarcher [Tue, 1 Oct 2013 22:21:04 +0000 (22:21 +0000)]
Remove warnings about combining initialization and declaration

Clang warns that FILE* should be declared before it is assigned,
and to not mix declarations and code.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@817 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoRemove warning about undeclared function ck_strdup_printf
brarcher [Tue, 1 Oct 2013 22:21:02 +0000 (22:21 +0000)]
Remove warning about undeclared function ck_strdup_printf

check_msg.c was not including check_str.h to get the
prototype for ck_strdup_printf. Now fixed.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@816 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoinitialize both elements in timespec
brarcher [Tue, 1 Oct 2013 22:21:00 +0000 (22:21 +0000)]
initialize both elements in timespec

Initializing a timespect to {0} only initializes the first
field. Needed to assign {0,0} to get both fields.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@815 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoif tmpfile() fails, remember the filename and delete it later
brarcher [Sat, 28 Sep 2013 03:10:43 +0000 (03:10 +0000)]
if tmpfile() fails, remember the filename and delete it later

One feature of tmpfile() is to unlink the file, causing it to be
deleted after it is closed. Unlinking an open file fails in Windows.
To prevent the case where the temp directory just fills up with
files, the created file name is remembered, and deleted when
it is closed.

Certainly, if a unit test fails before it deletes the file,
the temp directory will still fill up. However, this is better
than not deleting the files.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@814 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoPrint an error if nothing is read from punpack()
brarcher [Sat, 28 Sep 2013 03:10:42 +0000 (03:10 +0000)]
Print an error if nothing is read from punpack()

There is some issue with MinGW-w64 builds run on wine, if multiple
unit test programs are run concurrently. Sometimes they will fail
to get something from punpack. It may be a failure to read the file,
or the file, or some other issue.

When this happens, later in receive_test_result the rmesg is free'd,
but only by freeing its elements first, which causes a segfault.

Instead of crashing, check should error out gracefully.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@813 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoIf tmpfile() fails, try to make a unique file with tempnam() and getpid()
brarcher [Sat, 28 Sep 2013 03:10:40 +0000 (03:10 +0000)]
If tmpfile() fails, try to make a unique file with tempnam() and getpid()

On systems where tmpfile() does not work, we try to fallback on
using tempnam() and fopen() to get a temporary unique file.

However, tempnam is not enough to get a unique name. Between
getting the name and opening the file, something else also
calling tempnam() could get the same name. It has been observed
on MinGW-w64 builds on Wine that this exact thing happens
if multiple instances of a unit tests are running concurrently.
To prevent two concurrent unit tests from getting the same file,
we append the pid to the file. The pid should be unique on the
system.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@812 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUpdate NEWS with information on MinGW-w64/wine support
brarcher [Sat, 28 Sep 2013 03:10:38 +0000 (03:10 +0000)]
Update NEWS with information on MinGW-w64/wine support

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@811 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_xml_output: removing stray ${3}
brarcher [Sat, 28 Sep 2013 00:34:02 +0000 (00:34 +0000)]
test_xml_output: removing stray ${3}

There is no third argument (or any argument) to this script.
Removing the unneeded ${3}

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@810 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_log_output: Fixed typo in test
brarcher [Sat, 28 Sep 2013 00:34:01 +0000 (00:34 +0000)]
test_log_output: Fixed typo in test

There is no third argument, only the first argument.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@809 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoFix how tests remove \r characters
brarcher [Sat, 28 Sep 2013 00:33:59 +0000 (00:33 +0000)]
Fix how tests remove \r characters

   sed 's/\r//g'
worked for my Linux machine, but OSX expected
   sed 's/\\\\r//g'

Avoid using sed at all, and instead use
   tr -d "\r"
which works on both platforms.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@808 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoFix small text errors in test's help output.
brarcher [Sat, 28 Sep 2013 00:33:57 +0000 (00:33 +0000)]
Fix small text errors in test's help output.

Likely the CR* was true at one point, but was changed to CK_*

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@807 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDo not make decision based on fork status for which ctx to assign
brarcher [Sat, 28 Sep 2013 00:33:55 +0000 (00:33 +0000)]
Do not make decision based on fork status for which ctx to assign

This condition worked when the fork status was CK_FORK. However,
if the fork status was CK_NOFORK, it would fail. The values of
lastctx and failctx would be the same, however the wrong one would
be written if CK_NOFORK was being used.

There does not seem to be any reason why lastctx could not be used
all the time. No decision in messaging seems to be related to
the fork status.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@806 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agocheck_check: do not run tests using setenv if unavailable
brarcher [Sat, 28 Sep 2013 00:33:53 +0000 (00:33 +0000)]
check_check: do not run tests using setenv if unavailable

If the system does not have setenv(), do not use it during
tests. The libcompat version calls assert(), failing the test.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@805 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_check_nofork: removing assumption that HAVE_FORK=0 implied Windows
brarcher [Fri, 27 Sep 2013 01:38:43 +0000 (01:38 +0000)]
test_check_nofork: removing assumption that HAVE_FORK=0 implied Windows

With the configuration option --disable-fork, *nix systems
can also be compiled without using fork. To fix the
line encoding, sed is used to remove \r before the check.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@804 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_output: removing assumption that HAVE_FORK=0 implied Windows
brarcher [Fri, 27 Sep 2013 01:38:41 +0000 (01:38 +0000)]
test_output: removing assumption that HAVE_FORK=0 implied Windows

With the configuration option --disable-fork, *nix systems
can also be compiled without using fork. To fix the
line encoding, sed is used to remove \r before the check.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@803 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_log_output: removing assumption that HAVE_FORK=0 implied Windows
brarcher [Fri, 27 Sep 2013 01:38:39 +0000 (01:38 +0000)]
test_log_output: removing assumption that HAVE_FORK=0 implied Windows

With the configuration option --disable-fork, *nix systems
can also be compiled without using fork. To fix the
line encoding, sed is used to remove \r before the check.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@802 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_xml_output: remove check for -1 in durations
brarcher [Fri, 27 Sep 2013 01:38:37 +0000 (01:38 +0000)]
test_xml_output: remove check for -1 in durations

This test is only valid on platforms that have a functional
clock_gettime() and do not have a good replacement in libcompat.
If there is no good replacement, then all durations will be 0,
even during failures. Instead of forcing the duration to be
negative during a failure artificially, we remove the requirement.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@801 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agotest_xml_output: removing assumption that HAVE_FORK=0 implied Windows
brarcher [Fri, 27 Sep 2013 01:38:35 +0000 (01:38 +0000)]
test_xml_output: removing assumption that HAVE_FORK=0 implied Windows

With the configuration option --disable-fork, *nix systems
can also be compiled without using fork. To fix the
line encodings, sed is used to remove \r before the check.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@800 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoOnly use signals if fork is available
brarcher [Fri, 27 Sep 2013 01:38:33 +0000 (01:38 +0000)]
Only use signals if fork is available

The code at the top of this file for signals and fork is protected by
HAVE_FORK. The signals usage is not very useful without fork, so
now protecting the signal code with HAVE_FORK as well.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@799 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoallow disabling fork, to test for systems without fork
brarcher [Fri, 27 Sep 2013 01:38:31 +0000 (01:38 +0000)]
allow disabling fork, to test for systems without fork

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@798 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agodisable exit tests if fork is unavailable
brarcher [Thu, 26 Sep 2013 02:31:47 +0000 (02:31 +0000)]
disable exit tests if fork is unavailable

all of these tests expect that calling exit() during a test is OK.
Without fork, these tests just result in killing the unit test
program early.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@797 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agodisable checked signal tests if fork is unavailable
brarcher [Thu, 26 Sep 2013 02:31:44 +0000 (02:31 +0000)]
disable checked signal tests if fork is unavailable

As mentioned in a previous commit, checked fixtures are disabled
if fork is unavailable, as they are unable to provide the guarantees
that they advertise without fork.

In addition, some line numbers are updated. This is because some tests
are looking through error messages, and the line number of the
messages is important.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@796 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDisable checked fixtures if fork is unavailable
brarcher [Thu, 26 Sep 2013 02:31:42 +0000 (02:31 +0000)]
Disable checked fixtures if fork is unavailable

checked fixtures allow setup and teardown functions to be run in the
same process space as tests. If a fixture fails, the error is caught
and reported as a failure for the associated test.

If fork is not used, then the guarantee that checked fixtures try to
provide is not possible. Further, using checked fixtures without fork can
cause issues. For example, without fork if a checked teardown
calls ck_assert() which fails, this results in longjmp being called,
which results in the teardowns being called again. An infinate loop
results.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@795 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoChanging the value passed to malloc to be size_t instead of int
brarcher [Thu, 26 Sep 2013 02:31:39 +0000 (02:31 +0000)]
Changing the value passed to malloc to be size_t instead of int

We should not pass a negative number to malloc. Making size
of type size_t to emphasize this.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@794 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoThe number of elements in a list is now unsigned
brarcher [Mon, 23 Sep 2013 17:58:11 +0000 (17:58 +0000)]
The number of elements in a list is now unsigned

there can never be a negative number of elements in a list.
Changing the values to unsigned to enforce this.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@793 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDisable warning from implicit cast of double to time_t or long
brarcher [Mon, 23 Sep 2013 17:58:10 +0000 (17:58 +0000)]
Disable warning from implicit cast of double to time_t or long

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@792 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdd noreturn attribute to select functions and added -Wmissing-noreturn
brarcher [Mon, 23 Sep 2013 17:58:09 +0000 (17:58 +0000)]
Add noreturn attribute to select functions and added -Wmissing-noreturn

Added the gcc attribute noreturn to a few functions that could use it
(but only if the compiler is gcc 2.5 >=),  and added the warning to
point out when a function should use noreturn.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@791 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdding warning flags
brarcher [Mon, 23 Sep 2013 17:58:07 +0000 (17:58 +0000)]
Adding warning flags

These flags do not cause any warnings to be emitted currently.
Adding them now, in case a future change causes a warning.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@790 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdding a missing case in a switch statement
brarcher [Mon, 23 Sep 2013 17:58:06 +0000 (17:58 +0000)]
Adding a missing case in a switch statement

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@789 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoThe mutex cleanup function is now declared as static
brarcher [Mon, 23 Sep 2013 17:58:02 +0000 (17:58 +0000)]
The mutex cleanup function is now declared as static

ppack_cleanup should not be called outside of check_pack.c,
as it is passed as a cleanup callback to pthread. Declaring it
as static.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@788 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDetermine at runtime which clockid_t to use for clock_gettime
brarcher [Mon, 23 Sep 2013 15:17:56 +0000 (15:17 +0000)]
Determine at runtime which clockid_t to use for clock_gettime

The cygwin platform (perhaps others) does not support
CLOCK_MONOTONIC in clock_gettime. However, it does support
CLOCK_REALTIME. Instead of having every call to clock_gettime
check which clock to use, check once and cache the result.

The only two clock options which seemed useful are CLOCK_MONOTONIC
and CLOCK_REALTIME. If others are available in the future
(or another clock type seems a good alternative if these two are
missing on a system) it can be added later.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@787 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUse clockid_t in prototype for clock_gettime
brarcher [Mon, 23 Sep 2013 15:17:54 +0000 (15:17 +0000)]
Use clockid_t in prototype for clock_gettime

The clockid_t type will be needed in a future commit. In preparation,
providing the type now in libcompat.h.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@786 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDo not expect the duration for no-fork mode tests to be negative
brarcher [Mon, 23 Sep 2013 15:17:52 +0000 (15:17 +0000)]
Do not expect the duration for no-fork mode tests to be negative

For tests using fork, if the test fails exit() is called, which results
in the duration not being recorded for the test.

no-fork mode instead requires all tests to return, meaning their
duration is always recorded.

The test_xml_output.sh test expected that all failed tests have a negative
duration, which is not the case for no-fork mode. Removing
this expectation, and instead forcing all durations to be >=0 for
no-fork mode.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@785 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoinitialize timespec's to {0}
brarcher [Mon, 23 Sep 2013 15:17:50 +0000 (15:17 +0000)]
initialize timespec's to {0}

In case the clock_gettime call fails, the timespec values need to be
a sane value.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@784 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agomodify test_xml_output.sh to compare output based on HAVE_FORK
brarcher [Mon, 23 Sep 2013 13:07:03 +0000 (13:07 +0000)]
modify test_xml_output.sh to compare output based on HAVE_FORK

When run in Windows, the output differs slightly from when it is run
under *NIX due to line endings. *NIX uses \n, whereas Windows
uses \r\n. To account for this, printf is used to generate the
Windows expected string.

Additionally, the test_exit test was removed, as it is not valid
if fork is unavailable.

Note that the test does not yet pass for MinGW due to a bug yet to be
identified. The last test failure to compare against currently has
a duration which is not -1.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@783 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agomodify test_log_output.sh to compare output based on HAVE_FORK
brarcher [Mon, 23 Sep 2013 13:07:01 +0000 (13:07 +0000)]
modify test_log_output.sh to compare output based on HAVE_FORK

When run in Windows, the output differs slightly from when it is run
under *NIX due to line endings. *NIX uses \n, whereas Windows
uses \r\n. To account for this, printf is used to generate the
Windows expected string.

Additionally, the test_exit test was removed, as it is not valid
if fork is unavailable.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@782 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agomodify test_check_nofork.sh to compare output based on HAVE_FORK
brarcher [Mon, 23 Sep 2013 13:06:58 +0000 (13:06 +0000)]
modify test_check_nofork.sh to compare output based on HAVE_FORK

When run in Windows, the output differs slightly from when it is run
under *NIX due to line endings. *NIX uses \n, whereas Windows
uses \r\n. To account for this, printf is used to generate the
Windows expected string.

One other change is not using stderr for the test. Wine has an issue
with the tmpfile() call, and will output:
   fixme:msvcrt:MSVCRT__sopen_s : pmode 0x0033 ignored
to stderr when tmpfile() is called. Besides, if the test actually
does segfault in the future (which is the reason for grabbing the stderr),
the result will not be to print out the test results.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@781 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agomodify test_output.sh to compare output based on HAVE_FORK
brarcher [Sun, 22 Sep 2013 23:29:05 +0000 (23:29 +0000)]
modify test_output.sh to compare output based on HAVE_FORK

The output of ex_output changes based on HAVE_FORK, as a test is
skipped when fork is unavailable. However, simply adding another
string mentioning one less test is not enough to get this working
for Windows...

When run in Windows, the output differs slightly from when it is run
under *NIX due to line endings. *NIX uses \n, whereas Windows
uses \r\n. To account for this, printf is used to generate the
Windows expected string.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@780 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoDo not run test_exit if fork is unavailable
brarcher [Sun, 22 Sep 2013 23:29:03 +0000 (23:29 +0000)]
Do not run test_exit if fork is unavailable

if fork is unavailable, the test is not valid, as it makes the
unit test runner exit early.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@779 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoexport HAVE_FORK to testing shell scripts
brarcher [Sun, 22 Sep 2013 23:29:01 +0000 (23:29 +0000)]
export HAVE_FORK to testing shell scripts

The testing scripts will need to know if fork is available or not,
as different tests will run if it is.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@778 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoRemove explicit set of CK_NOFORK when fork is unavailable
brarcher [Sun, 22 Sep 2013 21:27:58 +0000 (21:27 +0000)]
Remove explicit set of CK_NOFORK when fork is unavailable

the default behavior is to now set the fork mode as CK_NOFORK
if fork is unavailable. The code being removed is redundant.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@777 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoAdd test for setting CK_FORK mode
brarcher [Sun, 22 Sep 2013 21:27:55 +0000 (21:27 +0000)]
Add test for setting CK_FORK mode

There was a test for setting CK_NOFORK, but not for CK_FORK.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@776 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoPost an error if a fork mode is set and fork is unavailable
brarcher [Sun, 22 Sep 2013 21:27:53 +0000 (21:27 +0000)]
Post an error if a fork mode is set and fork is unavailable

The default fork mode if fork is unavailable is CK_NOFORK.
Someone trying to set a fork mode without fork available will
only result in failures running tests. Posting an error up
front before tests are run makes more sense.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@775 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoSet default fork mode to CK_NOFORK if fork is unavailable
brarcher [Sun, 22 Sep 2013 21:27:50 +0000 (21:27 +0000)]
Set default fork mode to CK_NOFORK if fork is unavailable

The default fork mode is CK_FORK_GETENV, which checks the
environment, and failing that falls back on using fork.
If fork is unavailable, the default is now to set CK_NOFORK.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@774 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agocheck_check: do setup regardless of availability of fork
brarcher [Sun, 22 Sep 2013 21:27:47 +0000 (21:27 +0000)]
check_check: do setup regardless of availability of fork

The tests originally protected by the HAVE_FORK check will
work if fork is unavailable. Further, setup() does work that
is required by the tests which follow.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@773 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoUpdate NEWS file with information on MinGW-w64 builds
brarcher [Sun, 22 Sep 2013 17:23:03 +0000 (17:23 +0000)]
Update NEWS file with information on MinGW-w64 builds

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@772 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoIf fork unavailable, run tests with CK_NOFORK
brarcher [Sun, 22 Sep 2013 17:23:02 +0000 (17:23 +0000)]
If fork unavailable, run tests with CK_NOFORK

Although the tests which check the correctness of fork-based tests
are disabled if fork is unavailable, the remaining tests were
still run assuming fork was available.

If there is no fork, run tests cases with CK_NOFORK

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@771 64e312b2-a51f-0410-8e61-82d0ca0eb02a

11 years agoskip tests requiring setenv if none is available
brarcher [Sun, 22 Sep 2013 17:23:00 +0000 (17:23 +0000)]
skip tests requiring setenv if none is available

These tests were not protected by the HAVE_WORKING_SETENV variable,
but needed to be.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@770 64e312b2-a51f-0410-8e61-82d0ca0eb02a