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.
brarcher [Mon, 23 Jun 2014 04:13:16 +0000 (04:13 +0000)]
Allow checked fixtures when compiled without fork().
Previously such setup/teardown functions were disabled, as the
full contract for checked fixtures could not be honored. Checked
fixtures in CK_NOFORK mode are now closer to the contract, and are
now enabled.
Besides, it was possible to use checked fixtures if the system
had fork() but the tests were configured to run in CK_NOFORK mode.
brarcher [Mon, 23 Jun 2014 04:13:11 +0000 (04:13 +0000)]
Add DurationMsg to CheckMsg union
As the CheckMsg union is passed around to the various
pack/upack functions, and a DurationMsg is valid to be
passed around, include it in the union just in case
the DurationMsg is or becomes larger than the other
members.
brarcher [Mon, 23 Jun 2014 04:13:03 +0000 (04:13 +0000)]
Fix checked teardown calls going into infinate loop in CK_NOFORK mode
A test can be created with a checked teardown, where the teardown
would call some Check asserts. If the test was run in CK_NOFORK
mode and one of the asserts in the teardown failed, longjmp()
would be called, which would result in the setjmp() being returned
to which monitored the test function, and the checked teardowns
executed again. This lead to an infinate loop.
The fix* for this is to execute the checked teardowns in their
own setjmp() block. A test is added to ensure that CK_NOFORK
with a failed checked teardown does not go into an infinate loop.
In addition, the comments for the checked and unchecked
fixture API are updated to be more clear as to what occurs
for CK_FORK and CK_NOFORK mode.
* This reveals another problem: a failed checked teardown
reacts differently for CK_FORK and CK_NOFORK mode.
CK_FORK: the test is marked as failed
CK_NOFORK: the test is marked as passed
More work will need to be done to allow CK_NOFORK mode to also
cause a test to fail if the checked teardown fails.
brarcher [Mon, 23 Jun 2014 04:12:55 +0000 (04:12 +0000)]
autotools: change check for floor() and __floor()
The reason AIX is having difficulty with floor() is that the
AC_CHECK_LIB([m], [floor])
finds floor() in libm, however due to some header file stuff
(maybe) floor() cannot be used directly. Instead, there is likely
a definition for __floor() -> floor().
To check for this, floor() is detected in libm as normal. After,
determine if floor() can be used directly. If not, check if __floor()
is defined (not necessarily a function). If floor() is usable, do
that. If not but __floor() is available, try using that.
brarcher [Thu, 19 Jun 2014 01:53:32 +0000 (01:53 +0000)]
Use env to find shell to use
On at least one platform (Solaris), the shell located at /bin/sh is
not a compliant shell. Using env as a form of redirection to find
a sh program, the PATH can be changed to find a compliant sh
to use. On platforms where /bin/sh is compliant, env should work
just fine.
brarcher [Mon, 12 May 2014 01:38:24 +0000 (01:38 +0000)]
Use env to find shell to use
On at least one platform (Solaris), the shell located at /bin/sh is
not a compliant shell. Using env as a form of redirection to find
a sh program, the PATH can be changed to find a compliant sh
to use. On platforms where /bin/sh is compliant, env should work
just fine.
brarcher [Wed, 7 May 2014 10:59:33 +0000 (10:59 +0000)]
upon test failure, invoke _exit() instead of exit()
exit() will call atexit handlers, which may try to
clean up things or wait for things to get cleaned up,
which we don't want or need. We just want to stop
and let the parent know about the failure as quickly
as possible in case fork() is used.
Fixes timeouts on assert failures in checks where
an exit handler waits for things to stop, but they
don't stop because they haven't been shut down,
and they haven't been shut down because there's no
simple way to do so on failures.
brarcher [Wed, 19 Feb 2014 02:39:54 +0000 (02:39 +0000)]
include signal.h in exit tests
technically this should have been here before. However, the
autotools build did not need it, so it was not caught.
The CMake build requires it be in place to get the definition
of the SIGSEGV signal.
brarcher [Sun, 16 Feb 2014 04:58:52 +0000 (04:58 +0000)]
Make check.h.in Doxygen friendly
All prototypes and enums are now documented using javadoc.
Doxygen is able to convert this file into a web page displaying
Check's API. This will be used on Check's web page to display
what API is available and when it was introduced.