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.
brarcher [Wed, 5 Feb 2014 16:08:00 +0000 (16:08 +0000)]
example: Add CHECK_INSTALL_DIR override for FindCheck.cmake
If pkg-config is not installed on the system, then the
FindCheck.cmake script may fail. This is especially likely
on Windows. In this case, we expect that the variable
CHECK_INSTALL_DIR points to the install location of Check.
If this variable is not defined, then the find_path() and
find_library() functions will try to locate Check the
best that it can.
brarcher [Tue, 4 Feb 2014 00:35:56 +0000 (00:35 +0000)]
cmake: install a check.cmake file to help configure projects
If CMake was used to compile and install Check, then a check.cmake
file was generated and installed along with the library. If a project
wants to link against Check in this situation, then the project
will need to include that check.cmake file.
brarcher [Tue, 4 Feb 2014 00:35:43 +0000 (00:35 +0000)]
example: add CMake based example
This example does the same thing, just with CMake instead
of autotools.
Note that it uses a FindCheck.cmake file to locate
libcheck on the system using pkg-config. This file is
originally from the opensync project. Attribution and info
on how to find the original are included.
brarcher [Mon, 27 Jan 2014 04:41:52 +0000 (04:41 +0000)]
source test_output_strings from src tree tests dir
If Check is built out of tree, then the test_output_strings
file was expected to be in the build tree, which is not
where it is; it is in the source tree.
Now find the file in the same directory that the script is in.
Note that this was not run againt the test files for two reasons:
1) some of the tests depend on the failures occuring on specific lines,
and I did not want to go through and fix that for each test.
2) indent does not know what to do with END_TEST, and thinks it is a
type modifier for the function that follows.
brarcher [Mon, 27 Jan 2014 03:18:24 +0000 (03:18 +0000)]
change argument for 'close' from 2 -> 1
The close variable determines if the file will be closed
after logging completes. It is used as a flag, and only really
needs to be '0' or '1'. A value of '2' is just confusing.
brarcher [Sat, 25 Jan 2014 18:18:25 +0000 (18:18 +0000)]
removing pedantic warning
This results in printing warnings about the assert macros and
comma pasting, such as the following:
In file included from check_check_master.c:6:
../src/check.h:301:75: warning: Use of comma pasting extension is non-portable
[-pedantic]
...__LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
^
To remove this warning, the macros would need to be reworked.
brarcher [Sat, 25 Jan 2014 18:18:21 +0000 (18:18 +0000)]
removing -Wmissing-noreturn
This warnings points out that many unit tests could be
declared as 'noreturn'. As all tests could or could not
return (it is up to them), the warning is being dropped.
brarcher [Sat, 25 Jan 2014 18:18:17 +0000 (18:18 +0000)]
simplify path and file name handling and honor const rules
the path and file name variables are not const, but were assigned
const strings. However, both variables could be reassigned
non const data, and the path_name could be allocated data.
To prevent this mix, they are both non-const and initially NULL.
If they are NULL during the print, they are replaced before printing.
Further, the path_name is now always free'd at the end, as it is
either NULL or allocated memory.
brarcher [Sat, 25 Jan 2014 18:18:14 +0000 (18:18 +0000)]
no longer violate the const part of 'const char *' in send functions.
FailMsg and LocMsg contain char* fields which are not const. Assigning
the passed const char* to a FailMsg or LocMsg violates the const.
To avoid this, a copy of the data is made using strdup. Yes, the
extra copy is functionally unnecessary, but to honor the const
it must be done.
The alternative is to make the char* fields in FailMsg and LocMsg
const. This will not work, however, as those fields are sometimes
assigned malloc'ed data in the code and free'd. You cannot pass
a const pointer to free without a warning.
brarcher [Sat, 25 Jan 2014 18:18:12 +0000 (18:18 +0000)]
Removing const identifier from List data structure
The const identifier on the data field of List would imply that
nothing is ever done to modify or destroy the data. However, the
data can be accessed later and modified or freed, as was being done
in places. By removing the const identifiers, the implied safety
of the stored values (which is being violated anyway) is not
advertised in the API.