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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
This test is run 3 times, and each run attempts to change some global
memory. If using fork, each test has the same global memory. However,
without fork subsequent tests observe the changed global memory from
previous tests. Disabling all but the first run if there is no fork(),
and the test is invalid without fork.
Without fork(), the signal tests are invalid. They result in throwing
different signals, no of which would let a no-fork unit test
run finish. The tests are invalid without fork().
Previously the test_mark_lno test would run without fork, it just
would not early exit. This let the unit tests run, but did not
let them pass. Without fork(), the test is invalid.
CCurrently on GNU/Hurd the timer_* functions are not implemented;
check's configure detects that and switches to the replacements
functions in lib/, which use alarm for the timer. However, using
alarm does not allow a timeout precision more than 1 second (as also
written in the comments in lib/timer_settime.c), causing the failure
of the two tests check_check_export and check_check.
As a workaround, it is possible to get a better precision using the
POSIX function setitimer [1] (declared obsolescent, but still usable)
instead of alarm.
This change checks for the existence of setitimer, and in case it
exists uses it (with its ITIMER_REAL timer) in the replacement
timer_settime and timer_delete. Given they are implemented in the
Hurd, all the tests of check passes.
bross had submitted a patch for a few issues compiling for
MinGW. Changes similar to his were put in, though after he
submitted his patch. Giving credit.
If tmpfile fails on a platform, there is no harm in trying the
alternative.
Previously the alternative was only attempted for Windows. However,
checking for WIN32 was not correct; instead _WIN32 should be used.
When the proper check for Windows was attempted, OSX would fail
to run its tests. However, removing the conditional and renaming
_tempnam to tempnam (which is available in MinGW, OSX, and GNU/Linux)
works for all three platforms.
Correctly check for Windows environment
The correct way to check for compiling for Windows is to check for
_WIN32 instead of WIN32.
Patch submitted by username bross on Sourceforge, patch#48
Some scripts that run unit tests assume that the compiled unit test
programs do not have an extension, which is not always true.
Adding in the EXEEXT variable, which lists what the extension, if
any, is.
MinGW does not define "struct sigevent". As check never references
any field inside this, doing a forward declaration does no harm,
and allows MinGW to understand timer_create().
cpickett [Mon, 11 Feb 2013 22:59:48 +0000 (22:59 +0000)]
* flip conditionals around in setup_pipe so that it's readable
* call new open_tmp_file from setup_pipe instead of tmpfile, to
make things work on WIN32, closing Bug 3314868
cpickett [Sat, 9 Feb 2013 00:37:31 +0000 (00:37 +0000)]
* use AC_SUBST in configure.ac to replace @HAVE_STDINT_H@ in
check.h.in, and define intmax_t and uintmax_t ourselves if it's not
there, making check.h work with arbitrary clients again. There is
probably more of a fix needed for clients that just don't have
64-bit ints.
brarcher [Thu, 31 Jan 2013 22:49:40 +0000 (22:49 +0000)]
Add C99 compliant snprintf to libcompat
Many systems do not provide a C99 compliant snprintf implementation.
To guarantee that the snprintf used by parts of check is correct,
a version is added to libcompat. The system's snprintf is checked with
the configure script. If the system's snprintf is not up to snuff,
the libcompat version is used.
This version of snprintf is from Holger Weiß and Patrick Powell.
http://www.jhweiss.de/software/snprintf.html
brarcher [Wed, 21 Nov 2012 04:01:43 +0000 (04:01 +0000)]
Allow unit test timeouts to be specified using nanosecond precision
Previously, test timeouts were limited to second precision. The reason
was the call used to determine test timeouts, alarm, only supported
second precision. With this change, three more functions from librt
are used set a timer to fire with nanosecond precision. For systems
without librt, an implementation of these functions is in libcompat
which fall back on using alarm.
brarcher [Sun, 18 Nov 2012 04:14:06 +0000 (04:14 +0000)]
Updating documentation to remove using fail* API in examples
The fail* API are deprecated, but were the primary API used in the
examples. This commit changes this, by using API that is recommended
for use with new projects. The fail* API are mentioned with the
remaining convenience API, but are introduced as being deprecated.
Additionally, updated what version and on what system the examples
were built against.