Compare commits

...
Sign in to create a new pull request.

421 commits

Author SHA1 Message Date
5b0f2b1290 create nanomsg sockets in /var/lib by default 2016-09-27 21:20:37 -04:00
Snaipe
69a05ded6d doc: Fixed wrong usage of parameterized test arrays 2016-09-27 18:52:48 +02:00
Snaipe
4e0ee1a319 theories: Fixed leak in theory context destruction 2016-09-24 21:16:35 +02:00
Snaipe
932b943cd2 cli: Fixed --no-early-exit falling through to --use-ascii 2016-09-24 21:14:49 +02:00
Snaipe
faaae85b80 cram,osx: Fixed mismatch in getopt diagnostic 2016-09-24 20:32:12 +02:00
Snaipe
182a66bc43 ubsan: Fixed shift overflow on signed int 2016-09-24 14:16:14 +02:00
Snaipe
e0ea52e60d cram: Added test for invalid CLI flags 2016-09-24 14:08:15 +02:00
Snaipe
f8107d221e params: Fixed unknown flags implying --crash. Fixes #166 2016-09-24 14:01:48 +02:00
Snaipe
2d6959d777 contrib: Added autotools skeleton 2016-09-24 00:51:49 +02:00
Snaipe
12691f094c travis: Use the default python installation for cram 2016-09-23 17:23:24 +02:00
Snaipe
20d8b5a4fd authors: Added AUTHORS file 2016-09-22 13:03:40 +02:00
Snaipe
20a9da7c18 changelog: Added the parameter change to the custom logger provider API 2016-09-21 13:57:25 +02:00
Snaipe
4093cfa0d6 context: Inherit criterion_options in the test sandbox. Fixes #164. 2016-09-21 13:49:19 +02:00
Snaipe
a9df7911d6 release: Prepare a release candidate for 2.3.0 2016-09-19 00:21:17 +02:00
Snaipe
e864f3dbf2 boxfort,windows: Fixed arena mapping errors. Fixes #149. 2016-09-18 21:45:57 +02:00
Snaipe
e9ef474878 doc: Added note regarding abort in hooks. Addresses partially #163 2016-09-17 12:30:34 +02:00
Snaipe
bf23bb82de boxfort: Fixed hangs on windows 2016-09-16 20:22:46 +02:00
Snaipe
4c15e137bc boxfort: Updated for compilation issues 2016-09-16 19:21:18 +02:00
Snaipe
56c5fea2fc debug: Fixed debugger value passed to boxfort 2016-09-16 17:28:09 +02:00
Snaipe
66556c8cdb debug: Added support for --debug=idle. Fixes #154. 2016-09-16 17:15:47 +02:00
Snaipe
0507dfcf50 licence: Added missing license header on io/output.c 2016-09-14 11:50:15 +02:00
Snaipe
301d143ea4 elf,section: Fixed section code interpreting all empty names as the current executable
This was causing crashes with eglibc which visits the loaded vdso with
an empty dlpi_name.
2016-09-14 01:23:08 +02:00
Snaipe
c48ffae4de mach-o,section: Fixed compilation errors 2016-09-14 00:47:29 +02:00
Snaipe
731991fc18 hooks: Append diffs with tee rather than overwrite them 2016-09-13 23:38:49 +02:00
Snaipe
1c11db55ae section: Added deep section inspection.
This allows loaded dynamic libraries to further provide default hooks,
suites, or even tests.

Fixes #160.
2016-09-13 23:35:57 +02:00
Snaipe
8c840a8fd2 boxfort: Fixed windows builds 2016-09-13 13:21:40 +02:00
Snaipe
6d5fe5a6e1 dyncall: Fixed -fPIC warnings on windows and CXX requirement
Fixes #159.
2016-09-13 12:56:20 +02:00
Kevin Locke
ba2c09e192 section: Close FD in open_module_self on error
If open_module_map encounters an error, open_module_self would return 0
while leaving the file descriptor open.  Since close_module does not
validate the state of the mod_handle, callers can't know whether to call
close_module when this occurs.

Resolve this by closing the file descriptor before returning so that
mod_handle is never partially open.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2016-09-12 21:03:30 -06:00
Kevin Locke
7581417dfa section: Call close_module for open_module_self
Commit a3df2ab abstracted the section handling into several functions.
For ELF, the newly created open_module_self opens a file descriptor to
the executable file which should be closed from close_module.  The
close_module call is missing in report.c and runner.c, causing EMFILE
errors during test runs when the available file descriptors are
exhausted.  This commit fixes the issue.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2016-09-12 20:53:08 -06:00
Snaipe
39c14abdcc boxfort: Updated submodule 2016-09-11 21:09:57 +02:00
Snaipe
696e648efe i18n: Fixed remaining positional arguments in non-localized strings 2016-09-10 13:03:27 +02:00
Snaipe
0d2521b279 travis,stylecheck: Fixed missing fi error 2016-09-10 11:12:10 +02:00
Kevin Locke
07c380d6b7 asserts: Add assertions for wide strings
This commit creates _wcs_ variants of the _str_ assertions for operating
on wchar_t * instead of char *.  The assertions are useful for programs
using wchar_t strings, particularly on Windows where use of the wide
character version of the Windows API is encouraged by Microsoft.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2016-09-10 08:48:30 +02:00
Snaipe
59ed78c4a2 githooks: Fixed precommit hook not producing good patches 2016-09-10 08:47:37 +02:00
Snaipe
ca965d3db9 section,elf: Fixed missing ElfW definition on FreeBSD. Fixes #156 2016-09-10 08:47:24 +02:00
Snaipe
bb61aef765 version,readme: Fixed broken version badge 2016-09-07 10:43:08 +02:00
ailu
1e28ad1277 fix: set criterion_options.debug to CR_DBG_NATIVE
criterion_options.debug was not set if no argument was given. According
to the docs the native debugger should used, so this member has to be
set to CR_DBG_NATIVE
2016-09-06 22:01:03 +02:00
Snaipe
cfd3212a4a sample,asserts: Fixed wrong usage of cr_assert_arr_eq_cmp in C++ 2016-09-06 20:56:42 +02:00
Snaipe
c5bfe03733 section: Resolve /proc/self/exe for compatibility with introspection tools like valgrind 2016-09-06 20:03:36 +02:00
Snaipe
fc2cf1f9d2 version: bumped version to 2.3.0-dev 2016-09-06 19:11:16 +02:00
Snaipe
c99827489a bumpversion: include rc & dev suffixes 2016-09-06 19:08:03 +02:00
Snaipe
d83dbb60cf Revert "cmake: Build libcriterion.so as an executable PIE"
This reverts commit 8959dfa83f.
2016-09-06 18:23:04 +02:00
Snaipe
fcc3d92d5d version: Fixed reported version 2016-09-06 18:23:04 +02:00
ailu
44849f9ea4 doc: fixed debug-transport arguments 2016-09-06 18:11:03 +02:00
Snaipe
50d0a20e5e travis: Fixed spurious fi as reported 2016-09-06 18:08:27 +02:00
Snaipe
02bb993419 po: Updated line counts 2016-09-06 18:03:41 +02:00
Snaipe
8959dfa83f cmake: Build libcriterion.so as an executable PIE 2016-09-06 18:02:38 +02:00
Snaipe
b29e662432 contributing: Added bit on commit messages 2016-09-06 11:02:08 +02:00
Snaipe
d886913438 cram: Fixed line counts 2016-09-06 10:50:28 +02:00
Snaipe
c299b8dd85 style: Fixed (A) Op (B) formatting taking 'Op' as a function rather than an operator 2016-09-06 10:49:10 +02:00
Snaipe
314c15fd9b travis,style: Only run the style check on PRs 2016-09-05 22:47:19 +02:00
Snaipe
64c0e1f501 contributing: Updated to reflect the style check 2016-09-05 22:24:25 +02:00
Snaipe
fff1d0a168 style: Make uncrustify silent 2016-09-05 22:13:23 +02:00
Snaipe
f32a46694a style: Use 'internal' rather than '<internal>' for API macro implementations 2016-09-05 22:09:25 +02:00
Snaipe
48650f965c travis: Added style check 2016-09-05 22:04:34 +02:00
Snaipe
d2a4124b87 style: Added and enforce uncrustify config 2016-09-05 21:32:57 +02:00
Snaipe
ec7cbe2a18 style: disable indent for delicate places 2016-09-05 20:45:46 +02:00
Snaipe
f72ffff3ca style: ignore style for coroutine macros 2016-09-05 15:12:25 +02:00
Snaipe
033bac0c5e style: disable indent for delicate places 2016-09-05 14:36:00 +02:00
Snaipe
bae428393a cmake: Fixed missing include 2016-09-05 13:50:02 +02:00
Snaipe
8d8731053d cram: Updated tests for cr_skip_test() strings 2016-09-05 10:22:03 +02:00
Snaipe
bd4760582f timeout: Fixed --timeout always overriding 2016-09-05 10:20:23 +02:00
ailu
fbbfcb6d61 added gdb and coverage how to
check side note of #127, addition to #114
2016-09-05 10:08:52 +02:00
ailu
91250fed74 Fixed output of skipped tests 2016-09-05 10:04:10 +02:00
Snaipe
205b9a4444 cmake: Cleaned up definitions and default flags a bit 2016-09-04 22:21:20 +02:00
Snaipe
0b191be52a cram: Fixed tests for --timeout 2016-09-04 21:55:19 +02:00
Snaipe
4e1a877c66 cli: Added --timeout flag 2016-09-04 21:06:25 +02:00
Snaipe
e7ab23d67a style: removed extra semicolons 2016-09-04 20:50:58 +02:00
Snaipe
9a68415eb2 cram: Fixed tests to account for time 2016-09-04 12:19:56 +02:00
Snaipe
553869aa5c cmake: Fixed uninstall rule not removing symlinks 2016-09-04 11:35:26 +02:00
Snaipe
bbd5fab174 cmake: Added uninstall rule 2016-09-04 11:27:21 +02:00
Snaipe
da7df99bff cli: Fixed unused variable error 2016-09-04 11:25:41 +02:00
Snaipe
24f0d34eda cli: Fixed leak with dbg parameter parsing 2016-09-04 11:10:40 +02:00
Snaipe
0a0574cb59 cli: Fixed handling of bad arguments 2016-09-04 11:08:39 +02:00
Snaipe
f0cfc6d18d cli: Fixed parsing for --debug-transport 2016-09-04 11:08:10 +02:00
Snaipe
7aa0b1c5ce runtime: Fixed timestamps not being reported. Fixes #116 2016-09-04 10:38:05 +02:00
Snaipe
63d0bc8a4e boxfort: Updated for PID mismatch fix in debug mode 2016-09-04 09:38:14 +02:00
ailu
7143118b5c api: added cr_skip_test()
Added cr_skip_test to skip a test during runtime. Also merged the old
disable system with the new one. All skipped tests are printed by
normal_log_post_suite(), so there is no need for a logger function for
runtime skipepd tests.
Fixes #131.
2016-09-03 23:06:35 +02:00
Snaipe
a3df2ab9a4 section: introspect sections without linker extensions. Fixes #91 2016-09-03 21:55:32 +02:00
Snaipe
8882c7d9cc api,logging: Fixed placement of CR_FORMAT attribute on cr_log 2016-09-03 18:55:09 +02:00
Snaipe
32fea80b7d api: Don't use free directly with cr_asprintf. Fixes #87 2016-09-03 08:33:34 -07:00
Snaipe
9b88f244b6 travis: Added timeout to ctest 2016-09-03 16:52:08 +02:00
Snaipe
0d10c7d6c5 travis: remove Release builds as they are the same as RelWithDebInfo optimization-wise 2016-09-03 16:51:36 +02:00
Snaipe
d6b95f93b6 cram: Fixed MSYS2 expanding patterns as paths 2016-09-03 16:48:46 +02:00
Snaipe
8b62ac51b0 Merge branch 'features/boxfort-sandboxing' into bleeding
Fixes #132, fixes #129, fixes #85
2016-09-03 16:44:12 +02:00
Snaipe
ada75ab25c cram: Updated test diffs 2016-09-03 16:22:42 +02:00
Snaipe
832e9ca8a1 cmake: Removed unused SCRIPTS variable 2016-09-03 16:07:41 +02:00
Snaipe
27c4db8b67 doc: Added --debug, --debug-transport & --filter to command-line flags 2016-09-03 16:07:25 +02:00
Snaipe
a4ad3084a9 options: Deprecate no-early-exit 2016-09-03 16:05:53 +02:00
Snaipe
37da81191a msvc,valgrind: Don't include valgrind.h on any other compiler than __GNUC__ 2016-09-03 15:29:26 +02:00
Snaipe
309e0411c0 appveyor: Use 64-bit mingw-gcc by default 2016-09-03 15:18:25 +02:00
Snaipe
b245fd7bd3 boxfort: Stability update for windows 2016-09-03 15:14:06 +02:00
Snaipe
70f2630ae2 cram: Fixed test diffs 2016-09-03 15:14:06 +02:00
Snaipe
4b14c30027 boxfort: Updated to fix Darwin compile issues 2016-09-03 15:14:06 +02:00
Snaipe
7fb21e5f71 boxfort: Fixed DSO visibility 2016-09-03 15:14:06 +02:00
Snaipe
df5ed94654 help: Added usage for --debug and --debug-transport 2016-09-03 15:14:06 +02:00
Snaipe
4606ceb415 cli: renamed --pattern to --filter 2016-09-03 15:14:06 +02:00
Snaipe
cbb44bb68f boxfort: Updated for better debug mode handling 2016-09-03 15:14:06 +02:00
Snaipe
aa9b2aa915 cli: Added --debug. Fixes #85. 2016-09-03 15:14:06 +02:00
Snaipe
dfdea07325 cmake: Made the visibility be hidden by default 2016-09-03 15:12:28 +02:00
Snaipe
14f7f60ce7 memcheck: Fixed client & runner leaks 2016-09-03 15:12:28 +02:00
Snaipe
a1d690ffdb sample: Changed parameterized test samples to not use strings 2016-09-03 15:12:28 +02:00
Snaipe
e0a38e1ab9 runner: Do not serialize null function pointers 2016-09-03 15:12:28 +02:00
Snaipe
22ea04f778 runner: Fixed test context not being properly serialized 2016-09-03 15:12:28 +02:00
Snaipe
fea6577c87 boxfort: Updated submodule for addaddr fix 2016-09-03 15:12:28 +02:00
Snaipe
4ca8d3dcfb boxfort: Updated dependency for bxf_context_{add,get}fnaddr 2016-09-03 15:12:28 +02:00
Snaipe
af835c763c cmake: make subprojects inherit the processor type 2016-09-03 15:12:28 +02:00
Snaipe
2d80fb97cb boxfort: Updated to latest for windows arena EINVAL fix 2016-09-03 15:12:28 +02:00
Snaipe
c081c31228 cram: Fixed invalid line test for parameterized.cc 2016-09-03 15:12:28 +02:00
Snaipe
571f489cab i18n: removed unused no-early-exit valgrind translations 2016-09-03 15:12:28 +02:00
Snaipe
5388e779d3 boxfort: Updated for eglib bug fix 2016-09-03 15:12:28 +02:00
Snaipe
dc5248d49c boxfort: Initial integration 2016-09-03 15:12:28 +02:00
Snaipe
955e982f37 boxfort: Added boxfort dependency 2016-09-03 15:08:51 +02:00
Snaipe
1d6f0c6822 nanomsg: Remove patch dependency and use upstream project 2016-09-03 15:08:51 +02:00
Snaipe
eb70ea8ae1 appveyor: cleanup configuration 2016-09-03 15:02:33 +02:00
Snaipe
f67128f10e appveyor: Disable Release builds as RelWithDebInfo is equivalent optimization-wise 2016-09-03 14:53:15 +02:00
Snaipe
0690da5ec6 jobs,windows: Temporarily disable multiple jobs as a workaround for #118 2016-09-03 14:48:01 +02:00
Snaipe
3dfc32c486 travis: Use travis_retry for install operations 2016-09-01 12:12:19 +02:00
László Várady
913f0e5d6a doc: fix "Example main" code snippet
Signed-off-by: László Várady <laszlo.varady@balabit.com>
2016-08-31 17:01:20 +02:00
Snaipe
525f2e0ce0 api: Fixed APIs exports. Fixes #145. 2016-08-31 16:56:47 +02:00
Snaipe
805005a5e8 kill: Fixed kill not being available on some builds 2016-08-26 13:54:17 +02:00
Snaipe
595b4601a7 mockfile: Test for features rather than platform 2016-08-26 13:25:05 +02:00
Snaipe
4f5b85d08c compat: Fixed header inclusion for musl compatibility 2016-08-26 09:50:20 +02:00
a1lu
5ff8ef9a5c improve #139: added --crash for cr_expect (#144) 2016-08-23 13:48:53 +02:00
a1lu
25d444b1b9 cli: Added --crash cli option (#126) (#139)
If a assert fails and --crash is given, the debugger will trapped in
this assert using debugbreak.h from the new debugbreak submodule.
2016-08-22 10:17:55 +02:00
Snaipe
15b221ac09 cmake: Add -fvisibility=hidden by default. Fixes #141 2016-08-10 10:50:29 +02:00
Snaipe
2fe3349e4a cmake: Fixed the SONAME not matching the real SO version 2016-08-10 10:39:13 +02:00
László Várady
0c715b46c6 pkgconfig: fix the installation path of criterion.pc (#140)
If ${CMAKE_INSTALL_PREFIX} is mentioned explicitly in the install() command,
the generated cmake_install.cmake file will contain a hard-coded value.

This can cause installation errors during debian package generation, since
the 'cmake -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr -P cmake_install.cmake'
command is used in debian/rules (this command overrides CMAKE_INSTALL_PREFIX).

Signed-off-by: László Várady <laszlo.varady@balabit.com>
2016-08-09 17:31:19 +02:00
Snaipe
9fbd28bf69 core: .exit_code = 0 now enforces the test exit status to be 0.
Before this change, an exit_code of 0 would allow a test to pass for any
exit status, because checking for 0 meant that the value was optional
and people did not care.

However, the semantics of exit() tells that 0 shall be synonymous of
success, and allowing a nonzero status to pass the test is unexpected.

This fixes issue #137.
2016-07-28 18:11:45 +02:00
Snaipe
1f6d05adca readme: Added link to the mailing list 2016-07-28 17:34:08 +02:00
Snaipe
da60498f38 i18n: removed unnecessary N_ on non-nls string 2016-07-24 17:12:21 +02:00
Snaipe
856a5f80c0 core: Fixed segfaults with reset_proc_compat in single mode 2016-07-24 15:00:18 +02:00
Snaipe
1e32935ff6 travis: Parallelized tests 2016-07-24 14:56:09 +02:00
Snaipe
f86714cbb1 protocol: Added missing criterion.options 2016-07-24 13:55:36 +02:00
Snaipe
f0fe1f8bac travis: Removed llvm & clang installation through brew 2016-07-24 00:56:33 +02:00
Snaipe
fcb6d58f93 travis: Fixed pip misbehaving with --user on OS X builds and upgraded cram to 0.7 2016-07-24 00:16:05 +02:00
Snaipe
df4b32de9e po: Updated line numbers 2016-07-24 00:02:56 +02:00
Snaipe
bd42dab406 cmake: Removed pcre dependency from debian package 2016-07-24 00:02:38 +02:00
Snaipe
9ea35ee4d4 travis: Removed pcre installation on OS X builds 2016-07-23 23:57:05 +02:00
a1lu
4d6d741357 extended glob matcher with brzozowski derivative (#111) 2016-07-23 22:32:57 +02:00
Franklin Mathieu
0c9c76599d Merge pull request #130 from kevinoid/freebsd-support
Compilation and test fixes for FreeBSD
2016-07-01 22:02:42 +02:00
Kevin Locke
98b63bd041 Allow nullptr or __null in asserts.t
Libc in FreeBSD 10.3 defines NULL to nullptr rather than __null.  Allow
this in the test output.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2016-06-28 17:33:00 -07:00
Kevin Locke
b49517c376 Link against libanl only for getaddrinfo_a
Since libanl is only used by nanomsg when it provides getaddrinfo_a, and
is not necessary otherwise (and not available without glibc), use the
same logic for libcriterion.

This fixes the following build failure on FreeBSD 10.3:

    Linking C shared library libcriterion.so
    /usr/bin/ld: cannot find -lanl

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2016-06-28 15:50:06 -07:00
Snaipe
e3de11a274 readme: Fixed travis badge not displaying 2016-06-28 16:49:18 +02:00
Snaipe
ff431f8860 Merge branch 'patch' into bleeding 2016-06-20 09:53:04 +02:00
Snaipe
81f2b1855a release: Prepare release 2.2.2 2016-06-20 09:36:25 +02:00
Snaipe
6cbe26c2a2 pthread: Fixed child pump not being joined right after a fork.
Fixes #125.
2016-06-20 09:26:13 +02:00
Snaipe
69f7e20c35 Fixed deadlocks when the tests are terminated too fast 2016-06-20 09:26:13 +02:00
Snaipe
0d53444087 [Issue #113] Fixed memory leak in disabled tests 2016-06-20 09:22:14 +02:00
Franklin Mathieu
be89fde240 Merge pull request #124 from kaidowei/bleeding
Behavior of cr_assert_str* assertions changed:

- Default assertion messages will now print the expession and the content of both strings.
- String assertions will not crash, if the actual string is NULL.
2016-06-12 20:07:39 +02:00
commit
f201d85e3c Behavior of cr_assert_str* assertions changed:
- Default assertion messages will now print the expession and the content of both strings.
- String assertions will not crash, if the actual string is NULL.
  (cr_assert_not_null(actual) is called before the cr_assert_str* assertion)
2016-06-07 16:56:17 +02:00
Snaipe
96bf7869de travis: Added whole source archive deployment on github releases (fixes #123) 2016-05-22 14:18:09 +02:00
Franklin Mathieu
7d17ac0bd3 Merge pull request #122 from MrAnno/fix-find-criterion
Fix FindCriterion.cmake package name
2016-05-15 12:57:07 +02:00
László Várady
1a65956b66 dev: Fix FindCriterion.cmake package name 2016-05-15 12:40:40 +02:00
Snaipe
4c1a399dab travis: Added coverity configuration 2016-05-06 20:10:01 +02:00
Snaipe
0c389023ec cram: Remove cmake dependency on target criterion_samples 2016-05-05 16:28:36 +02:00
Snaipe
cd57b9f6f4 appveyor: Don't install unnecessary packages 2016-05-05 16:21:39 +02:00
Snaipe
cb3486eb7b core: Fixed #121 Single mode crashes 2016-05-05 15:44:35 +02:00
Franklin Mathieu
341b221458 Merge pull request #119 from am11/fix/gh-118
Remove `restrict` keyword usages
2016-04-28 00:44:17 +02:00
Adeel
fc066a710d Remove restrict keyword usages
This turned out to be a bug in the recent C99 support:
https://connect.microsoft.com/VisualStudio/Feedback/Details/1161593
(ticket probably needs some votes to draw their attention)

Since this is little to no value there for `restrict` anyway, it has
been removed.

Contributes to #118.
2016-04-24 12:36:20 +03:00
Snaipe
9fe47197b9 cmake: Forcefully pass CFLAGS to nanomsg 2016-04-23 14:34:09 +02:00
Snaipe
e0a058c95e nanomsg: Updated winnt version and set fork sources to be unix-only 2016-04-23 14:21:24 +02:00
Snaipe
fb684a140a cmake: Pass -fPIC to nanomsg cflags 2016-04-23 14:12:16 +02:00
Snaipe
83ad6bca21 nanomsg: Updated fork patch to latest 2016-04-23 14:04:06 +02:00
Snaipe
d699665274 windows: Fixed hangs 2016-04-23 12:09:14 +02:00
Snaipe
5f32927b63 travis: Added --output-on-failure to ctest 2016-04-22 00:16:53 +02:00
Snaipe
887d04363c appveyor: Added timeout & helpful diagnostics 2016-04-19 22:51:50 +02:00
Snaipe
676a31baac test: Fixed cram tests not working without PYTHON_BIN defined 2016-04-19 22:29:49 +02:00
Franklin Mathieu
605fd3efd5 Merge pull request #117 from kaidowei/bleeding
XML: The output parameter --xml now generates xml-files with the elapsed time.
2016-04-19 19:45:19 +02:00
commit
f5340f8f27 XML: The output parameter --xml now generates xml-files with the elapsed time. 2016-04-19 19:16:15 +02:00
Franklin Mathieu
1f7ca2f32b Merge pull request #101 from kaidowei/bleeding
cli: Strip red ANSI color from the failing & crashing summary if there were no errored tests.
2016-04-13 15:37:40 +02:00
Snaipe
cd814f9899 protocol: Fixed rc check being removed on Release builds 2016-04-13 15:22:01 +02:00
Snaipe
4842cf0d9e protocol: Connect to a PID-bound named socket 2016-04-13 15:03:23 +02:00
Snaipe
0e1eec940a appveyor: Install cram 0.6 2016-04-13 12:20:30 +02:00
Snaipe
38653a6414 Merge branch 'master' into bleeding
This merges the changes brought by 2.2.1 into bleeding.
2016-04-13 11:57:37 +02:00
Snaipe
6b4fff1a30 readme: Fixed download links 2016-04-13 11:19:38 +02:00
Snaipe
9a035fab70 Merge branch 'features/sphinx-doxygen' into bleeding 2016-04-10 17:17:23 +02:00
Snaipe
7092a1c5aa doc: Fixed parameterized test dumping criterion namespace 2016-04-10 17:15:30 +02:00
Snaipe
952687c4c9 doc: Integrated doxygen docs for parameterized tests in sphinx 2016-04-10 16:27:35 +02:00
Snaipe
70d693766c doc: Integrated doxygen on invariants to sphinx page on theories 2016-04-10 16:27:30 +02:00
Snaipe
e24d2f3c79 doc: Ignore deprecated assertions 2016-04-10 15:17:06 +02:00
Snaipe
733153cca0 Set REPEAT_BRIEF to NO 2016-04-10 15:17:06 +02:00
Snaipe
91c85cb2bc Integrated theories doxygen into sphinx docs 2016-04-10 15:17:06 +02:00
Snaipe
411bdb73df Moved actual implementation of Test & TestSuite in internal/test.h 2016-04-10 15:12:32 +02:00
Snaipe
8bcc21e55c Moved CR_STDN definition to commons 2016-04-10 15:12:32 +02:00
Snaipe
d95bfa2de8 Fixed macro redefinition errors for redirect.h 2016-04-10 15:12:32 +02:00
Snaipe
d2ecb5c0ac Added collapsible definition lists for sphinx docs 2016-04-10 15:12:32 +02:00
Snaipe
1d216ac929 Added more details to test option fields & integrated doxygen docs for Test and TestSuite 2016-04-10 15:12:32 +02:00
Snaipe
cbe733b7f9 Fixed doxygen warnings on unknown <type> xml tag 2016-04-10 15:12:32 +02:00
Snaipe
c270c02940 Fixed asserts doxygen & integrated them into the assertion reference 2016-04-10 15:12:32 +02:00
Snaipe
7bd7053aa5 Integrated doxygen into sphinx docs 2016-04-10 15:12:32 +02:00
Franklin Mathieu
f285c3bc58 Merge pull request #114 from blinskey/gcov-faq
doc: Add coverage info to FAQ
2016-04-04 05:18:39 +02:00
Ben Linskey
e9f8d46c1b Add coverage info to FAQ in docs
Adds a question and answer explaining how to generate Gcov test coverage
data. Answer text is copied from https://github.com/Snaipe/Criterion/pull/84#issuecomment-161551069
2016-04-03 19:28:40 -04:00
Snaipe
95d7ed4356 [v2.2.1] Merge branch 'patch' (Patch release)
* Fix: fixed criterion not being embeddable with CMake's `add_directory`
* Fix: fixed resource leaks in the child pump thread
* Fix: fixed redirected standard streams being leaked by cr_(assert|expect)_std(out|err)
* Fix: fixed out of bounds during assert message sending
* Fix: fixed naming convention conflicts for internal variables used by the implementation of cr_assert
* Fix: fixed empty format string warning with GCC 4.8
* Fix: fixed file-to-file comparison assert message being corrupted
2016-03-06 13:45:29 +01:00
Snaipe
22c9c3ec1c Merge branch 'fix-project-src-bin-dir' of https://github.com/MrAnno/Criterion into patch 2016-03-05 16:14:14 +01:00
Snaipe
00d3ef7ad8 Fixed resource leaks the child pump thread 2016-03-05 15:53:50 +01:00
Snaipe
c5b4ca27d7 Fixed redirected standard streams being leaked by cr_(assert|expect)_std(out|err) 2016-03-05 15:51:50 +01:00
László Várady
b4f5197288 Switched CMAKE_*_DIR variables to PROJECT_*_DIR
With this change, Criterion can be added as a cmake subproject
with the add_subdirectory() command.
2016-03-05 13:34:26 +01:00
Franklin Mathieu
2e84d3d443 Merge pull request #108 from a1lu/features/doxygen-api
added doxygen for cr_assume_* macros
2016-02-23 19:11:27 +01:00
ailu
faa44899a6 added doxygen for cr_assume_* macros 2016-02-23 18:25:46 +01:00
Snaipe
de5ec40466 Fixed out of bounds during assert message sending 2016-02-22 16:56:00 +01:00
Franklin Mathieu
1ef7c0f25a Merge pull request #106 from a1lu/doc/api-docs
Add doxygen documentation in API headers (Fixes #80)
2016-02-20 14:46:30 +01:00
ailu
4bea3d5ce2 Add doxygen documentation in API headers 2016-02-20 13:09:20 +01:00
Snaipe
0f76430d74 Removed libcsptr tests from builds 2016-02-19 21:10:15 +01:00
Snaipe
c5d9172c3d Fixed cross-compiling of cmake subprojects 2016-02-19 21:10:15 +01:00
Franklin Mathieu
c5148d74a2 Merge pull request #104 from a1lu/bleeding
Added missing licenses on stdio_filebuf.hxx and stream.hxx
2016-02-18 12:26:08 +01:00
ailu
70a5b88763 added licenses 2016-02-18 07:31:57 +01:00
Snaipe
e53f3892d5 Merge branch 'features/new-logging' into bleeding 2016-02-18 00:25:45 +01:00
Snaipe
4b093d2a3e Added documentation on logging functions 2016-02-18 00:05:15 +01:00
Snaipe
99b10d443c Added message splitting on line feed 2016-02-18 00:05:15 +01:00
Snaipe
9bc0da9e83 Added C++ stream interface for logging 2016-02-18 00:05:15 +01:00
Snaipe
4241b4e517 Added cram test for log.c 2016-02-18 00:05:15 +01:00
Snaipe
9e0a746a2e Fixed typo in deprecation macro 2016-02-18 00:05:15 +01:00
Snaipe
8ab938d06d Added deprecation for old criterion logging macros 2016-02-18 00:05:15 +01:00
Snaipe
b8bfa34c22 Added simple message logging from a test worker 2016-02-18 00:05:14 +01:00
Snaipe
41bfaa189d Fixed pot files being updated when only the timestamp changed 2016-02-17 18:00:57 +01:00
Snaipe
ec5c8958cb Fixed naming convention conflicts for internal variables used by the implementation of cr_assert 2016-02-16 17:47:02 +01:00
Snaipe
1f674d3ffb Fixed empty format string warning with GCC 4.8 2016-02-16 17:35:14 +01:00
Snaipe
1d944471d3 Removed google analytics beacon from README 2016-02-14 23:12:19 +01:00
Snaipe
28007ab67e Added missing array include for asserts.cc 2016-02-13 15:09:31 +01:00
Snaipe
24f90ea817 Fixed array comparison assert samples 2016-02-13 13:20:10 +01:00
Snaipe
d5518956cb Updated po file line numbers 2016-02-13 13:05:41 +01:00
Snaipe
9f11303552 Merge remote-tracking branch 'ailu1/translation/german' into bleeding 2016-02-13 12:55:46 +01:00
ailu
dabee4470f added german translation 2016-02-13 11:15:06 +01:00
commit
f442488f19 Visibility change:
The numbers next to Failing and Crashing in the text synthesis will not be printed red, if they are zero.
2016-02-11 14:31:35 +01:00
Snaipe
8c1c9c05ee Fixed file-to-file comparison assert message being corrupted 2016-02-10 23:27:51 +01:00
Snaipe
f0541e86fa Reformatted chat rooms into a table in README & changed logo accreditation [ci skip] 2016-02-07 03:43:55 +01:00
Snaipe
d539c12b5d Fixed Error NTSTATUS-es not being reported as crashes 2016-02-07 02:50:07 +01:00
Snaipe
4636358398 Manually added cram shell path for appveyor builds 2016-02-06 23:06:53 +01:00
Snaipe
7a847952b6 Fixed Cram module environment expansion and python binary for cram tests on appveyor 2016-02-06 22:41:08 +01:00
Snaipe
80bd1fe829 Fixed linkage issues with nanomsg 2016-02-06 22:15:44 +01:00
Snaipe
ba195d3c9f Updated nanomsg patch for Windows API setting 2016-02-06 19:30:55 +01:00
Snaipe
91b2fdb180 Updated nanomsg patch for fixed WIN32 checks for fork strategies 2016-02-06 19:01:39 +01:00
Snaipe
a1d9ff5a00 Updated nanomsg patch for correct cmake behaviour 2016-02-06 18:47:28 +01:00
Snaipe
e949ec107b Downgraded minimum cmake version of patched nanomsg to 2.8.7 2016-02-06 18:08:24 +01:00
Snaipe
5e2d8fe57b Removed unused include 2016-02-06 17:38:35 +01:00
Snaipe
1980319d0d Switched nanomsg patch to cmake build system 2016-02-06 17:37:11 +01:00
Snaipe
570c232622 Fixed version badge timing out [ci skip] 2016-02-06 15:17:39 +01:00
Snaipe
73d8ecd61e Fixed '0: bad file descriptor' at configure time for nanomsg on appveyor builds 2016-02-06 14:39:55 +01:00
Snaipe
d028534312 Compile nanomsg with autotools if using MinGW 2016-02-06 04:25:41 +01:00
Snaipe
744eb31101 Added proper platform checks for strtok_r 2016-02-06 04:02:17 +01:00
Snaipe
0d3d986c7b Fixed MinGW-w64 pointer size conversion warnings 2016-02-06 03:20:10 +01:00
Snaipe
2c0db0853c Fixed wrong cmake installation on appveyor builds 2016-02-06 03:05:04 +01:00
Snaipe
f64b2aba2a Changed appveyor config to use MSYS2 + MinGW-w64 instead of MinGW/MSYS 2016-02-06 02:37:10 +01:00
Snaipe
f4cccfec3f Fixed windows runner exiting before the death of all wait threads 2016-02-06 01:13:57 +01:00
Snaipe
1d2a5c2376 Bump Windows API requirement to Vista and later 2016-02-06 01:12:35 +01:00
Snaipe
223af17ddc Updated nanomsg patch to latest 2016-01-30 18:40:29 +01:00
Snaipe
04042ab71a Revert "Switched from nanomsg to zeromq temporarily until the fork patch works"
This reverts commit 4af745bf88.
2016-01-28 23:43:23 +01:00
Franklin Mathieu
98fbab0afd Merge pull request #100 from MrAnno/fix-docs-assert_arr-params
Fixed doc/assert: missing size parameter
2016-01-28 13:07:41 +01:00
László Várady
9285ea6e96 Fixed doc/assert: missing size parameter
Size parameter was missing from cr_assert_arr_eq and cr_assert_arr_neq.
2016-01-28 12:59:00 +01:00
Snaipe
4af745bf88 Switched from nanomsg to zeromq temporarily until the fork patch works 2016-01-27 21:08:33 +01:00
Snaipe
5b4f724ccf Fixed external suite stats memory leak 2016-01-26 20:55:00 +01:00
Snaipe
2b1b823db0 Fixed use after frees & deadlocks in the child pump 2016-01-23 12:26:30 +01:00
Snaipe
83e96cbded Removed OS X from the allowed travis build failures 2016-01-23 10:56:37 +01:00
Snaipe
c507434dca Actually fix the pattern tests this time 2016-01-23 10:54:57 +01:00
Snaipe
f1bd35f81b Fixed pattern tests not running when PCRE is present 2016-01-23 03:04:50 +01:00
Snaipe
8da1f2fb45 Updated nanomsg patch for possible OS X pause/resume fix 2016-01-23 02:50:54 +01:00
Snaipe
2c690c9340 Updated nanomsg patch to fix assertion errors 2016-01-22 15:15:10 +01:00
Snaipe
fdbc337314 Updated nanomsg patch to support extensive cleanups 2016-01-21 22:52:14 +01:00
Snaipe
07f76af017 Added a pkg-config file for criterion 2016-01-20 22:35:31 +01:00
Snaipe
a3ee1b1b99 [runtime] Display an error message when a pattern has been set without extglob support 2016-01-20 16:04:18 +01:00
Snaipe
a670f7c361 [cram] Made the usage tests ignore absolute paths and --pattern options 2016-01-20 16:04:18 +01:00
Snaipe
444e393226 [samples] Unbuffered standard streams on report sample for test consistency 2016-01-20 16:04:17 +01:00
Snaipe
cc9465e133 [samples] Fixed sample with a cross platform segfault function 2016-01-20 15:03:00 +01:00
Snaipe
bbfe9aa08e [appveyor] Fixed builds not being maked as failed when tests are not passing 2016-01-20 14:03:02 +01:00
Snaipe
79648c7136 [travis] Fixed cram tests not running 2016-01-20 13:09:17 +01:00
Snaipe
033bcacf7f [cram] Skip pattern tests on windows 2016-01-20 12:51:06 +01:00
Snaipe
5413075812 [windows] Fixed output not being flushed on fail-fast mode 2016-01-20 12:36:14 +01:00
Snaipe
7f7029cb03 [cmake] Read python name from PYTHON_BIN in cram module 2016-01-20 12:25:34 +01:00
Snaipe
cf63230bf6 [cmake] Try to use python3 when available when calling cram 2016-01-20 12:08:39 +01:00
Snaipe
375a21a569 [cmake] Trying to fix the flipping buggy cram on windows 2016-01-20 12:03:44 +01:00
Snaipe
7740b9dfca [appveyor] Added python version display after install 2016-01-20 11:31:43 +01:00
Snaipe
8b11c2d179 [cmake] Prevented function inlining for C++ samples on mingw (see mingw bug <http://sourceforge.net/p/mingw/bugs/2250/>) 2016-01-19 23:55:01 +01:00
Snaipe
56364bd811 [appveyor] Updated python to python 3.5.x 2016-01-19 22:44:25 +01:00
Snaipe
eef231a2ee [appveyor] Fixed unicode issues on cram tests on windows 2016-01-19 22:33:35 +01:00
Snaipe
6dc256075f [cmake] Set cram shell to use sh on mingw builds 2016-01-19 22:01:13 +01:00
Snaipe
71e3f1a4b3 [cmake] Called cram through python and not a shell script 2016-01-19 03:01:50 +01:00
Snaipe
8802a983b2 [appveyor] Added python & cram installation 2016-01-19 02:57:09 +01:00
Snaipe
e8ec14e276 [cmake] Fixed cram module not failing when the cram tests fail 2016-01-19 00:30:31 +01:00
Snaipe
60de40708d [cmake] Fixed path passed to cram on windows builds 2016-01-19 00:15:23 +01:00
Snaipe
1b5af3bc4c [cmake] Fixed wrong library path for MinGW/MSYS Makefiles generator 2016-01-18 22:05:56 +01:00
Snaipe
4530d10af7 [cmake] Added generator propagation to subprojects 2016-01-18 21:55:22 +01:00
Snaipe
cea364a881 [appveyor] Trying to fix autotools on mingw 2016-01-18 20:58:07 +01:00
Snaipe
0083897079 [travis] Made OS X builds failures temporarily allowed 2016-01-18 17:05:28 +01:00
Snaipe
9fac0f40d4 [appveyor] Installed libtool for mingw builds 2016-01-18 16:12:07 +01:00
Snaipe
b4591cd0e1 [license] Updated license year on missed files 2016-01-18 16:06:54 +01:00
Snaipe
0a48cb9062 [appveyor] Installed automake and autoconfs on mingw builds 2016-01-18 15:58:51 +01:00
Snaipe
dc62c45c08 [Issue #96] Refactored the build system configuration 2016-01-18 14:16:13 +01:00
Snaipe
70c0593e23 Fixed abort messages not showing anymore 2016-01-18 01:41:51 +01:00
Snaipe
e638cf3d43 Merge branch 'features/io-rewrite-nanopb' into bleeding 2016-01-18 01:35:55 +01:00
Snaipe
0019864314 Added external install path to windows PATH in appveyor builds 2016-01-17 21:57:47 +01:00
Snaipe
45c9215c32 Deparallelized tests on appveyor 2016-01-17 21:03:00 +01:00
Snaipe
497b584a59 Fixed crashes on windows due to null pipe dereferencing 2016-01-17 20:44:13 +01:00
Snaipe
fbc29e40ea Fixed nanomsg not being picked up as cmake dependency 2016-01-17 20:35:40 +01:00
Snaipe
3e725aecdb Expanded add_cmake_subproject 2016-01-17 19:26:03 +01:00
Snaipe
9421d5bc86 Fixed nanomsg config for windows builds 2016-01-17 17:34:46 +01:00
Snaipe
9562260201 Fixed external project build for nanomsg 2016-01-17 15:43:54 +01:00
Snaipe
d405e640ed Disabled nanomsg tests & tools 2016-01-17 15:03:49 +01:00
Snaipe
215e8dc8fd Fixed nanomsg static library not being picked up by win32 builds 2016-01-17 14:27:47 +01:00
Snaipe
5591942df9 Removed unused includes in protocol.c 2016-01-17 12:01:01 +01:00
Snaipe
813a526c8f [Issue #98] Removed undefined behaviour from signal samples 2016-01-17 11:50:10 +01:00
Snaipe
0590c0eb61 Removed -DLANG_OBJ from specified cmake options in travis builds 2016-01-17 11:50:10 +01:00
Snaipe
34675fe4f3 Redefine null for failure messages regression test 2016-01-17 11:50:10 +01:00
Snaipe
bdcf62d0eb Removed debug logging on cram patch 2016-01-17 11:50:10 +01:00
Snaipe
347a114b29 Added nanomsg header copy to cmake builds for MSVC 2016-01-17 11:27:07 +01:00
Snaipe
8169b70049 Merged verbosity & prefix fields into one severity field in the log message type 2016-01-17 02:07:40 +01:00
Snaipe
33757e01db Added pcre installation on OS X builds 2016-01-16 21:29:19 +01:00
Snaipe
55187c7f59 Patched buggy cram on OS X 2016-01-16 21:20:02 +01:00
Snaipe
05bf62890f Fixed various compile errors with the compatibility kill code 2016-01-16 21:20:02 +01:00
Snaipe
2b963e8eff Changed cram installation on travis builds for python 3 2016-01-16 21:20:02 +01:00
Snaipe
02194aa132 Fixed cram target not being run on cmake 2.8.x 2016-01-16 15:34:32 +01:00
Snaipe
7faaa7656f [Issue #95] Fixed fail fast and added proper SIGTERM handling 2016-01-16 14:47:46 +01:00
Snaipe
dbfffabf84 Merge branch 'features/cram-tests' into bleeding 2016-01-16 13:31:23 +01:00
Snaipe
bfc29532cd Moved cram tests into their own subdirectory 2016-01-16 13:28:11 +01:00
Snaipe
8d286b4334 Added the rest of the cram tests and removed old system test suite 2016-01-16 13:24:35 +01:00
Snaipe
714f176b65 Added test name in birth messages and made the subtest name optional in phase messages 2016-01-15 17:37:44 +01:00
Snaipe
a6aefb69aa Fixed potential overflow and fixed the state stack to be at least 32 bits 2016-01-15 14:24:02 +01:00
Snaipe
e4ee92c8d7 Fixed multiple typedefs error 2016-01-15 14:24:02 +01:00
Snaipe
77e33940f8 Fixed cross platform compatibility setup 2016-01-15 14:24:02 +01:00
Snaipe
cd09997f3c Deparallelized tests 2016-01-15 14:24:02 +01:00
Snaipe
4d17b35a75 Fixed old gcc warnings 2016-01-15 14:24:02 +01:00
Snaipe
feb9611eed Added proper nanomsg-patched submodule 2016-01-15 14:24:02 +01:00
Snaipe
7c01e372c2 Temporarily used patched nanomsg for tests 2016-01-15 12:13:05 +01:00
Snaipe
44adfb4be5 Fixed description not being printed with dashes 2016-01-14 15:46:19 +01:00
Snaipe
14d8019dce Added cram tests for theories, redirections, report hooks, and patterns 2016-01-14 15:36:06 +01:00
Snaipe
44bf59aeab Fixed Tests logs not showing on failure 2016-01-14 12:40:22 +01:00
Snaipe
23aab98c90 Install cram in home directory and only if tests are active 2016-01-14 12:40:01 +01:00
Snaipe
6fff06a2ee Made cram tests run on travis 2016-01-14 12:25:46 +01:00
Snaipe
1a3cb4e2b1 Added more cram tests 2016-01-14 11:12:24 +01:00
Snaipe
1b8cad2162 Added basic cram tests 2016-01-14 00:38:37 +01:00
Snaipe
48346747b9 Removed unused protocol functions 2016-01-13 20:17:22 +01:00
Snaipe
2e75ad6268 Fixed MinGW builds receiving -lpthread wrongly 2016-01-12 22:28:45 +01:00
Snaipe
bec554e6d6 Removed tinycthreads artifacts 2016-01-12 21:44:58 +01:00
Snaipe
43f3e99b36 [Issue #94] Fixed compiler errors on OpenBSD 2016-01-12 19:48:48 +01:00
Snaipe
fc5a943327 Added missing pthreads link dependency 2016-01-12 19:37:00 +01:00
Snaipe
c4f5e6baed Implemented simple server mode 2016-01-12 00:17:03 +01:00
Snaipe
1339185973 Send the new death message on windows child reaper 2016-01-11 15:39:27 +01:00
Snaipe
f4e444a8d3 Integrated new protocol into the core 2016-01-11 12:21:58 +01:00
Snaipe
131a6a646b Revamped the protocol for test nesting and phase grouping 2016-01-11 12:20:38 +01:00
Snaipe
2461574214 We're in 2016. 2016-01-06 17:35:35 +01:00
Franklin Mathieu
4321068c30 Merge pull request #93 from hppritcha/topic/add_soname
cmake: add a SOVERSION to libcriterion.so
2015-12-29 23:32:49 +01:00
Howard Pritchard
766e61ad67 cmake: add a SOVERSION to libcriterion.so
Shared libraries should have an SONAME
to facilitate proper dynamic linking.

Signed-off-by: Howard Pritchard <howardp@lanl.gov>
2015-12-29 13:07:37 -08:00
Snaipe
6936ca44de Removed the generic event sending function from the API 2015-12-13 18:52:56 +01:00
Snaipe
f8965214e3 Added missing license header 2015-12-13 18:13:27 +01:00
Snaipe
e7b0d5e0c4 Added message read/write utilities 2015-12-13 18:13:16 +01:00
Snaipe
752123f496 Added new sources to cmake build 2015-12-13 18:11:39 +01:00
Snaipe
43f7d837f0 Started to integrate the new message pump into the runner 2015-12-13 17:18:06 +01:00
Snaipe
2411660cba Fixed typos in extmatch size heuristic 2015-12-13 00:44:16 +01:00
Snaipe
d9fa24276e Changed submessage union as oneof 2015-12-11 17:15:35 +01:00
Snaipe
74a72eec17 Updated protocol to latest 2015-12-11 17:01:38 +01:00
Snaipe
16b604673c Simplified protocol 2015-12-10 21:58:30 +01:00
Snaipe
7c69b81045 Updated gitignore 2015-12-10 12:42:44 +01:00
Snaipe
8b5f19f1d4 Added nanopb/nanomsg layer 2015-12-10 12:40:49 +01:00
Snaipe
c064f845a4 Added missing dependencies for nanopb 2015-12-10 12:39:55 +01:00
Snaipe
043395bcd7 Added nanomsg compilation in cmake build system 2015-12-09 17:11:11 +01:00
Snaipe
76cf9f47ca Added nanomsg dependency 2015-12-09 14:43:44 +01:00
Snaipe
474b0aa2f6 Added generated protocol sources 2015-12-09 13:53:31 +01:00
Snaipe
4f43b0b1a4 Fixed cmake module syntax error 2015-12-09 02:30:17 +01:00
Snaipe
6efdc13b81 Added basic criterion protocol definition 2015-12-09 01:51:22 +01:00
Snaipe
c9f88e5b93 Added nanopb generation facilities 2015-12-09 00:29:48 +01:00
Snaipe
8d3e913424 Removed submodule checkout in cmake submodule 2015-12-09 00:27:55 +01:00
Snaipe
1cc3f7c885 Added nanopb dependency 2015-12-08 23:15:33 +01:00
Snaipe
0becccc403 Added dependency on criterion for the criterion-dev package 2015-12-08 14:54:35 +01:00
Snaipe
76ff9b21b9 Reset deb build counter 2015-12-08 14:37:48 +01:00
Snaipe
65aa79dd52 [v2.2.0] Merge branch 'bleeding' (Version release) 2015-12-08 14:31:59 +01:00
Snaipe
78a62465e9 Merge branch 'features/language-decouple' into bleeding 2015-12-08 13:52:29 +01:00
Snaipe
ac2f5e1bce Removed Objective-C compiler modules 2015-12-08 03:12:05 +01:00
Snaipe
f913940427 Fixed decoupling for parameterized tests and fixed missing definitions 2015-12-08 02:36:23 +01:00
Snaipe
df7d47f184 Fixed theories regression tests 2015-12-08 01:56:01 +01:00
Snaipe
6c248da321 Removed Theory data point generation 2015-12-08 01:49:56 +01:00
Snaipe
e7234512ed Added doxygen for theories.h 2015-12-08 01:44:42 +01:00
Snaipe
0dfd69b4b9 Added doxygen for redirect.h 2015-12-08 01:10:06 +01:00
Snaipe
046e7abac5 Removed objective-c dependency on deb builds & added missing libpcre3 runtime dependency 2015-12-08 00:36:12 +01:00
Snaipe
c681d2a42e Added doxygen for parameterized.h 2015-12-08 00:34:38 +01:00
Snaipe
93199a1651 Added doxygen for output.h 2015-12-08 00:34:14 +01:00
Snaipe
7c416af673 Added doxygen for options.h 2015-12-08 00:34:02 +01:00
Snaipe
415fc20462 Added doxygen for hooks.h 2015-12-08 00:33:55 +01:00
Snaipe
1b9c13246a Fixed misformed table in assert docs 2015-12-07 15:09:30 +01:00
Snaipe
2e5e4af3c7 Added doxygen docs for alloc.h 2015-12-07 15:03:35 +01:00
Snaipe
00ca6cfc67 Added doxygen docs for abort.h 2015-12-07 15:03:27 +01:00
Snaipe
dbe2894b88 [Issue #81] Fixed documentation not mentioning that the assert message is a format string 2015-12-07 13:57:22 +01:00
Snaipe
cdcf52e373 Fixed conditional windows build broken by 13e7928d0c 2015-12-07 13:56:08 +01:00
Snaipe
13e7928d0c [Issue #82] Fixed deadlocks that were triggered when the event pipe was full and a child needed to be reaped 2015-12-07 13:28:49 +01:00
Snaipe
aaa21d922c Simplified empty tests & suite placeholders in runner 2015-12-06 14:27:44 +01:00
Snaipe
30c3afedda Added first tentative to decouple the wrappers from the library 2015-12-05 01:37:58 +01:00
Snaipe
214bd95a62 [Issue #83] Added single test execution mode 2015-12-04 18:44:46 +01:00
Snaipe
30f2982423 Fixed main not cleaning up on special CLI actions 2015-12-04 17:41:14 +01:00
Snaipe
503f9e2896 Properly set up cmake install components 2015-11-29 00:33:58 +01:00
Snaipe
689eee1545 Removed unused deb dependencies and activated objective c support on deb builds 2015-11-28 14:36:15 +01:00
Snaipe
ba21d658ca Added missing files for ppa builds 2015-11-28 14:33:09 +01:00
Snaipe
2ccbdbd578 Added deb generation rules in cmake module 2015-11-28 14:26:08 +01:00
Snaipe
c4bc28b7fb Added THEORIES cmake option 2015-11-27 15:53:10 +01:00
Snaipe
5101a514a3 Moved cr_translate_assert_msg out of the public API 2015-11-27 15:42:05 +01:00
Snaipe
d25ea68eb1 Removed the worker function pointer typedef from the public API 2015-11-27 14:21:50 +01:00
Snaipe
5fddb5a0c8 Added doxygen docs for types.h 2015-11-27 13:57:38 +01:00
Snaipe
4185058a89 Added doxygen-style doc in criterion.h 2015-11-27 13:47:35 +01:00
Snaipe
d55869a5e5 Moved criterion_test_params to internal API 2015-11-27 13:44:38 +01:00
Snaipe
090e8571fe Added missing license headers 2015-11-27 12:55:24 +01:00
Snaipe
d16ce3ae61 Refactored main.c -> params.c 2015-11-27 12:52:40 +01:00
Snaipe
3e48959798 Added --quiet implication of having a provider write to stderr in documentation 2015-11-27 12:31:38 +01:00
Snaipe
8a0540b5ab Revert "Added install checks on travis builds"
This reverts commit 56f0abfd49.
2015-11-27 12:26:49 +01:00
Snaipe
11b84284f7 Print strerror when failing to open a report file 2015-11-27 12:24:42 +01:00
Snaipe
07f109eb6e Added error messages when reporting fails 2015-11-27 12:18:46 +01:00
Snaipe
85095ba7e7 Disable --quiet when the provider output path is not stderr 2015-11-27 11:59:39 +01:00
Snaipe
56f0abfd49 Added install checks on travis builds 2015-11-27 11:48:52 +01:00
Snaipe
41d7123b41 Cleaned up travis config 2015-11-27 01:11:52 +01:00
Snaipe
635ddb204f Refactored travis config to install gcc 4.9 only on the relevant configurations 2015-11-27 00:52:14 +01:00
Snaipe
a5de951a48 Fixed travis build not running tests by default 2015-11-27 00:30:08 +01:00
Snaipe
6bfdaffea8 Fixed travis build translating 'ON' as 'true' in environment variables. 2015-11-27 00:24:39 +01:00
Snaipe
49abc86066 [Issue #76] Updated dyncall to latest for icc fix 2015-11-27 00:13:59 +01:00
Snaipe
1beccec921 Added back CRITERION_ENABLE_TAP and added CRITERION_OUTPUTS environment variable. 2015-11-26 00:23:27 +01:00
Snaipe
26b25cf1f9 Updated docs on the required version of GCC 2015-11-25 20:16:26 +01:00
Snaipe
fa29b3c6db Added back GCC 4.6 support 2015-11-25 20:10:09 +01:00
Snaipe
6a766ca432 [v2.1.1] Merge branch 'patch' (patch release)
This patch fixes accesses over freed assert messages, causing the TAP
output to be broken.
2015-11-25 12:41:30 +01:00
Snaipe
6f9d29a602 [Issue #78] Fixed assert message being freed too early, leading to some dangling pointers to invalid memory
Cherry-pick of commit 8197bef66c.
2015-11-25 12:33:56 +01:00
Snaipe
5bdccd862a Fixed unused parameter warnings 2015-11-21 00:07:53 +01:00
Snaipe
80a45b5ecc [Issue #76] Fixed compilation errors for ICC 2015-11-20 19:10:35 +01:00
Snaipe
2fbf8e8f1d Updated libcsptr for icc compilation 2015-11-20 18:49:48 +01:00
Snaipe
34fb71dcd6 Merge branch 'features/refactor' into bleeding 2015-11-19 14:43:35 +01:00
Snaipe
eeb7ab24f3 Fixed list formatting for supported compilers in documentation 2015-11-19 14:32:24 +01:00
Snaipe
cb9d702f06 [Issue #77] Fixed msgmerge being called with --lang on versions <=0.17 by cmake. 2015-11-19 02:13:17 +01:00
320 changed files with 18571 additions and 6720 deletions

View file

@ -1,8 +1,27 @@
[bumpversion]
current_version = 2.1.0
current_version = 2.3.0-rc1
commit = False
parse = ^
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # minimum 'N.N.N'
(?:
-(?P<prerel>\w+) # 'rc' = release candidate, 'dev' = dev branch
(?:
(?P<prerelversion>\d+)
)?
)?
serialize =
{major}.{minor}.{patch}-{prerel}{prerelversion}
{major}.{minor}.{patch}-{prerel}
{major}.{minor}.{patch}
[bumpversion:file:CMakeLists.txt]
[bumpversion:part:prerel]
optional_value = release
values =
dev
rc
release
[bumpversion:file:.cmake/Modules/Properties.cmake]
[bumpversion:file:doc/conf.py]

View file

@ -1,19 +0,0 @@
# Copyright (C) 2015 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
# CMake <2.8.10 backward compat
if(NOT CMAKE_PLATFORM_INFO_DIR)
set(CMAKE_PLATFORM_INFO_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
endif(NOT CMAKE_PLATFORM_INFO_DIR)
set(CMAKE_ObjectiveC_COMPILER_ID ${CMAKE_C_COMPILER_ID})
set(CMAKE_ObjectiveC_COMPILER ${CMAKE_C_COMPILER})
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeObjectiveCCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeObjectiveCCompiler.cmake
@ONLY
)
set(CMAKE_ObjectiveC_COMPILER_ENV_VAR "OBJCC")

View file

@ -1,10 +0,0 @@
set(CMAKE_ObjectiveC_COMPILER "@CMAKE_ObjectiveC_COMPILER@")
set(CMAKE_ObjectiveC_COMPILER_ID "@CMAKE_ObjectiveC_COMPILER_ID@")
set(CMAKE_ObjectiveC_IMPLICIT_LINK_LIBRARIES "@CMAKE_ObjectiveC_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_ObjectiveC_COMPILER_LOADED 1)
set(CMAKE_ObjectiveC_COMPILER_WORKS @CMAKE_ObjectiveC_COMPILER_WORKS@)
set(CMAKE_ObjectiveC_COMPILER_ID_RUN 1)
set(CMAKE_ObjectiveC_SOURCE_FILE_EXTENSIONS m)

View file

@ -1,192 +0,0 @@
if(UNIX)
set(CMAKE_ObjectiveC_OUTPUT_EXTENSION .o)
else()
set(CMAKE_ObjectiveC_OUTPUT_EXTENSION .obj)
endif()
set(_INCLUDED_FILE 0)
set(_INCLUDED_FILE_2 0)
# Load compiler-specific information.
if(CMAKE_ObjectiveC_COMPILER_ID)
include(Compiler/${CMAKE_ObjectiveC_COMPILER_ID}-C OPTIONAL)
endif()
set(CMAKE_BASE_NAME)
get_filename_component(CMAKE_BASE_NAME "${CMAKE_ObjectiveC_COMPILER}" NAME_WE)
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_ObjectiveC_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ObjectiveC_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ObjectiveC_COMPILER_ID}-ObjectiveC-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE_2)
endif()
if (NOT _INCLUDED_FILE AND NOT _INCLUDED_FILE_2)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif ()
endif()
# load the system- and compiler specific files
if(CMAKE_ObjectiveC_COMPILER_ID)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ObjectiveC_COMPILER_ID}-C
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ObjectiveC_COMPILER_ID}-ObjectiveC
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE_2)
endif()
if (NOT _INCLUDED_FILE AND _INCLUDED_FILE_2)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif ()
# We specify the compiler information in the system file for some
# platforms, but this language may not have been enabled when the file
# was first included. Include it again to get the language info.
# Remove this when all compiler info is removed from system files.
if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
endif ()
if(CMAKE_ObjectiveC_COMPILER_LINKS_STATICALLY)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
endif()
# This should be included before the _INIT variables are
# used to initialize the cache. Since the rule variables
# have if blocks on them, users can still define them here.
# But, it should still be after the platform file so changes can
# be made to those values.
if(CMAKE_USER_MAKE_RULES_OVERRIDE)
# Save the full path of the file so try_compile can use it.
include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
endif()
if(CMAKE_USER_MAKE_RULES_OVERRIDE_ObjectiveC)
# Save the full path of the file so try_compile can use it.
include(${CMAKE_USER_MAKE_RULES_OVERRIDE_ObjectiveC} RESULT_VARIABLE _override)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_ObjectiveC "${_override}")
endif()
# for most systems a module is the same as a shared library
# so unless the variable CMAKE_MODULE_EXISTS is set just
# copy the values from the LIBRARY variables
if(NOT CMAKE_MODULE_EXISTS)
set(CMAKE_SHARED_MODULE_ObjectiveC_FLAGS ${CMAKE_SHARED_LIBRARY_ObjectiveC_FLAGS})
set(CMAKE_SHARED_MODULE_CREATE_ObjectiveC_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_ObjectiveC_FLAGS})
endif()
if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
# default build type is none
if(NOT CMAKE_NO_BUILD_TYPE)
set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
set (CMAKE_ObjectiveC_FLAGS_DEBUG "${CMAKE_ObjectiveC_FLAGS_DEBUG_INIT}" CACHE STRING
"Flags used by the compiler during debug builds.")
set (CMAKE_ObjectiveC_FLAGS_MINSIZEREL "${CMAKE_ObjectiveC_FLAGS_MINSIZEREL_INIT}" CACHE STRING
"Flags used by the compiler during release builds for minimum size.")
set (CMAKE_ObjectiveC_FLAGS_RELEASE "${CMAKE_ObjectiveC_FLAGS_RELEASE_INIT}" CACHE STRING
"Flags used by the compiler during release builds.")
set (CMAKE_ObjectiveC_FLAGS_RELWITHDEBINFO "${CMAKE_ObjectiveC_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
"Flags used by the compiler during release builds with debug info.")
endif()
if(CMAKE_ObjectiveC_STANDARD_LIBRARIES_INIT)
set(CMAKE_ObjectiveC_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}"
CACHE STRING "Libraries linked by default with all C applications.")
mark_as_advanced(CMAKE_ObjectiveC_STANDARD_LIBRARIES)
endif()
include(CMakeCommonLanguageInclude)
# now define the following rule variables
# CMAKE_ObjectiveC_CREATE_SHARED_LIBRARY
# CMAKE_ObjectiveC_CREATE_SHARED_MODULE
# CMAKE_ObjectiveC_COMPILE_OBJECT
# CMAKE_ObjectiveC_LINK_EXECUTABLE
# variables supplied by the generator at use time
# <TARGET>
# <TARGET_BASE> the target without the suffix
# <OBJECTS>
# <OBJECT>
# <LINK_LIBRARIES>
# <FLAGS>
# <LINK_FLAGS>
# C compiler information
# <CMAKE_ObjectiveC_COMPILER>
# <CMAKE_SHARED_LIBRARY_CREATE_ObjectiveC_FLAGS>
# <CMAKE_SHARED_MODULE_CREATE_ObjectiveC_FLAGS>
# <CMAKE_ObjectiveC_LINK_FLAGS>
# Static library tools
# <CMAKE_AR>
# <CMAKE_RANLIB>
# create a C shared library
if(NOT CMAKE_ObjectiveC_CREATE_SHARED_LIBRARY)
set(CMAKE_ObjectiveC_CREATE_SHARED_LIBRARY
"<CMAKE_ObjectiveC_COMPILER> <CMAKE_SHARED_LIBRARY_ObjectiveC_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_ObjectiveC_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
endif()
# create a C shared module just copy the shared library rule
if(NOT CMAKE_ObjectiveC_CREATE_SHARED_MODULE)
set(CMAKE_ObjectiveC_CREATE_SHARED_MODULE ${CMAKE_ObjectiveC_CREATE_SHARED_LIBRARY})
endif()
# Create a static archive incrementally for large object file counts.
# If CMAKE_ObjectiveC_CREATE_STATIObjectiveC_LIBRARY is set it will override these.
if(NOT DEFINED CMAKE_ObjectiveC_ARCHIVE_CREATE)
set(CMAKE_ObjectiveC_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_ObjectiveC_ARCHIVE_APPEND)
set(CMAKE_ObjectiveC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_ObjectiveC_ARCHIVE_FINISH)
set(CMAKE_ObjectiveC_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
endif()
set(CMAKE_INCLUDE_FLAG_ObjectiveC "-I")
set(CMAKE_ObjectiveC_IMPLICIT_LINK_LIBRARIES objc)
# compile a C file into an object file
if(NOT CMAKE_ObjectiveC_COMPILE_OBJECT)
if("${CMAKE_VERSION}" VERSION_GREATER 3.3.2)
set(CMAKE_ObjectiveC_COMPILE_OBJECT
"<CMAKE_ObjectiveC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
else ()
set(CMAKE_ObjectiveC_COMPILE_OBJECT
"<CMAKE_ObjectiveC_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
endif ()
endif()
if(NOT CMAKE_ObjectiveC_LINK_EXECUTABLE)
set(CMAKE_ObjectiveC_LINK_EXECUTABLE
"<CMAKE_ObjectiveC_COMPILER> <FLAGS> <CMAKE_ObjectiveC_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endif()
if(NOT CMAKE_EXECUTABLE_RUNTIME_ObjectiveC_FLAG)
set(CMAKE_EXECUTABLE_RUNTIME_ObjectiveC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_ObjectiveC_FLAG})
endif()
if(NOT CMAKE_EXECUTABLE_RUNTIME_ObjectiveC_FLAG_SEP)
set(CMAKE_EXECUTABLE_RUNTIME_ObjectiveC_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_ObjectiveC_FLAG_SEP})
endif()
if(NOT CMAKE_EXECUTABLE_RPATH_LINK_ObjectiveC_FLAG)
set(CMAKE_EXECUTABLE_RPATH_LINK_ObjectiveC_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_ObjectiveC_FLAG})
endif()
mark_as_advanced(
CMAKE_ObjectiveC_FLAGS
CMAKE_ObjectiveC_FLAGS_DEBUG
CMAKE_ObjectiveC_FLAGS_MINSIZEREL
CMAKE_ObjectiveC_FLAGS_RELEASE
CMAKE_ObjectiveC_FLAGS_RELWITHDEBINFO
)
set(CMAKE_ObjectiveC_INFORMATION_LOADED 1)

View file

@ -1,64 +0,0 @@
if(CMAKE_ObjectiveC_COMPILER_FORCED)
# The compiler configuration was forced by the user.
# Assume the user has configured all compiler information.
set(CMAKE_ObjectiveC_COMPILER_WORKS TRUE)
return()
endif()
include(CMakeTestCompilerCommon)
# Remove any cached result from an older CMake version.
# We now store this in CMakeCCompiler.cmake.
unset(CMAKE_ObjectiveC_COMPILER_WORKS CACHE)
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected C compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
if(NOT CMAKE_ObjectiveC_COMPILER_WORKS)
PrintTestCompilerStatus("ObjectiveC" "")
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testObjectiveCCompiler.m
"#ifdef __cplusplus\n"
"# error \"The CMAKE_ObjectiveC_COMPILER is set to an ObjectiveC++ compiler\"\n"
"#endif\n"
"@interface Foo\n"
"@end\n"
"int main(int argc, char* argv[])\n"
"{ (void)argv; return argc-1;}\n")
try_compile(CMAKE_ObjectiveC_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testObjectiveCCompiler.m
OUTPUT_VARIABLE __CMAKE_ObjectiveC_COMPILER_OUTPUT)
# Move result from cache to normal variable.
set(CMAKE_ObjectiveC_COMPILER_WORKS ${CMAKE_ObjectiveC_COMPILER_WORKS})
unset(CMAKE_ObjectiveC_COMPILER_WORKS CACHE)
set(ObjectiveC_TEST_WAS_RUN 1)
endif()
if(NOT CMAKE_ObjectiveC_COMPILER_WORKS)
PrintTestCompilerStatus("ObjectiveC" " -- broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the ObjectiveC compiler works failed with "
"the following output:\n${__CMAKE_ObjectiveC_COMPILER_OUTPUT}\n\n")
message(FATAL_ERROR "The ObjectiveC compiler \"${CMAKE_ObjectiveC_COMPILER}\" "
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${__CMAKE_ObjectiveC_COMPILER_OUTPUT}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(ObjectiveC_TEST_WAS_RUN)
PrintTestCompilerStatus("ObjectiveC" " -- works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the ObjectiveC compiler works passed with "
"the following output:\n${__CMAKE_ObjectiveC_COMPILER_OUTPUT}\n\n")
endif()
# Re-configure file
configure_file(
${CMAKE_CURRENT_LIST_DIR}/CMakeObjectiveCCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeObjectiveCCompiler.cmake
@ONLY
)
include(${CMAKE_PLATFORM_INFO_DIR}/CMakeObjectiveCCompiler.cmake)
endif()
unset(__CMAKE_ObjectiveC_COMPILER_OUTPUT)

View file

@ -1,12 +1,70 @@
# Copyright (C) 2015 Franklin "Snaipe" Mathieu.
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(CheckPrototypeDefinition)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(PackageUtils)
check_prototype_definition(
strtok_s
"char *strtok_s(char *strToken, const char *strDelimit, char **context)"
NULL
"string.h"
HAVE_STRTOK_S)
# Check for packages
cr_find_package (Gettext)
cr_find_package (Libintl)
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
set (GettextTranslate_ALL 1)
set (GettextTranslate_GMO_BINARY 1)
set (ENABLE_NLS 1)
endif ()
# Check for functions
check_function_exists(strtok_s HAVE_STRTOK_S)
check_function_exists(strtok_r HAVE_STRTOK_R)
check_library_exists (anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
check_function_exists(funopen HAVE_FUNOPEN)
check_function_exists(fopencookie HAVE_FOPENCOOKIE)
check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
if (HAVE_CLOCK_GETTIME_RT AND NOT HAVE_LIBRT)
set (HAVE_LIBRT 1)
endif ()
if (NOT HAVE_CLOCK_GETTIME_RT)
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
else ()
set (HAVE_CLOCK_GETTIME "${HAVE_CLOCK_GETTIME_RT}" CACHE INTERNAL "Have symbol clock_gettime")
endif ()
check_symbol_exists(CLOCK_MONOTONIC_RAW "time.h" HAVE_CLOCK_MONOTONIC_RAW)
# Check for C++11
if (LANG_CXX)
enable_language(CXX)
endif ()
if (NOT MSVC AND CMAKE_CXX_COMPILER_WORKS)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CXX11_FLAG "-std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CXX11_FLAG "-std=c++0x")
else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
endif()
# Valgrind support
if (DEV_BUILD)
set(ENABLE_VALGRIND_ERRORS 1)
endif ()

View file

@ -110,7 +110,7 @@ if (GIT_FOUND)
# Branch.
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
@ -118,7 +118,7 @@ if (GIT_FOUND)
macro (git_log_format FORMAT_CHARS VAR_NAME)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%${FORMAT_CHARS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE ${VAR_NAME}
OUTPUT_STRIP_TRAILING_WHITESPACE
)

63
.cmake/Modules/Cram.cmake Normal file
View file

@ -0,0 +1,63 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
set(PATH_VAR
"${PROJECT_BINARY_DIR}/samples"
"${PROJECT_BINARY_DIR}/samples/tests"
"${PROJECT_BINARY_DIR}/external/lib"
"${PROJECT_BINARY_DIR}/external/bin"
)
set(NEW_PATH "")
foreach (P ${PATH_VAR})
file (TO_NATIVE_PATH "${P}" P)
list (APPEND NEW_PATH "${P}")
endforeach ()
set (PATH_VAR "${NEW_PATH}")
if (NOT WIN32)
string (REPLACE ";" ":" PATH_VAR "${PATH_VAR}")
set(ENV{PATH} "$ENV{PATH}:${PATH_VAR}")
else ()
set(ENV{PATH} "$ENV{PATH};${PATH_VAR}")
endif ()
set(ENV{LC_ALL} "en_US.utf8")
set(ENV{CRITERION_ALWAYS_SUCCEED} "1")
set(ENV{CRITERION_SHORT_FILENAME} "1")
set(ENV{CRITERION_JOBS} "1")
set(ENV{CRITERION_DISABLE_TIME_MEASUREMENTS} "1")
set(ENV{MSYS2_ARG_CONV_EXCL} "--filter=")
if (WIN32)
if (ENV{MINGW} STREQUAL "")
set (MINGW_HOME "C:/MinGW")
else ()
file (TO_CMAKE_PATH "$ENV{MINGW}" MINGW_HOME)
endif ()
if (ENV{CRAM_SHELL} STREQUAL "" AND MINGW_HOME)
set (CRAM_SHELL "${MINGW_HOME}/msys/1.0/bin/sh.exe")
else ()
file (TO_CMAKE_PATH "$ENV{CRAM_SHELL}" CRAM_SHELL)
endif ()
if (CRAM_SHELL)
set(CRAM_OPTS "--shell=${CRAM_SHELL}")
endif ()
endif ()
if ("$ENV{TRAVIS}" STREQUAL "true")
execute_process (COMMAND cram -v ${CRAM_OPTS} "${CRAM_PATH}" TIMEOUT 60 RESULT_VARIABLE RES)
else ()
if ("$ENV{PYTHON_BIN}" STREQUAL "")
set (PYTHON "python")
else ()
set (PYTHON "$ENV{PYTHON_BIN}")
endif ()
execute_process (COMMAND ${PYTHON} -m cram -v ${CRAM_OPTS} "${CRAM_PATH}" TIMEOUT 60 RESULT_VARIABLE RES)
endif ()
if (NOT RES STREQUAL "0")
message (FATAL_ERROR "Cram tests failed")
endif ()

View file

@ -0,0 +1,43 @@
# build a Debian package for Launchpad
set(CPACK_DEBIAN_PACKAGE_NAME "criterion")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Snaipe/Criterion")
set(CPACK_DEBIAN_BUILD_DEPENDS
debhelper
cmake
gettext
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_CMAKE_OPTIONS)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/description.txt")
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY "${PROJECT_SOURCE_DIR}/.cmake/copy-source.sh")
set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
set(CPACK_DEBIAN_DISTRIBUTION_RELEASES precise trusty vivid wily xenial)
set(DPUT_HOST "snaipewastaken-ppa")
set(DPUT_SNAPSHOT_HOST "snaipewastaken-ppa")
set(CPACK_DEBIAN_PACKAGE_DOCS "")
set(CPACK_DEBIAN_PACKAGE_INSTALL
"/usr/lib/*.so"
"/usr/lib/*.so.*"
"/usr/share/locale/*"
)
set(CPACK_COMPONENTS_ALL "dev")
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Criterion library development files")
set(CPACK_COMPONENT_DEV_DESCRIPTION "These are the development files.")
set(CPACK_COMPONENT_DEV_SECTION "devel")
set(CPACK_COMPONENT_DEV_DEPENDS
criterion
)
set(CPACK_COMPONENT_DEV_DOCS "")
set(CPACK_COMPONENT_DEV_INSTALL "/usr/include")
include (DebSourcePPA)

View file

@ -0,0 +1,347 @@
## Debian Source Package Generator
#
# Copyright (c) 2010 Daniel Pfeifer <daniel@pfeifer-mail.de>
# Many modifications by Rosen Diankov <rosen.diankov@gmail.com>
#
# Creates source debian files and manages library dependencies
#
# Features:
#
# - Automatically generates symbols and run-time dependencies from the build dependencies
# - Custom copy of source directory via CPACK_DEBIAN_PACKAGE_SOURCE_COPY
# - Simultaneous output of multiple debian source packages for each distribution
# - Can specificy distribution-specific dependencies by suffixing DEPENDS with _${DISTRO_NAME}, for example: CPACK_DEBIAN_PACKAGE_DEPENDS_LUCID, CPACK_COMPONENT_MYCOMP0_DEPENDS_LUCID
#
# Usage:
#
# set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake)
# set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
# set(CPACK_DEBIAN_PACKAGE_SECTION devel)
# set(CPACK_DEBIAN_CMAKE_OPTIONS "-DMYOPTION=myvalue")
# set(CPACK_DEBIAN_PACKAGE_DEPENDS mycomp0 mycomp1 some_ubuntu_package)
# set(CPACK_DEBIAN_PACKAGE_DEPENDS_UBUNTU_LUCID mycomp0 mycomp1 lucid_specific_package)
# set(CPACK_DEBIAN_PACKAGE_NAME mypackage)
# set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES unnecessary_file unnecessary_dir/file0)
# set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force) # if using subversion
# set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
# set(CPACK_DEBIAN_DISTRIBUTION_RELEASES karmic lucid maverick natty)
# set(CPACK_DEBIAN_CHANGELOG " * Extra change log lines")
# set(CPACK_DEBIAN_PACKAGE_SUGGESTS "ipython")
# set(CPACK_COMPONENT_X_RECOMMENDS "recommended-package")
##
find_program(DEBUILD_EXECUTABLE debuild)
find_program(DPUT_EXECUTABLE dput)
if(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
return()
endif(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
# DEBIAN/control
# debian policy enforce lower case for package name
# Package: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
# Section: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
# Priority: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
file(STRINGS ${CPACK_PACKAGE_DESCRIPTION_FILE} DESC_LINES)
foreach(LINE ${DESC_LINES})
set(DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n")
endforeach(LINE ${DESC_LINES})
file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/Debian")
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/Debian")
set(DEBIAN_SOURCE_ORIG_DIR "${PROJECT_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
if( CPACK_DEBIAN_PACKAGE_SOURCE_COPY )
execute_process(COMMAND ${CPACK_DEBIAN_PACKAGE_SOURCE_COPY} "${PROJECT_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.git")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.svn")
endif()
# remove unnecessary folders
foreach(REMOVE_DIR ${CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES})
file(REMOVE_RECURSE ${DEBIAN_SOURCE_ORIG_DIR}.orig/${REMOVE_DIR})
endforeach()
# create the original source tar
execute_process(COMMAND ${CMAKE_COMMAND} -E tar czf "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.orig.tar.gz" "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.orig" WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)
set(DEB_SOURCE_CHANGES)
foreach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
set(DEBIAN_SOURCE_DIR "${DEBIAN_SOURCE_ORIG_DIR}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
set(RELEASE_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
string(TOUPPER ${RELEASE} RELEASE_UPPER)
string(TOUPPER ${CPACK_DEBIAN_DISTRIBUTION_NAME} DISTRIBUTION_NAME_UPPER)
file(MAKE_DIRECTORY ${DEBIAN_SOURCE_DIR}/debian)
##############################################################################
# debian/control
set(DEBIAN_CONTROL ${DEBIAN_SOURCE_DIR}/debian/control)
file(WRITE ${DEBIAN_CONTROL}
"Source: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
"Section: ${CPACK_DEBIAN_PACKAGE_SECTION}\n"
"Priority: ${CPACK_DEBIAN_PACKAGE_PRIORITY}\n"
"DM-Upload-Allowed: yes\n"
"Maintainer: ${CPACK_PACKAGE_CONTACT}\n"
"Build-Depends: "
)
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Standards-Version: 3.8.4\n"
"Homepage: ${CPACK_PACKAGE_VENDOR}\n"
"\n"
"Package: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
"Architecture: any\n"
"Depends: "
)
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\nRecommends: ")
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\nSuggests: ")
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n"
"${DEB_LONG_DESCRIPTION}"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
string(TOUPPER ${COMPONENT} UPPER_COMPONENT)
set(DEPENDS "\${shlibs:Depends}")
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
set(RECOMMENDS)
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
set(SUGGESTS)
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Package: ${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT}\n"
"Architecture: any\n"
"Depends: ${DEPENDS}\n"
"Recommends: ${RECOMMENDS}\n"
"Suggests: ${SUGGESTS}\n"
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_COMPONENT_${UPPER_COMPONENT}_DISPLAY_NAME}\n"
"${DEB_LONG_DESCRIPTION}"
" .\n"
" ${CPACK_COMPONENT_${UPPER_COMPONENT}_DESCRIPTION}\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
##############################################################################
# debian/copyright
set(DEBIAN_COPYRIGHT ${DEBIAN_SOURCE_DIR}/debian/copyright)
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy ${CPACK_RESOURCE_FILE_LICENSE} ${DEBIAN_COPYRIGHT}
)
##############################################################################
# debian/rules
set(DEBIAN_RULES ${DEBIAN_SOURCE_DIR}/debian/rules)
file(WRITE ${DEBIAN_RULES}
"#!/usr/bin/make -f\n"
"\n"
"BUILDDIR = build_dir\n"
"\n"
"build:\n"
" mkdir $(BUILDDIR)\n"
" cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=Release ${CPACK_DEBIAN_CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr ..\n"
" $(MAKE) -C $(BUILDDIR) preinstall\n"
" touch build\n"
"\n"
"binary: binary-indep binary-arch\n"
"\n"
"binary-indep: build\n"
"\n"
"binary-arch: build\n"
" cd $(BUILDDIR); cmake -DCOMPONENT=Unspecified -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr -P cmake_install.cmake\n"
" mkdir -p debian/tmp/DEBIAN\n"
" dpkg-gensymbols -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
set(PATH debian/${COMPONENT})
file(APPEND ${DEBIAN_RULES}
" cd $(BUILDDIR); cmake -DCOMPONENT=${COMPONENT} -DCMAKE_INSTALL_PREFIX=../${PATH}/usr -P cmake_install.cmake\n"
" mkdir -p ${PATH}/DEBIAN\n"
" dpkg-gensymbols -p${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT} -P${PATH}\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
file(APPEND ${DEBIAN_RULES}
" dh_shlibdeps\n"
" dh_strip\n" # for reducing size
" dpkg-gencontrol -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
" dpkg --build debian/tmp ..\n"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
set(PATH debian/${COMPONENT})
file(APPEND ${DEBIAN_RULES}
" dpkg-gencontrol -p${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT} -P${PATH} -Tdebian/${COMPONENT}.substvars\n"
" dpkg --build ${PATH} ..\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
file(APPEND ${DEBIAN_RULES}
"\n"
"clean:\n"
" rm -f build\n"
" rm -rf $(BUILDDIR)\n"
"\n"
".PHONY: binary binary-arch binary-indep clean\n"
)
execute_process(COMMAND chmod +x ${DEBIAN_RULES})
##############################################################################
# debian/compat
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/compat "7")
##############################################################################
# debian/source/format
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/source/format "3.0 (quilt)")
##############################################################################
# debian/changelog
set(DEBIAN_CHANGELOG ${DEBIAN_SOURCE_DIR}/debian/changelog)
execute_process(COMMAND date -R OUTPUT_VARIABLE DATE_TIME)
file(WRITE ${DEBIAN_CHANGELOG}
"${CPACK_DEBIAN_PACKAGE_NAME} (${RELEASE_PACKAGE_VERSION}) ${RELEASE}; urgency=medium\n\n"
" * Package built with CMake\n\n"
"${CPACK_DEBIAN_CHANGELOG}"
" -- ${CPACK_PACKAGE_CONTACT} ${DATE_TIME}"
)
##############################################################################
# debuild -S
if( DEB_SOURCE_CHANGES )
set(DEBUILD_OPTIONS "-sd")
else()
set(DEBUILD_OPTIONS "-sa")
endif()
set(SOURCE_CHANGES_FILE "${CPACK_DEBIAN_PACKAGE_NAME}_${RELEASE_PACKAGE_VERSION}_source.changes")
set(DEB_SOURCE_CHANGES ${DEB_SOURCE_CHANGES} "${SOURCE_CHANGES_FILE}")
add_custom_command(OUTPUT "${SOURCE_CHANGES_FILE}" COMMAND ${DEBUILD_EXECUTABLE} -S ${DEBUILD_OPTIONS} WORKING_DIRECTORY ${DEBIAN_SOURCE_DIR})
endforeach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
##############################################################################
# dput ppa:your-lp-id/ppa <source.changes>
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)

View file

@ -0,0 +1,9 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
# Add toolchain patch number for incremental deb builds
set(PROJECT_VERSION "${PROJECT_VERSION}-2")
include (PackageConfig)
include (DebConfig)

View file

@ -1,4 +1,4 @@
# Copyright (C) 2015 Franklin "Snaipe" Mathieu.
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.

View file

@ -1,4 +1,4 @@
# Copyright (C) 2015 Franklin "Snaipe" Mathieu.
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.

View file

@ -1,37 +0,0 @@
# Copyright (C) 2007-2009 LuaDist.
# Created by Peter Kapec <kapecp@gmail.com>
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Note:
# Searching headers and libraries is very simple and is NOT as powerful as scripts
# distributed with CMake, because LuaDist defines directories to search for.
# Everyone is encouraged to contact the author with improvements. Maybe this file
# becomes part of CMake distribution sometimes.
# - Find pcre
# Find the native PCRE headers and libraries.
#
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE_LIBRARIES - List of libraries when using pcre.
# PCRE_FOUND - True if pcre found.
# Look for the header file.
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h)
# Look for the library.
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
# Copy the results to the output variables.
IF(PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
ELSE(PCRE_FOUND)
SET(PCRE_LIBRARIES)
SET(PCRE_INCLUDE_DIRS)
ENDIF(PCRE_FOUND)
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)

View file

@ -252,13 +252,41 @@ macro(GettextTranslate)
else()
add_custom_target(${PO_TARGET}
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --lang=${lang}
${PO_FILE_NAME} ${TEMPLATE_FILE_ABS}
-o ${PO_FILE_NAME}.new
COMMAND mv ${PO_FILE_NAME}.new ${PO_FILE_NAME}
DEPENDS ${TEMPLATE_FILE_ABS}
execute_process(
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --version
OUTPUT_VARIABLE MSGMERGE_VERSION_MSG
)
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" MSGMERGE_VERSION "${MSGMERGE_VERSION_MSG}")
if ("${MSGMERGE_VERSION}" VERSION_GREATER "0.17")
add_custom_target(${PO_TARGET}
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --lang=${lang}
${PO_FILE_NAME} ${TEMPLATE_FILE_ABS}
-o ${PO_FILE_NAME}.new
COMMAND if diff ${PO_FILE_NAME} ${PO_FILE_NAME}.new
--unchanged-line-format='' --old-line-format=''
| grep -v 'POT-Creation-Date' >/dev/null\; then
mv ${PO_FILE_NAME}.new ${PO_FILE_NAME}\;
else
rm ${PO_FILE_NAME}.new\;
fi
DEPENDS ${TEMPLATE_FILE_ABS}
)
else ()
add_custom_target(${PO_TARGET}
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE}
${PO_FILE_NAME} ${TEMPLATE_FILE_ABS}
-o ${PO_FILE_NAME}.new
COMMAND if diff ${PO_FILE_NAME} ${PO_FILE_NAME}.new
--unchanged-line-format='' --old-line-format=''
| grep -v 'POT-Creation-Date' >/dev/null\; then
mv ${PO_FILE_NAME}.new ${PO_FILE_NAME}\;
else
rm ${PO_FILE_NAME}.new\;
fi
DEPENDS ${TEMPLATE_FILE_ABS}
)
endif ()
endif()
@ -271,7 +299,7 @@ macro(GettextTranslate)
add_dependencies(${PO_TARGET} ${MAKEVAR_DOMAIN}.pot-update)
install(FILES ${GMO_FILE_NAME} DESTINATION
${LOCALEDIR}/${lang}/LC_MESSAGES
${LOCALEDIR_REL}/${lang}/LC_MESSAGES
RENAME ${MAKEVAR_DOMAIN}.mo
)

View file

@ -1,17 +0,0 @@
option(LANG_CXX "Turn on C++ support" ON)
option(LANG_OBJC "Turn on Objective-C support" OFF)
if (LANG_CXX)
enable_language(CXX)
if (CMAKE_CXX_COMPILER_WORKS)
set(CXX_BRIDGE 1)
endif ()
endif ()
if (LANG_OBJC)
enable_language(ObjectiveC)
if (CMAKE_ObjectiveC_COMPILER_WORKS)
set(OBJC_BRIDGE 1)
endif ()
endif ()

View file

@ -0,0 +1,13 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
option(LANG_CXX "Turn on C++ support" ON)
option(THEORIES "Activate the support for theories" ON)
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
option(COVERALLS "Turn on coveralls support" OFF)
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
option(DEV_BUILD "Compile in developer mode" OFF)
option(CTESTS "Turn on the samples and test" ${DEV_BUILD})
option(I18N "Turn on internationalization" ON)
option(UPLOAD_DEB "Upload package to launchpad" OFF)

View file

@ -0,0 +1,79 @@
function(extract_version version major minor patch extra)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" version_valid ${version})
if(version_valid)
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" "\\1;\\2;\\3;\\4" VERSION_MATCHES ${version})
list(GET VERSION_MATCHES 0 version_major)
set(${major} ${version_major} PARENT_SCOPE)
list(GET VERSION_MATCHES 1 version_minor)
set(${minor} ${version_minor} PARENT_SCOPE)
list(GET VERSION_MATCHES 2 version_patch)
set(${patch} ${version_patch} PARENT_SCOPE)
list(GET VERSION_MATCHES 3 version_extra)
set(${extra} ${version_extra} PARENT_SCOPE)
else(version_valid)
message(AUTHOR_WARNING "Bad version ${version}; falling back to 0 (have you made an initial release?)")
set(${major} "0" PARENT_SCOPE)
set(${minor} "" PARENT_SCOPE)
set(${patch} "" PARENT_SCOPE)
set(${extra} "" PARENT_SCOPE)
endif(version_valid)
endfunction(extract_version)
if (WIN32)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
else ()
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
endif ()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A KISS, modern unit testing framework for C and C++.")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-binary-${PROJECT_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Franklin \"Snaipe\" Mathieu")
set(CPACK_PACKAGE_CONTACT "Franklin \"Snaipe\" Mathieu <franklinmathieu@gmail.com>")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
if (WIN32)
# add snapshot specific versioning information
if (CPACK_DEBIAN_PACKAGE_TYPE STREQUAL "snapshot")
execute_process(COMMAND date +%Y%m%d%0k%0M%0S%z OUTPUT_VARIABLE SNAPSHOT_DATE_TIME)
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-snapshot-${SNAPSHOT_DATE_TIME}")
STRING(REPLACE "\n" "" CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
endif ()
endif ()
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/debian.copyright")
extract_version(${PROJECT_VERSION}
CPACK_PACKAGE_VERSION_MAJOR
CPACK_PACKAGE_VERSION_MINOR
CPACK_PACKAGE_VERSION_PATCH
VERSION_EXTRA
)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
file(GLOB TRASH_FILES "${PROJECT_SOURCE_DIR}/*")
set(KEEP_FILES
"${PROJECT_SOURCE_DIR}/.cmake"
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/doc"
"${PROJECT_SOURCE_DIR}/dev"
"${PROJECT_SOURCE_DIR}/po"
"${PROJECT_SOURCE_DIR}/dependencies"
"${PROJECT_SOURCE_DIR}/CMakeLists.txt"
"${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/CONTRIBUTING.md"
"${PROJECT_SOURCE_DIR}/LICENSE"
"${PROJECT_SOURCE_DIR}/ChangeLog"
"${PROJECT_SOURCE_DIR}/description.txt"
)
list(REMOVE_ITEM TRASH_FILES ${KEEP_FILES})
# Escape any '.' characters
string(REPLACE "." "\\\\." TRASH_FILES "${TRASH_FILES}")
set(CPACK_SOURCE_IGNORE_FILES "${TRASH_FILES}")
include(CPack)

View file

@ -0,0 +1,97 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(CMakeParseArguments)
function (cr_link_package _TARGET _PKG)
if (${_PKG}_LIB_FOUND OR ${_PKG}_FOUND)
target_link_libraries(${_TARGET} ${${_PKG}_LIBRARIES})
include_directories(${${_PKG}_INCLUDE_DIRS})
endif ()
endfunction ()
function (cr_link_libraries _TARGET)
set (multiValueArgs IF)
cmake_parse_arguments (ARGS "" "" "${multiValueArgs}" ${ARGN})
if (ARGS_IF)
if (${ARGS_IF})
else ()
return ()
endif ()
endif ()
target_link_libraries(${_TARGET} ${ARGS_UNPARSED_ARGUMENTS})
endfunction ()
function (cr_add_library _LIB)
set (options SHARED STATIC)
set (oneValueArgs COMPONENT)
set (multiValueArgs SOURCES HEADERS PROPERTIES)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set (flags "")
if (ARGS_SHARED)
set (flags ${flags} SHARED)
elseif (ARGS_STATIC)
set (flags ${flags} STATIC)
endif ()
add_library(${_LIB} ${flags} ${ARGS_SOURCES} ${ARGS_HEADERS})
set_target_properties(${_LIB} PROPERTIES ${ARGS_PROPERTIES})
foreach (F ${INTERFACE_FILES})
get_filename_component(DEST "${F}" PATH)
if (ARGS_COMPONENT)
set (install_flags COMPONENT ${ARGS_COMPONENT})
endif ()
install(FILES "${F}" DESTINATION "${DEST}" ${install_flags})
endforeach ()
install(TARGETS ${_LIB}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib ${install_flags}
)
endfunction ()
find_package(PkgConfig)
macro (cr_find_package _PKG)
set (options REQUIRED)
set (oneValueArgs PKGCONFIG)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "" ${ARGN})
string (TOUPPER "${_PKG}" _PKG_UP)
find_package (${_PKG})
if (NOT ${_PKG_UP}_FOUND AND ${_PKG_UP}_LIB_FOUND)
set (${_PKG_UP}_FOUND ON)
endif ()
if (NOT ${_PKG_UP}_FOUND AND PKGCONFIG_FOUND)
message (STATUS "Checking for package ${_PKG} with pkg-config")
if (NOT ARGS_PKGCONFIG)
set (ARGS_PKGCONFIG ${_PKG})
endif ()
pkg_check_modules(${_PKG_UP}_PKG ${ARGS_PKGCONFIG})
if (${_PKG_UP}_PKG_FOUND)
if (${_PKG_UP}_PKG_LIBRARY_DIRS)
link_directories(${${_PKG_UP}_PKG_LIBRARY_DIRS})
endif ()
set (${_PKG_UP}_LIBRARIES ${${_PKG_UP}_PKG_LIBRARIES})
set (${_PKG_UP}_INCLUDE_DIRS ${${_PKG_UP}_PKG_INCLUDE_DIRS})
set (${_PKG_UP}_FOUND 1)
endif()
endif ()
if (NOT ${_PKG_UP}_FOUND AND ARGS_REQUIRED)
message (FATAL_ERROR "Could not find required package ${_PKG}")
endif ()
if (${_PKG_UP}_FOUND)
set (HAVE_${_PKG_UP} 1)
endif ()
endmacro ()

View file

@ -0,0 +1,41 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
set (PROJECT_VERSION "2.3.0-rc1")
set (PROJECT_SOVERSION 3)
set (PROJECT_SONAME 3.1.0)
set (LOCALEDIR_REL "share/locale")
set (LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
string (TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
add_definitions(
-DCRITERION_BUILDING_DLL=1
-DPB_ENABLE_MALLOC=1
)
set (CMAKE_C_FLAGS_DEFAULT "${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS_DEFAULT "${CMAKE_CXX_FLAGS}")
if (MSVC)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
add_definitions (-D_CRT_SECURE_NO_WARNINGS=1)
add_definitions (-DVC_EXTRALEAN)
add_definitions (-DWIN32_LEAN_AND_MEAN)
add_definitions (-D_WIN32_WINNT=0x600)
else ()
if (WIN32)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=gnu99 -fvisibility=hidden")
if (CMAKE_CXX_COMPILER_WORKS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${CXX11_FLAG} -fvisibility=hidden")
endif ()
endif ()
include_directories(SYSTEM
/usr/local/include
/usr/include/GNUstep
)

View file

@ -26,31 +26,4 @@ else()
)
endif()
### Then, checkout each submodule to the specified commit
# Note: Execute separate processes here, to make sure each one is run,
# should one crash (because of branch not existing, this, that ... whatever)
foreach(GIT_SUBMODULE ${GIT_SUBMODULES})
if( "${GIT_SUBMODULE_VERSION_${GIT_SUBMODULE}}" STREQUAL "" )
message(STATUS "no specific version given for submodule ${GIT_SUBMODULE}, checking out master")
set(GIT_SUBMODULE_VERSION_${GIT_SUBMODULE} "master")
endif()
if(${GIT_SUBMODULES_CHECKOUT_QUIET})
execute_process(
COMMAND git checkout ${GIT_SUBMODULE_VERSION_${GIT_SUBMODULE}}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${GIT_SUBMODULES_DIRECTORY}/${GIT_SUBMODULE}
OUTPUT_QUIET
ERROR_QUIET
)
else()
message(STATUS "checking out ${GIT_SUBMODULE}'s commit/tag ${GIT_SUBMODULE_VERSION_${GIT_SUBMODULE}}")
execute_process(
COMMAND git checkout -q ${GIT_SUBMODULE_VERSION_${GIT_SUBMODULE}}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/${GIT_SUBMODULES_DIRECTORY}/${GIT_SUBMODULE}
)
endif()
endforeach(${GIT_SUBMODULE})
endif()

View file

@ -0,0 +1,123 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(ExternalProject)
include(CMakeParseArguments)
function (cr_add_subproject _NAME)
set (options CMAKE AUTOTOOLS)
set (oneValueArgs GIT PATH PREFIX GENERATOR)
set (multiValueArgs OPTS IF)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (ARGS_IF)
if (${ARGS_IF})
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
else ()
return ()
endif ()
else ()
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
endif ()
if (ARGS_PREFIX)
set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
else ()
set (install_prefix ${CMAKE_BINARY_DIR}/external)
endif ()
if (ARGS_GIT)
string(REPLACE "#" ";" git_opts "${ARGS_GIT}")
list(LENGTH git_opts git_opts_len)
list(GET git_opts 0 repo)
set (epa_opts GIT_REPOSITORY "${repo}")
if (git_opts_len GREATER 1)
list(GET git_opts 1 object)
set (epa_opts ${epa_opts} GIT_TAG "${object}")
endif ()
elseif (ARGS_PATH)
set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
endif ()
if (ARGS_CMAKE)
if (NOT ARGS_GENERATOR)
set (ARGS_GENERATOR ${CMAKE_GENERATOR})
endif ()
if (CMAKE_TOOLCHAIN_FILE)
set (ARGS_OPTS ${ARGS_OPTS}
"-DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif ()
set (build_cmds
CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
-DCMAKE_INSTALL_PREFIX=${install_prefix}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-G "${ARGS_GENERATOR}"
${ARGS_OPTS}
BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
)
elseif (ARGS_AUTOTOOLS)
set (make_opts "")
if (ARGS_PARALLELIZED)
set (make_opts "${make_opts} -j4")
endif ()
set (build_cmds
UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${install_prefix} ${ARGS_OPTS}
BUILD_COMMAND make ${make_opts}
INSTALL_COMMAND make install
)
endif ()
externalproject_add(
${_NAME}
${epa_opts}
PREFIX "${CMAKE_BINARY_DIR}/${_NAME}-build"
BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"
${build_cmds}
)
if (WIN32)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/${_NAME}.dll" PARENT_SCOPE)
if (ARGS_GENERATOR MATCHES "(Unix|MSYS|MinGW) Makefiles")
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
else ()
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/${_NAME}.lib" PARENT_SCOPE)
endif ()
elseif (APPLE)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.dylib" PARENT_SCOPE)
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
elseif (UNIX)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.so" PARENT_SCOPE)
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
else ()
message (FATAL_ERROR "Could not set proper library path for the current platform")
endif ()
endfunction ()
function (cr_link_subproject _TARGET _SUBPROJECT)
if (NOT ${_SUBPROJECT}_SUBPROJECT_EXISTS)
return ()
endif ()
set (options STATIC SHARED)
cmake_parse_arguments (ARGS "${options}" "" "" ${ARGN})
add_dependencies("${_TARGET}" "${_SUBPROJECT}")
if (ARGS_SHARED)
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_SHARED_LIB}")
endif ()
if (ARGS_STATIC)
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_STATIC_LIB}")
endif ()
endfunction ()
include_directories(${CMAKE_BINARY_DIR}/external/include)
link_directories(${CMAKE_BINARY_DIR}/external/lib)

View file

@ -1,23 +1,19 @@
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
if(NOT EXISTS ${MANIFEST})
message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
endif()
file(STRINGS ${MANIFEST} files)
foreach(file ${files})
if(EXISTS ${file})
message(STATUS "Removing file: '${file}'")
exec_program(
${CMAKE_COMMAND} ARGS "-E remove ${file}"
OUTPUT_VARIABLE stdout
RETURN_VALUE result
)
if(NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove file: '${file}'.")
endif()
else()
MESSAGE(STATUS "File '${file}' does not exist.")
endif()
endforeach(file)
message(STATUS "Removing file: '${file}'")
exec_program(
${CMAKE_COMMAND} ARGS "-E remove ${file}"
OUTPUT_VARIABLE stdout
RETURN_VALUE result
)
if (NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove file: '${file}'.")
endif ()
endforeach ()

11
.cmake/copy-source.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
CURDIR=$(dirname $0)
SOURCE_DIR=$1; shift
DEST_DIR=$1; shift
(
cd "$SOURCE_DIR"
mkdir -p "$DEST_DIR"
"$CURDIR/git-archive-all.sh" --format tar -- - | tar -x -C "$DEST_DIR"
)

18
.cmake/cram-env.patch Normal file
View file

@ -0,0 +1,18 @@
--- _test.py.orig 2016-09-03 00:50:27.505527300 +0200
+++ "/c/Program Files/Python35/lib/site-packages/cram/_test.py" 2016-09-03 00:48:48.708932100 +0200
@@ -143,11 +143,15 @@
after.setdefault(pos, []).append(line)
stdin.append(b('echo %s %s $?\n' % (usalt, i + 1)))
+ env = {k: v.decode('utf-8') if isinstance(v, bytes) else v for k, v in env.items()}
+
output, retcode = execute(shell + ['-'], stdin=b('').join(stdin),
stdout=PIPE, stderr=STDOUT, env=env)
if retcode == 80:
return (refout, None, [])
+ output = output.replace(b'\r\n', b'\n').replace(b'\r', b'\n')
+
pos = -1
ret = 0
for i, line in enumerate(output[:-1].splitlines(True)):

39
.cmake/cram-osx.patch Normal file
View file

@ -0,0 +1,39 @@
diff --git a/cram.py b/cram.py
index 20c4681..3b9f144 100755
--- a/cram.py
+++ b/cram.py
@@ -168,14 +168,14 @@ def test(path, shell, indent=2):
cmdline = '%s$ ' % indent
conline = '%s> ' % indent
- f = open(path)
+ f = open(path, 'r', encoding='utf-8')
abspath = os.path.abspath(path)
env = os.environ.copy()
env['TESTDIR'] = os.path.dirname(abspath)
env['TESTFILE'] = os.path.basename(abspath)
p = subprocess.Popen([shell, '-'], bufsize=-1, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- universal_newlines=True, env=env,
+ universal_newlines=False, env=env,
preexec_fn=makeresetsigpipe(),
close_fds=os.name == 'posix')
salt = 'CRAM%s' % time.time()
@@ -199,7 +199,7 @@ def test(path, shell, indent=2):
after.setdefault(pos, []).append(line)
stdin.append('echo "\n%s %s $?"\n' % (salt, i + 1))
- output = p.communicate(input=''.join(stdin))[0]
+ output = p.communicate(input=''.join(stdin).encode('utf-8'))[0].decode('utf-8')
if p.returncode == 80:
return (refout, None, [])
@@ -336,7 +336,7 @@ def run(paths, tmpdir, shell, quiet=False, verbose=False, patchcmd=None,
log('!', 'failed\n', verbose)
if not quiet:
log('\n', None, verbose)
- errfile = open(errpath, 'w')
+ errfile = open(errpath, 'w', encoding='utf-8')
try:
for line in postout:
errfile.write(line)

302
.cmake/git-archive-all.sh Executable file
View file

@ -0,0 +1,302 @@
#!/bin/bash -
#
# File: git-archive-all.sh
#
# Description: A utility script that builds an archive file(s) of all
# git repositories and submodules in the current path.
# Useful for creating a single tarfile of a git super-
# project that contains other submodules.
#
# Examples: Use git-archive-all.sh to create archive distributions
# from git repositories. To use, simply do:
#
# cd $GIT_DIR; git-archive-all.sh
#
# where $GIT_DIR is the root of your git superproject.
#
# License: GPL3+
#
###############################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
###############################################################################
# DEBUGGING
set -e
set -C # noclobber
# TRAP SIGNALS
trap 'cleanup' QUIT EXIT
# For security reasons, explicitly set the internal field separator
# to newline, space, tab
OLD_IFS=$IFS
IFS='
'
function cleanup () {
rm -f $TMPFILE
rm -f $TOARCHIVE
IFS="$OLD_IFS"
}
function usage () {
echo "Usage is as follows:"
echo
echo "$PROGRAM <--version>"
echo " Prints the program version number on a line by itself and exits."
echo
echo "$PROGRAM <--usage|--help|-?>"
echo " Prints this usage output and exits."
echo
echo "$PROGRAM [--format <fmt>] [--prefix <path>] [--verbose|-v] [--separate|-s]"
echo " [--tree-ish|-t <tree-ish>] [output_file]"
echo " Creates an archive for the entire git superproject, and its submodules"
echo " using the passed parameters, described below."
echo
echo " If '--format' is specified, the archive is created with the named"
echo " git archiver backend. Obviously, this must be a backend that git archive"
echo " understands. The format defaults to 'tar' if not specified."
echo
echo " If '--prefix' is specified, the archive's superproject and all submodules"
echo " are created with the <path> prefix named. The default is to not use one."
echo
echo " If '--separate' or '-s' is specified, individual archives will be created"
echo " for each of the superproject itself and its submodules. The default is to"
echo " concatenate individual archives into one larger archive."
echo
echo " If '--tree-ish' is specified, the archive will be created based on whatever"
echo " you define the tree-ish to be. Branch names, commit hash, etc. are acceptable."
echo " Defaults to HEAD if not specified. See git archive's documentation for more"
echo " information on what a tree-ish is."
echo
echo " If 'output_file' is specified, the resulting archive is created as the"
echo " file named. This parameter is essentially a path that must be writeable."
echo " When combined with '--separate' ('-s') this path must refer to a directory."
echo " Without this parameter or when combined with '--separate' the resulting"
echo " archive(s) are named with a dot-separated path of the archived directory and"
echo " a file extension equal to their format (e.g., 'superdir.submodule1dir.tar')."
echo
echo " The special value '-' (single dash) is treated as STDOUT and, when used, the"
echo " --separate option is ignored. Use a double-dash to separate the outfile from"
echo " the value of previous options. For example, to write a .zip file to STDOUT:"
echo
echo " ./$PROGRAM --format zip -- -"
echo
echo " If '--verbose' or '-v' is specified, progress will be printed."
}
function version () {
echo "$PROGRAM version $VERSION"
}
# Internal variables and initializations.
readonly PROGRAM=`basename "$0"`
readonly VERSION=0.3
SEPARATE=0
VERBOSE=0
TARCMD=`command -v gnutar || command -v tar`
FORMAT=tar
PREFIX=
TREEISH=HEAD
# RETURN VALUES/EXIT STATUS CODES
readonly E_BAD_OPTION=254
readonly E_UNKNOWN=255
# Process command-line arguments.
while test $# -gt 0; do
if [ x"$1" == x"--" ]; then
# detect argument termination
shift
break
fi
case $1 in
--format )
shift
FORMAT="$1"
shift
;;
--prefix )
shift
PREFIX="$1"
shift
;;
--separate | -s )
shift
SEPARATE=1
;;
--tree-ish | -t )
shift
TREEISH="$1"
shift
;;
--version )
version
exit
;;
--verbose | -v )
shift
VERBOSE=1
;;
-? | --usage | --help )
usage
exit
;;
-* )
echo "Unrecognized option: $1" >&2
usage
exit $E_BAD_OPTION
;;
* )
break
;;
esac
done
OLD_PWD="`pwd`"
TMPDIR=${TMPDIR:-/tmp}
TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress
TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"`
OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default
if [ ! -z "$1" ]; then
OUT_FILE="$1"
if [ "-" == $OUT_FILE ]; then
SEPARATE=0
fi
shift
fi
# Validate parameters; error early, error often.
if [ "-" == $OUT_FILE -o $SEPARATE -ne 1 ] && [ "$FORMAT" == "tar" -a `$TARCMD --help | grep -q -- "--concatenate"; echo $?` -ne 0 ]; then
echo "Your 'tar' does not support the '--concatenate' option, which we need"
echo "to produce a single tarfile. Either install a compatible tar (such as"
echo "gnutar), or invoke $PROGRAM with the '--separate' option."
exit
elif [ $SEPARATE -eq 1 -a ! -d $OUT_FILE ]; then
echo "When creating multiple archives, your destination must be a directory."
echo "If it's not, you risk being surprised when your files are overwritten."
exit
elif [ `git config -l | grep -q '^core\.bare=false'; echo $?` -ne 0 ]; then
echo "$PROGRAM must be run from a git working copy (i.e., not a bare repository)."
exit
fi
# Create the superproject's git-archive
if [ $VERBOSE -eq 1 ]; then
echo -n "creating superproject archive..."
fi
git archive --format=$FORMAT --prefix="$PREFIX" $TREEISH > $TMPDIR/$(basename "$(pwd)").$FORMAT
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
echo $TMPDIR/$(basename "$(pwd)").$FORMAT >| $TMPFILE # clobber on purpose
superfile=`head -n 1 $TMPFILE`
if [ $VERBOSE -eq 1 ]; then
echo -n "looking for subprojects..."
fi
# find all '.git' dirs, these show us the remaining to-be-archived dirs
# we only want directories that are below the current directory
find . -mindepth 2 -name '.git' -type d -print | sed -e 's/^\.\///' -e 's/\.git$//' >> $TOARCHIVE
# as of version 1.7.8, git places the submodule .git directories under the superprojects .git dir
# the submodules get a .git file that points to their .git dir. we need to find all of these too
find . -mindepth 2 -name '.git' -type f -print | xargs grep -l "gitdir" | sed -e 's/^\.\///' -e 's/\.git$//' >> $TOARCHIVE
if [ $VERBOSE -eq 1 ]; then
echo "done"
echo " found:"
cat $TOARCHIVE | while read arch
do
echo " $arch"
done
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "archiving submodules..."
fi
while read path; do
TREEISH=$(git submodule | grep "^ .*${path%/} " | cut -d ' ' -f 2) # git submodule does not list trailing slashes in $path
cd "$path"
git archive --format=$FORMAT --prefix="${PREFIX}$path" ${TREEISH:-HEAD} > "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT
if [ $FORMAT == 'zip' ]; then
# delete the empty directory entry; zipped submodules won't unzip if we don't do this
zip -d "$(tail -n 1 $TMPFILE)" "${PREFIX}${path%/}" >/dev/null # remove trailing '/'
fi
echo "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT >> $TMPFILE
cd "$OLD_PWD"
done < $TOARCHIVE
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "concatenating archives into single archive..."
fi
# Concatenate archives into a super-archive.
if [ $SEPARATE -eq 0 -o "-" == $OUT_FILE ]; then
if [ $FORMAT == 'tar.gz' ]; then
gunzip $superfile
superfile=${superfile:0: -3} # Remove '.gz'
sed -e '1d' $TMPFILE | while read file; do
gunzip $file
file=${file:0: -3}
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
done
gzip $superfile
superfile=$superfile.gz
elif [ $FORMAT == 'tar' ]; then
sed -e '1d' $TMPFILE | while read file; do
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
done
elif [ $FORMAT == 'zip' ]; then
sed -e '1d' $TMPFILE | while read file; do
# zip incorrectly stores the full path, so cd and then grow
cd `dirname "$file"`
zip -g "$superfile" `basename "$file"` && rm -f "$file"
done
cd "$OLD_PWD"
fi
echo "$superfile" >| $TMPFILE # clobber on purpose
fi
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "moving archive to $OUT_FILE..."
fi
while read file; do
if [ "-" == $OUT_FILE ]; then
cat "$file" && rm -f "$file"
else
mv "$file" "$OUT_FILE"
fi
done < $TMPFILE
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi

229
.cmake/install_python.ps1 Normal file
View file

@ -0,0 +1,229 @@
# Sample script to install Python and pip under Windows
# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
$BASE_URL = "https://www.python.org/ftp/python/"
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
$GET_PIP_PATH = "C:\get-pip.py"
$PYTHON_PRERELEASE_REGEX = @"
(?x)
(?<major>\d+)
\.
(?<minor>\d+)
\.
(?<micro>\d+)
(?<prerelease>[a-z]{1,2}\d+)
"@
function Download ($filename, $url) {
$webclient = New-Object System.Net.WebClient
$basedir = $pwd.Path + "\"
$filepath = $basedir + $filename
if (Test-Path $filename) {
Write-Host "Reusing" $filepath
return $filepath
}
# Download and retry up to 3 times in case of network transient errors.
Write-Host "Downloading" $filename "from" $url
$retry_attempts = 2
for ($i = 0; $i -lt $retry_attempts; $i++) {
try {
$webclient.DownloadFile($url, $filepath)
break
}
Catch [Exception]{
Start-Sleep 1
}
}
if (Test-Path $filepath) {
Write-Host "File saved at" $filepath
} else {
# Retry once to get the error message if any at the last try
$webclient.DownloadFile($url, $filepath)
}
return $filepath
}
function ParsePythonVersion ($python_version) {
if ($python_version -match $PYTHON_PRERELEASE_REGEX) {
return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,
$matches.prerelease)
}
$version_obj = [version]$python_version
return ($version_obj.major, $version_obj.minor, $version_obj.build, "")
}
function DownloadPython ($python_version, $platform_suffix) {
$major, $minor, $micro, $prerelease = ParsePythonVersion $python_version
if (($major -le 2 -and $micro -eq 0) `
-or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) `
) {
$dir = "$major.$minor"
$python_version = "$major.$minor$prerelease"
} else {
$dir = "$major.$minor.$micro"
}
if ($prerelease) {
if (($major -le 2) `
-or ($major -eq 3 -and $minor -eq 1) `
-or ($major -eq 3 -and $minor -eq 2) `
-or ($major -eq 3 -and $minor -eq 3) `
) {
$dir = "$dir/prev"
}
}
if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) {
$ext = "msi"
if ($platform_suffix) {
$platform_suffix = ".$platform_suffix"
}
} else {
$ext = "exe"
if ($platform_suffix) {
$platform_suffix = "-$platform_suffix"
}
}
$filename = "python-$python_version$platform_suffix.$ext"
$url = "$BASE_URL$dir/$filename"
$filepath = Download $filename $url
return $filepath
}
function InstallPython ($python_version, $architecture, $python_home) {
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
return $false
}
if ($architecture -eq "32") {
$platform_suffix = ""
} else {
$platform_suffix = "amd64"
}
$installer_path = DownloadPython $python_version $platform_suffix
$installer_ext = [System.IO.Path]::GetExtension($installer_path)
Write-Host "Installing $installer_path to $python_home"
$install_log = $python_home + ".log"
if ($installer_ext -eq '.msi') {
InstallPythonMSI $installer_path $python_home $install_log
} else {
InstallPythonEXE $installer_path $python_home $install_log
}
if (Test-Path $python_home) {
Write-Host "Python $python_version ($architecture) installation complete"
} else {
Write-Host "Failed to install Python in $python_home"
Get-Content -Path $install_log
Exit 1
}
}
function InstallPythonEXE ($exepath, $python_home, $install_log) {
$install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home"
RunCommand $exepath $install_args
}
function InstallPythonMSI ($msipath, $python_home, $install_log) {
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
$uninstall_args = "/qn /x $msipath"
RunCommand "msiexec.exe" $install_args
if (-not(Test-Path $python_home)) {
Write-Host "Python seems to be installed else-where, reinstalling."
RunCommand "msiexec.exe" $uninstall_args
RunCommand "msiexec.exe" $install_args
}
}
function RunCommand ($command, $command_args) {
Write-Host $command $command_args
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
}
function InstallPip ($python_home) {
$pip_path = $python_home + "\Scripts\pip.exe"
$python_path = $python_home + "\python.exe"
if (-not(Test-Path $pip_path)) {
Write-Host "Installing pip..."
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
Write-Host "Executing:" $python_path $GET_PIP_PATH
& $python_path $GET_PIP_PATH
} else {
Write-Host "pip already installed."
}
}
function DownloadMiniconda ($python_version, $platform_suffix) {
if ($python_version -eq "3.4") {
$filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"
} else {
$filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"
}
$url = $MINICONDA_URL + $filename
$filepath = Download $filename $url
return $filepath
}
function InstallMiniconda ($python_version, $architecture, $python_home) {
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
return $false
}
if ($architecture -eq "32") {
$platform_suffix = "x86"
} else {
$platform_suffix = "x86_64"
}
$filepath = DownloadMiniconda $python_version $platform_suffix
Write-Host "Installing" $filepath "to" $python_home
$install_log = $python_home + ".log"
$args = "/S /D=$python_home"
Write-Host $filepath $args
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
if (Test-Path $python_home) {
Write-Host "Python $python_version ($architecture) installation complete"
} else {
Write-Host "Failed to install Python in $python_home"
Get-Content -Path $install_log
Exit 1
}
}
function InstallMinicondaPip ($python_home) {
$pip_path = $python_home + "\Scripts\pip.exe"
$conda_path = $python_home + "\Scripts\conda.exe"
if (-not(Test-Path $pip_path)) {
Write-Host "Installing pip..."
$args = "install --yes pip"
Write-Host $conda_path $args
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
} else {
Write-Host "pip already installed."
}
}
function main () {
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
InstallPip $env:PYTHON
}
main

View file

@ -0,0 +1,48 @@
#!/bin/sh
# Provide the canonicalize filename (physical filename with out any symlinks)
# like the GNU version readlink with the -f option regardless of the version of
# readlink (GNU or BSD).
# This file is part of a set of unofficial pre-commit hooks available
# at github.
# Link: https://github.com/githubbrowser/Pre-commit-hooks
# Contact: David Martin, david.martin.mailbox@googlemail.com
###########################################################
# There should be no need to change anything below this line.
# Canonicalize by recursively following every symlink in every component of the
# specified filename. This should reproduce the results of the GNU version of
# readlink with the -f option.
#
# Reference: http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
canonicalize_filename () {
local target_file="$1"
local physical_directory=""
local result=""
# Need to restore the working directory after work.
local working_dir="`pwd`"
cd -- "$(dirname -- "$target_file")"
target_file="$(basename -- "$target_file")"
# Iterate down a (possible) chain of symlinks
while [ -L "$target_file" ]
do
target_file="$(readlink -- "$target_file")"
cd -- "$(dirname -- "$target_file")"
target_file="$(basename -- "$target_file")"
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
physical_directory="`pwd -P`"
result="$physical_directory/$target_file"
# restore the working directory after work.
cd -- "$working_dir"
echo "$result"
}

4
.githooks/install.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
rm -Rf .git/hooks
ln -s ../.githooks .git/hooks

171
.githooks/pre-commit Executable file
View file

@ -0,0 +1,171 @@
#!/bin/sh
# git pre-commit hook that runs an Uncrustify stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
#
# More info on Uncrustify: http://uncrustify.sourceforge.net/
# This file is part of a set of unofficial pre-commit hooks available
# at github.
# Link: https://github.com/githubbrowser/Pre-commit-hooks
# Contact: David Martin, david.martin.mailbox@googlemail.com
##################################################################
# CONFIGURATION
# set uncrustify path or executable
# UNCRUSTIFY="/usr/bin/uncrustify"
UNCRUSTIFY="uncrustify"
# set uncrustify config location
# CONFIG="/home/user/.config/uncrustify.cfg"
CONFIG=".uncrustify.cfg"
# the source language: C, CPP, D, CS, JAVA, PAWN, VALA, OC, OC+
# use AUTO to let Uncrustify decide which language a given file uses.
# the detected language is printed to the console when Uncrustify is called.
# override if the automatic detection seems off.
# SOURCE_LANGUAGE="AUTO"
SOURCE_LANGUAGE="AUTO"
# remove any older patches from previous commits. Set to true or false.
# DELETE_OLD_PATCHES=false
DELETE_OLD_PATCHES=false
# only parse files with the extensions in FILE_EXTS. Set to true or false.
# if false every changed file in the commit will be parsed with Uncrustify.
# if true only files matching one of the extensions are parsed with Uncrustify.
# PARSE_EXTS=true
PARSE_EXTS=true
# file types to parse. Only effective when PARSE_EXTS is true.
# FILE_EXTS=".c .h .cpp .hpp"
FILE_EXTS=".c .h .cc .hh .cpp .hpp .hxx"
##################################################################
# There should be no need to change anything below this line.
. "$(dirname -- "$0")/canonicalize_filename.sh"
# exit on error
set -e
# check whether the given file matches any of the set extensions
matches_extension() {
local filename="$(basename -- "$1")"
local extension=".${filename##*.}"
local ext
for ext in $FILE_EXTS; do [ "$ext" = "$extension" ] && return 0; done
return 1
}
# necessary check for initial commit
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# make sure the config file and executable are correctly set
if [ ! -f "$CONFIG" ] ; then
printf "Error: uncrustify config file not found.\n"
printf "Set the correct path in $(canonicalize_filename "$0").\n"
exit 1
fi
if ! command -v "$UNCRUSTIFY" > /dev/null ; then
printf "Error: uncrustify executable not found.\n"
printf "Set the correct path in $(canonicalize_filename "$0").\n"
exit 1
fi
# create a filename to store our generated patch
prefix="pre-commit-uncrustify"
suffix="$(date +%C%y-%m-%d_%Hh%Mm%Ss)"
patch="/tmp/$prefix-$suffix.patch"
diff="/tmp/$prefix-$suffix.diff"
# clean up any older uncrustify patches
$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch
# create one patch containing all changes to the files
# sed to remove quotes around the filename, if inserted by the system
# (done sometimes, if the filename contains special characters, like the quote itself)
git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
sed -e 's/^"\(.*\)"$/\1/' | \
while read file
do
# ignore file if we do check for file extensions and the file
# does not match any of the extensions specified in $FILE_EXTS
if $PARSE_EXTS && ! matches_extension "$file"; then
continue;
fi
# escape special characters in the source filename:
# - '\': backslash needs to be escaped
# - '*': used as matching string => '*' would mean expansion
# (curiously, '?' must not be escaped)
# - '[': used as matching string => '[' would mean start of set
# - '|': used as sed split char instead of '/', so it needs to be escaped
# in the filename
# printf %s particularly important if the filename contains the % character
file_escaped_source=$(printf "%s" "$file" | sed -e 's/[\*[|]/\\&/g')
# escape special characters in the target filename:
# phase 1 (characters escaped in the output diff):
# - '\': backslash needs to be escaped in the output diff
# - '"': quote needs to be escaped in the output diff if present inside
# of the filename, as it used to bracket the entire filename part
# phase 2 (characters escaped in the match replacement):
# - '\': backslash needs to be escaped again for sed itself
# (i.e. double escaping after phase 1)
# - '&': would expand to matched string
# - '|': used as sed split char instead of '/'
# printf %s particularly important if the filename contains the % character
file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
# Uncrustify detects the language automatically if it is not specified
language_option=""
if [ "$SOURCE_LANGUAGE" != "AUTO" ] ; then
language_option="-l $SOURCE_LANGUAGE"
fi
# uncrustify our sourcefile, create a patch with diff and append it to our $patch
# The sed call is necessary to transform the patch from
# --- $file timestamp
# +++ - timestamp
# to both lines working on the same file and having a a/ and b/ prefix.
# Else it can not be applied with 'git apply'.
"$UNCRUSTIFY" -q -c "$CONFIG" -f "$file" $language_option | \
git --no-pager diff --color=always --no-index -- "$file" - | \
tail -n +3 | \
sed -e "1s|--- a/$file_escaped_source|--- \"a/$file_escaped_target\"|" \
-e "2s|+++ b/-|+++ \"b/$file_escaped_target\"|" | \
tee -a "$diff" | \
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" >> "$patch"
done
# if no patch has been generated all is ok, clean up the file stub and exit
if [ ! -s "$patch" ] ; then
printf "Files in this commit comply with the uncrustify rules.\n"
rm -f "$patch"
exit 0
fi
# a patch has been created, notify the user and exit
printf "\nThe following differences were found between the code to commit "
printf "and the uncrustify rules:\n\n"
cat "$diff"
rm -f "$diff"
printf "\nYou can apply these changes with:\n git apply $patch\n"
printf "(may need to be called from the root directory of your repository)\n"
printf "Aborting commit. Apply changes and commit again or skip checking with"
printf " --no-verify (not recommended).\n"
exit 1

4
.gitignore vendored
View file

@ -17,7 +17,9 @@
!*.rst
!*.po
!*.in
!.cmake/*.cmake
!*.t
!*.proto
!.cmake/Modules/*.cmake
!samples/tests/*.sh
!samples/**/*.expected

12
.gitmodules vendored
View file

@ -10,3 +10,15 @@
[submodule "dependencies/klib"]
path = dependencies/klib
url = https://github.com/attractivechaos/klib.git
[submodule "dependencies/nanopb"]
path = dependencies/nanopb
url = https://github.com/nanopb/nanopb.git
[submodule "dependencies/nanomsg"]
path = dependencies/nanomsg
url = https://github.com/nanomsg/nanomsg.git
[submodule "dependencies/debugbreak"]
path = dependencies/debugbreak
url = https://github.com/scottt/debugbreak
[submodule "dependencies/boxfort"]
path = dependencies/boxfort
url = https://github.com/Snaipe/BoxFort

View file

@ -2,47 +2,89 @@ language: c
sudo: false
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
- gobjc-4.9
- gnustep-devel
_anchors:
- &gcc49-packages
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
- gobjc-4.9
- gnustep-devel
matrix:
include:
# Style check
- compiler: uncrustify
language: cpp
before_install:
- if [[ "$TRAVIS_PULL_REQUEST" == false ]]; then exit 0; fi
- |
git clone https://github.com/uncrustify/uncrustify /tmp/uncrustify &&
pushd /tmp/uncrustify &&
git checkout -q 7ae7af9d3483f5f92766ec41bb3ba3efe4747494 &&
mkdir build && cd build &&
CC=gcc CXX=g++ cmake -DCMAKE_INSTALL_PREFIX=$HOME .. &&
make -j4 && make install &&
export PATH="$PATH:$HOME/bin" &&
popd
- >
export SOURCES=$(find src include test samples \( \
-type f \( \
-iname "*.c" -or \
-iname "*.h" -or \
-iname "*.cc" -or \
-iname "*.hxx" \
\) -and -not \
-iname "*.pb.*" \))
- export STYLE_OK=true
script:
- >
for f in $SOURCES; do
if ! uncrustify -q --check -c .uncrustify.cfg $f; then
uncrustify -q -c .uncrustify.cfg -f $f | git --no-pager diff --no-index --color=always $f -
export STYLE_OK=false
fi
done
- $STYLE_OK
after_success:
- echo "Style check passed."
# Linux Debug, GCC 4.9
- compiler: gcc-4.9
addons: *gcc49-packages
env:
CONFIGURATION: Debug
GCOV: gcov-4.9
CMAKE_OPTS: -DLANG_OBJC=ON
COVERAGE: ON
# Linux Release, GCC 4.9
- compiler: gcc-4.9
env:
CONFIGURATION: Release
CMAKE_OPTS: -DLANG_OBJC=ON
COVERAGE: "ON"
# Linux RelWithDebInfo, GCC 4.9
- compiler: gcc-4.9
addons: *gcc49-packages
env:
CONFIGURATION: RelWithDebInfo
CMAKE_OPTS: -DLANG_OBJC=ON
DEPLOY: true
# Linux Debug, GCC 4.6
- compiler: gcc
env: CONFIGURATION=Debug TESTS=OFF
# Linux RelWithDebInfo, GCC 4.6
- compiler: gcc
env:
- CONFIGURATION=RelWithDebInfo
- TESTS=OFF
# Coverity token
- secure: >-
n6BHG86ISeYSAVE/i7m1K+XVW0j8PrJ5JxoJwhAGBb1
hkCn9sWybGo1HzZsf7rxpkQh/5Va4i+eyOrUt7VWAuF
EJN2+mEWqERkWZxiXrS3N9xi74cPFI79eDOTFnPm13e
diUX8Ts+IuFy890+tsNHqkEn055l6yOVMtj1LWWtRs=
# OSX Debug, GCC 4.9
- os: osx
compiler: gcc-4.9
env:
CONFIGURATION: Debug
GCOV: gcov-4.9
COVERAGE: ON
# OSX Release, GCC 4.9
- os: osx
compiler: gcc-4.9
env: CONFIGURATION=Release
COVERAGE: "ON"
# OSX RelWithDebInfo, GCC 4.9
- os: osx
compiler: gcc-4.9
@ -52,27 +94,23 @@ matrix:
compiler: clang
env:
CONFIGURATION: Debug
CMAKE_OPTS: -DLANG_OBJC=ON
# OSX Release, Clang
- os: osx
compiler: clang
env:
CONFIGURATION: Release
CMAKE_OPTS: -DLANG_OBJC=ON
# OSX RelWithDebInfo, Clang
- os: osx
compiler: clang
env:
CONFIGURATION: RelWithDebInfo
CMAKE_OPTS: -DLANG_OBJC=ON
DEPLOY: true
allow_failures:
- compiler: gcc
before_install:
- |
if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "clang" ]; then
brew update
brew unlink cmake
brew install llvm cmake
if [ "${TESTS:-ON}" = "ON" ]; then
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export PATH="$(python -m site --user-base)/bin:$PATH"
fi
travis_retry pip install --user cram==0.7
fi
- export CXX=${CC/gcc/g++}; export CXX=${CXX/clang/clang++}
- $CC --version
@ -83,14 +121,19 @@ script:
- >
cmake
-Wno-dev
-DCTESTS=ON
-DCTESTS=${TESTS:-ON}
-DCOVERALLS=${COVERAGE:-OFF}
-DCMAKE_BUILD_TYPE=${CONFIGURATION}
-DCMAKE_INSTALL_PREFIX=criterion-${TRAVIS_TAG}
${CMAKE_OPTS}
..
- TERM=dumb cmake --build . --target criterion_tests -- -j4
- ctest -j4
- |
if [ "${TESTS:-ON}" = "ON" ]; then
TERM=dumb cmake --build . --target criterion_tests -- -j4
ctest --output-on-failure -j4 --timeout=20
else
TERM=dumb cmake --build . -- -j4
fi
after_success:
- |
@ -99,19 +142,30 @@ after_success:
bash <(curl -s https://codecov.io/bash)
fi
after_failure:
- cat Testing/Temporary/LastTest.log samples/*.{out,err} ../samples/tests/*.{out,err}
before_deploy:
- make install
- tar -cvjf criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 criterion-${TRAVIS_TAG}
- cd ..
- ./.cmake/git-archive-all.sh --prefix criterion-${TRAVIS_TAG} criterion-${TRAVIS_TAG}.tar && bzip2 $_
addons:
coverity_scan:
project:
name: "Snaipe/Criterion"
description: "A KISS, Cross-platform C unit testing framework"
notification_email: franklinmathieu@gmail.com
build_command_prepend: "cmake ."
build_command: "make -j4"
branch_pattern: coverity_scan
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: d3l2Ohb2FF3tSXku1d0ASR5dntdnQ48Jyc39IEloDBxFXCselCkYruUQv6p0TA3P+Dmrz4wS7/AFlBMMsQ3XfGFVIOnITiTaGWg5fEpIf7zYsDf0zECPE0MOHMGqJMn3/SrSKdtEA4N84Q4JS7Ou+ewG65mxUDO5Ce60OoEG5JA=
file: criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2
file:
- criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2
- criterion-${TRAVIS_TAG}.tar.bz2
on:
repo: Snaipe/Criterion
tags: true

239
.uncrustify.cfg Normal file
View file

@ -0,0 +1,239 @@
#
# uncrustify config file (initially based on the linux kernel coding style)
#
input_tab_size = 4 # original tab size
output_tab_size = 4 # new tab size
newlines = lf # \n
utf8_force = true
utf8_bom = remove
# Indent
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
indent_columns = 4 # indents are 4 cols
indent_continue = 8 # line continuations are indented by 8 columns
indent_label = -4 # pos: absolute col, neg: relative column
indent_xml_string = 2 # embedded XML indents are 2 cols
indent_ctor_init = 4 # indent c++ ctor initializer list
indent_switch_case = 4 # indent 'case' inside switch statements
indent_namespace = false
indent_extern = false
indent_class = false
indent_class_colon = true
indent_access_spec_body = true
# Newlines
nl_max = 2 # no duplicate blank lines
nl_func_paren = remove # "int foo()" vs "int foo\n()"
nl_func_decl_start = ignore
nl_func_decl_empty = remove
nl_func_decl_args = ignore
nl_func_decl_end = remove
nl_enum_brace = remove # "enum {" vs "enum \n {"
nl_union_brace = remove # "union {" vs "union \n {"
nl_struct_brace = remove # "struct {" vs "struct \n {"
nl_do_brace = remove # "do {" vs "do \n {"
nl_if_brace = remove # "if () {" vs "if () \n {"
nl_for_brace = remove # "for () {" vs "for () \n {"
nl_else_brace = remove # "else {" vs "else \n {"
nl_while_brace = remove # "while () {" vs "while () \n {"
nl_switch_brace = remove # "switch () {" vs "switch () \n {"
nl_brace_while = remove # "} while" vs "} \n while" - cuddle while
nl_brace_else = remove # "} else" vs "} \n else" - cuddle else
nl_namespace_brace = force # "namespace name {" vs "namespace name \n {"
nl_func_var_def_blk = 1
nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{"
nl_fdef_brace = add # "int foo() {" vs "int foo()\n{"
nl_after_label_colon = false # "fail:\nfree(foo);" vs "fail: free(foo);"
nl_start_of_file = remove
nl_end_of_file = force
nl_end_of_file_min = 1
nl_comment_func_def = 1
nl_assign_leave_one_liners = true
nl_class_leave_one_liners = true
nl_enum_leave_one_liners = true
nl_getset_leave_one_liners = true
nl_func_leave_one_liners = true
nl_cpp_lambda_leave_one_liners = true
nl_while_leave_one_liners = false
nl_if_leave_one_liners = false
nl_multi_line_define = true
nl_func_call_start_multi_line = false
nl_func_call_end_multi_line = false
# Source code modifications
mod_paren_on_return = remove # "return 1;" vs "return (1);"
mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }"
mod_full_brace_if_chain = true
mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }"
mod_full_brace_do = force # "do a--; while ();" vs "do { a--; } while ();"
mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }"
mod_full_brace_nl = 3 # don't remove if more than 3 newlines
# Spacing
sp_addr = remove
sp_after_angle = force
sp_after_byref = remove
sp_after_byref_func = remove
sp_after_cast = force # "(int) a" vs "(int)a"
sp_after_class_colon = force
sp_after_comma = force
sp_after_dc = remove
sp_after_new = force
sp_after_operator = remove
sp_after_operator_sym = remove
sp_after_ptr_star = remove # "int *foo" vs "int * foo"
sp_after_ptr_star_func = remove
sp_after_semi = force
sp_after_semi_for = force
sp_after_semi_for_empty = remove
sp_after_sparen = force # "if () {" vs "if (){"
sp_after_type = force
sp_angle_paren = remove
sp_angle_shift = ignore
sp_angle_word = force
sp_arith = force
sp_assign = add
sp_assign_default = force
sp_attribute_paren = remove
sp_balance_nested_parens = false
sp_before_angle = remove
sp_before_byref = force
sp_before_byref_func = force
sp_before_case_colon = remove
sp_before_class_colon = force
sp_before_comma = remove
sp_before_dc = remove
sp_before_ellipsis = remove
sp_before_nl_cont = force
sp_before_ptr_star = force # "int*" vs "int *"
sp_before_ptr_star_func = force
sp_before_semi = remove
sp_before_semi_for = remove
sp_before_semi_for_empty = remove
sp_before_sparen = force # "if (" vs "if("
sp_before_square = remove
sp_before_tr_emb_cmt = force
sp_before_unnamed_byref = force
sp_between_ptr_star = remove # "int **" vs "int * *"
sp_bool = force
sp_brace_catch = force
sp_brace_else = force # "}else" vs "} else"
sp_brace_finally = force
sp_brace_typedef = force
sp_case_label = force
sp_catch_brace = force
sp_catch_paren = force
sp_cmt_cpp_start = force
sp_compare = force
sp_cond_colon = add
sp_cond_question = add
sp_cpp_cast_paren = force
sp_defined_paren = force
sp_deref = remove
sp_else_brace = force # "else{" vs "else {"
sp_endif_cmt = force
sp_enum_assign = force
sp_finally_brace = force
sp_fparen_brace = force
sp_func_call_paren = remove # "foo (" vs "foo("
sp_func_call_user_paren = remove
sp_func_class_paren = remove
sp_func_def_paren = remove # "int foo (){" vs "int foo(){"
sp_func_proto_paren = remove # "int foo ();" vs "int foo();"
sp_getset_brace = force
sp_incdec = remove
sp_inside_angle = remove
sp_inside_braces = force # "{ 1 }" vs "{1}"
sp_inside_braces_empty = remove
sp_inside_braces_enum = force # "{ 1 }" vs "{1}"
sp_inside_braces_struct = force # "{ 1 }" vs "{1}"
sp_inside_fparen = remove
sp_inside_fparens = remove
sp_inside_paren = remove
sp_inside_paren_cast = remove
sp_inside_sparen = remove
sp_inside_square = remove
sp_inv = remove
sp_macro = force
sp_macro_func = force
sp_member = remove
sp_not = remove
sp_num_before_tr_emb_cmt = 1
sp_paren_brace = force
sp_paren_comma = ignore
sp_paren_paren = remove # "((" vs "( ("
sp_pp_concat = force
sp_pp_stringify = remove
sp_return_paren = force # "return (1);" vs "return(1);"
sp_sign = remove
sp_sizeof_paren = force # "sizeof (int)" vs "sizeof(int)"
sp_sparen_brace = force
sp_special_semi = remove
sp_square_fparen = remove
sp_template_angle = add
sp_throw_paren = force
sp_try_brace = force
cmt_sp_before_star_cont = 0
cmt_sp_after_star_cont = 1
# Positioning
pos_arith = lead
pos_assign = trail
pos_bool = lead
pos_compare = lead
pos_conditional = lead
pos_comma = trail
pos_class_comma = trail
pos_class_colon = lead
# Alignment
align_with_tabs = false # use tabs to align
align_on_tabstop = false # align on tabstops
align_enum_equ_span = 4 # '=' in enum definition
align_nl_cont = true
align_assign_span = 0
align_struct_init_span = 3 # align stuff in a structure init '= { }'
align_right_cmt_span = 3
align_pp_define_span = 8
align_pp_define_gap = 4
align_func_params = false
align_var_struct_span = 0
# Comment
cmt_indent_multi = true
cmt_c_group = false
cmt_c_nl_start = false
cmt_c_nl_end = false
cmt_cpp_group = true
cmt_cpp_nl_start = false
cmt_cpp_nl_end = false
cmt_cpp_to_c = true
cmt_star_cont = false
cmt_multi_check_last = true
eat_blanks_after_open_brace = true
eat_blanks_before_close_brace = true
# Preprocessor
pp_indent = remove
pp_space = force
pp_space_count = 1
# Misc
set cpp_cast nonstd # nonstd cast attributes
set compare Op # typical (A) Op (B) macro scenarios
set func_call_user _ N_ # gettext macros
set attribute CR_FORMAT CR_API CR_PURE CR_INLINE

14
AUTHORS Normal file
View file

@ -0,0 +1,14 @@
Maintainer:
* Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
Contributors:
* Adeel "am11" Mujahid <adeelbm@outlook.com>
* Matthias "ailu" Günzel <a1lu@arcor.de>
* Ben "blinskey" Linskey <ben@benlinskey.com>
* "kaidowei" <kaidowei@users.noreply.github.com>
* Howard "hppritcha" Pritchard <howardp@lanl.gov>
* Kevin "kevinoid" Locke <kevin@kevinlocke.name>
* László "MrAnno" Várady <laszlo.varady@balabit.com>
* "offa" <bm-dev@yandex.com>

View file

@ -1,279 +1,149 @@
cmake_minimum_required(VERSION 2.8)
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
project(Criterion C)
cmake_minimum_required (VERSION 2.8)
set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
set(LIBCSPTR_DISABLE_TESTS ON)
set(LIBCSPTR_DISABLE_COVERALLS ON)
project (Criterion C)
include(Submodules)
include(Capabilities)
set (MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
if (POLICY CMP0054)
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
# This is here to allow conditions to be passed as function parameters
cmake_policy (SET CMP0054 OLD)
endif ()
add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)
add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
# Initialization
include_directories(SYSTEM
/usr/local/include
/usr/include/GNUstep
include (Options)
include (Submodules)
include (Capabilities)
include (Subprojects)
include (PackageUtils)
if (NOT WIN32)
set (PIC_C_FLAGS "-fPIC")
set (VISI_C_FLAGS "-fvisibility=hidden")
else ()
set (PIC_C_FLAGS "")
set (VISI_C_FLAGS "")
endif ()
cr_add_subproject (csptr PATH dependencies/libcsptr
OPTS
-DLIBCSPTR_TESTS=OFF
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE)
cr_add_subproject (dyncall_s PATH dependencies/dyncall
OPTS
-DLANG_CXX=${LANG_CXX}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE IF THEORIES)
cr_add_subproject (nanomsg
PATH dependencies/nanomsg
OPTS
-DNN_TESTS=OFF
-DNN_TOOLS=OFF
-DNN_STATIC_LIB=ON
-DCMAKE_INSTALL_LIBDIR=lib
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE
)
cr_add_subproject (boxfort PATH dependencies/boxfort
OPTS
-DBXF_TESTS=OFF
-DBXF_SAMPLES=OFF
-DBXF_STATIC_LIB=ON
-DBXF_FORK_RESILIENCE=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE)
add_definitions(-DBXF_STATIC_LIB -DNN_STATIC_LIB)
cr_add_subproject (wingetopt PATH dependencies/wingetopt CMAKE IF MSVC)
include (Properties)
add_definitions (-DNN_STATIC_LIB)
include_directories(
dependencies/libcsptr/include/
dependencies/dyncall/dyncall/
dependencies/valgrind/include/
dependencies/klib/
dependencies/nanopb/
dependencies/debugbreak/
)
if (MSVC)
add_subdirectory(dependencies/wingetopt/ EXCLUDE_FROM_ALL)
include_directories(dependencies/wingetopt/src/)
endif ()
# Language support
include(Languages)
# Project setup & environment variables
set(PROJECT_VERSION "2.1.0")
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
set(GettextTranslate_ALL 1)
set(GettextTranslate_GMO_BINARY 1)
add_definitions(-DCRITERION_BUILDING_DLL=1)
set(CMAKE_C_FLAGS_DEFAULT "${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS_DEFAULT "${CMAKE_CXX_FLAGS}")
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
if (CMAKE_CXX_COMPILER_WORKS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g -std=c++11")
endif ()
endif ()
if (MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
endif ()
if (WIN32 AND NOT MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
endif()
# Compilation options
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
# Setup coveralls
option(COVERALLS "Turn on coveralls support" OFF)
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
option(DEV_BUILD "Compile in developer mode" OFF)
option(CTESTS "Turn on the samples and test" ${DEV_BUILD})
if (DEV_BUILD)
set(ENABLE_VALGRIND_ERRORS 1)
endif ()
# Coverage
if (COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
# Find dependencies
# I18N
option(I18N "Turn on internationalization" ON)
if (I18N)
find_package(Gettext)
find_package(Libintl)
if (GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
include(GettextTranslate)
add_subdirectory(po)
set(ENABLE_NLS 1)
endif ()
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
include(GettextTranslate)
add_subdirectory(po)
endif ()
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
find_package(PCRE)
# List sources and headers
set(SOURCE_FILES
src/core/wrappers/wrap.h
src/core/wrappers/wrap.c
src/core/wrappers/wrappers.c
src/core/abort.c
src/core/abort.h
src/core/report.c
src/core/report.h
src/core/runner.c
src/core/runner.h
src/core/runner_coroutine.c
src/core/runner_coroutine.h
src/core/coroutine.h
src/core/worker.c
src/core/worker.h
src/core/stats.c
src/core/stats.h
src/core/ordered-set.c
src/core/theories.c
src/compat/internal.h
src/compat/pipe.c
src/compat/pipe.h
src/compat/pipe-internal.h
src/compat/section.c
src/compat/section.h
src/compat/process.c
src/compat/process.h
src/compat/basename.c
src/compat/basename.h
src/compat/mockfile.c
src/compat/time.c
src/compat/time.h
src/compat/posix.h
src/compat/alloc.c
src/compat/alloc.h
src/compat/processor.c
src/compat/processor.h
src/io/redirect.c
src/io/event.c
src/io/event.h
src/io/asprintf.c
src/io/file.c
src/io/output.c
src/io/output.h
src/io/tap.c
src/io/xml.c
src/io/json.c
src/log/logging.c
src/log/normal.c
src/string/i18n.c
src/string/i18n.h
src/entry/options.c
src/entry/main.c
src/entry/entry.c
src/common.h
src/config.h
)
if (PCRE_FOUND)
set (SOURCE_FILES ${SOURCE_FILES}
src/string/extmatch.c
src/string/extmatch.h
)
set(HAVE_PCRE 1)
endif ()
if (CMAKE_CXX_COMPILER_WORKS)
set(SOURCE_FILES ${SOURCE_FILES} src/core/wrappers/wrap.cc)
endif ()
if (CMAKE_ObjectiveC_COMPILER_WORKS)
set(CMAKE_ObjectiveC_FLAGS "${CMAKE_ObjectiveC_FLAGS} ${CMAKE_C_FLAGS} -fobjc-exceptions")
if ("${CMAKE_ObjectiveC_COMPILER_ID}" STREQUAL "Clang" AND APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -framework Foundation")
endif ()
add_definitions(-D_NATIVE_OBJC_EXCEPTIONS)
if (NOT WIN32)
set(CMAKE_ObjectiveC_FLAGS "${CMAKE_ObjectiveC_FLAGS} -fPIC")
endif ()
set(SOURCE_FILES ${SOURCE_FILES} src/core/wrappers/wrap.m)
endif ()
set(INTERFACE_FILES
include/criterion/assert.h
include/criterion/abort.h
include/criterion/criterion.h
include/criterion/event.h
include/criterion/hooks.h
include/criterion/logging.h
include/criterion/types.h
include/criterion/options.h
include/criterion/stats.h
include/criterion/theories.h
include/criterion/alloc.h
include/criterion/parameterized.h
include/criterion/redirect.h
include/criterion/output.h
include/criterion/internal/assert.h
include/criterion/internal/test.h
include/criterion/internal/common.h
include/criterion/internal/ordered-set.h
include/criterion/internal/asprintf-compat.h
include/criterion/internal/designated-initializer-compat.h
include/criterion/internal/preprocess.h
include/criterion/internal/theories.h
include/criterion/internal/parameterized.h
include/criterion/internal/stdio_filebuf.hxx
include/criterion/internal/stream.hxx
include/criterion/internal/hooks.h
include/criterion/internal/redirect.h
include/criterion/internal/stdio_filebuf.hxx
)
# Generate the configure file
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h"
)
# Project
include_directories(include src)
add_library(criterion SHARED ${SOURCE_FILES} ${INTERFACE_FILES})
target_link_libraries(criterion csptr dyncall_s)
add_subdirectory (src)
if (MSVC)
target_link_libraries(criterion wingetopt)
endif ()
cr_add_library(criterion SHARED
SOURCES ${SOURCE_FILES}
HEADERS ${INTERFACE_FILES}
COMPONENT dev
PROPERTIES
VERSION ${PROJECT_SONAME}
SOVERSION ${PROJECT_SOVERSION}
)
if (HAVE_CLOCK_GETTIME)
target_link_libraries(criterion rt)
endif()
cr_link_subproject(criterion csptr STATIC)
cr_link_subproject(criterion nanomsg STATIC)
cr_link_subproject(criterion dyncall_s STATIC)
cr_link_subproject(criterion wingetopt STATIC)
cr_link_subproject(criterion boxfort STATIC)
if (PCRE_FOUND)
target_link_libraries(criterion ${PCRE_LIBRARIES})
endif()
cr_link_libraries(criterion pthread IF NOT WIN32)
cr_link_libraries(criterion rt IF HAVE_LIBRT)
if (LIBINTL_LIB_FOUND)
target_link_libraries(criterion ${LIBINTL_LIBRARIES})
include_directories(${LIBINTL_INCLUDE_DIR})
endif()
# Required by nanomsg
cr_link_libraries(criterion anl IF HAVE_GETADDRINFO_A)
cr_link_libraries(criterion ws2_32 mswsock IF WIN32)
cr_link_package(criterion LIBINTL)
if (COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
endif()
foreach (F ${INTERFACE_FILES})
get_filename_component(DEST "${F}" PATH)
install(FILES "${F}" DESTINATION "${DEST}")
endforeach ()
install(TARGETS criterion
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
add_custom_target(criterion_tests)
add_custom_target(gcov
add_custom_target(gcov
"${CMAKE_COMMAND}"
-DSOURCE_FILES="${SOURCE_FILES}"
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
)
endif()
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
)
if (CTESTS)
enable_testing()
add_subdirectory(samples)
add_subdirectory(test)
enable_testing()
add_custom_target(criterion_tests)
add_subdirectory(samples)
add_subdirectory(test)
endif ()
if (UPLOAD_DEB)
include (DebUpload)
endif ()

View file

@ -7,18 +7,39 @@ be merged.
## General
* Use 4 (four) spaces for indentation.
* No trailing whitespaces.
* 80 chars column limit.
* Try to respect a 80 chars column limit. Not mandatory, but appreciated.
* No trash files. Trash files are by-products of the compilation process, or
generated files that does not need to be under version control.
* Pull requests must pass the style check. See "Passing the style check" section below.
* Pull requests must compile and work properly.
* Pull requests must pass all tests.
* Pull requests must be mergeable automatically.
* Pull requests must be mergeable without conflicts.
* Number of commits in a pull request should be kept to one commit and all
additional commits must be squashed.
* You may have more than one commit in a pull request if the commits are
separate changes, otherwise squash them.
* Keep your commit messages simple and concise. Good commit messages start
with a verb ('Add', 'Fix', ...).
* Commit messages should follow the format `topic: message`, e.g. `cli: Added --foo flag`.
In cases where multiple topics are relevant, use a comma-separated list of topics, e.g.
`api,float: Fixed printf format specifiers for long double`
## Passing the style check
This project use an automated style checking process for pull requests defined as
an uncrustify configuration file named `.uncrustify.cfg`.
To ease the development process, a pre-commit hook is installable by running
`.githooks/install.sh` from the project root directory. This pre-commit hook
checks for style, outputs a diff of the changes that need to be done, and
produces a patch to fix them automatically.
As the automatic style checker is bound to have errors, parts of the code
that make the checker fail because of their tricky grammar (e.g. Duff devices)
may be enclosed by `/* *INDENT-OFF* */` and `/* *INDENT-ON* */` to disable
the style checker on the region. Note that this feature should be used
*exceptionally*, and that the maintainer will always have the last word regarding
stylistic choices that cannot pass the style check.
## Translations

View file

@ -1,3 +1,97 @@
2018-09-18 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.3.0
* Addition: added German translation files (Matthias "ailu" Günzel).
* Addition: added a pkg-config file.
* Addition: allow tests to be skipped with cr_skip_test() (Matthias "ailu" Günzel).
* Addition: assertions on wide-strings are now available (Kevin "kevinoid" Locke).
* Addition: crash-mode with --crash to raise a trap when an assertion fails for debugging purposes (Matthias "ailu" Günzel).
* Addition: debugging mode with --debug.
* Addition: global test timeout with --timeout.
* Addition: header files in the public API now have doxygen documentation (Matthias "ailu" Günzel).
* Addition: test filtering now works on windows.
* Addition: user logging API with cr_log, cr_log_info, cr_log_warning, and cr_log_error.
* Breaking: dropped support for MinGW, use MinGW-w64.
* Breaking: dropped support for Windows XP, use Windows 7 and later.
* Breaking: log_pre_init and log_pre_test in the internal logger API now takes an additional parameter.
* Breaking: the SOVERSION now follows the SONAME major independently of the project version.
* Change: --pattern has been renamed to --filter.
* Change: removed dependency on PCRE for filtering (Matthias "ailu" Günzel).
* Change: sections of all loaded shared modules are now inspected for tests and hooks.
* Change: setting .exit_code = 0 now enforces the exit code of the test to be 0.
* Change: string assertions now print the contents of string parameters ("kaidowei").
* Change: tests are no longer executed in parallel on windows by default to mitigate a nanomsg bug (see https://github.com/Snaipe/Criterion/issues/118).
* Change: xml reports now includes elapsed times ("kaidowei").
* Deprecation: --no-early-exit is now a no-op and should no longer be used.
* Deprecation: internal logging API is no longer public, fallbacks to the new logging API.
* Fix: fail-fast now works correctly.
* Fix: fixed FindCriterion.cmake with the correct package name (László "MrAnno" Várady).
* Fix: position-independent executables now work.
* Fix: string assertions no longer crash with a NULL parameter ("kaidowei").
* Fix: the data pipe no longer gets corrupted when running a large quantity of assertions in parallel.
* Fix: using dmalloc on tests now works.
* Fix: using the GOLD linker rather than BFD now works.
* Fix: using the musl C library now works.
2016-06-20 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.2
* Fix: fixed deadlocks when tests are terminated too fast
* Fix: fixed crash during test teardown if spawning new threads in the test
* Fix: fixed memory leak in disabled tests
2016-02-06 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.1
* Fix: fixed criterion not being embeddable with CMake's `add_directory`
* Fix: fixed resource leaks in the child pump thread
* Fix: fixed redirected standard streams being leaked by cr_(assert|expect)_std(out|err)
* Fix: fixed out of bounds during assert message sending
* Fix: fixed naming convention conflicts for internal variables used by the implementation of cr_assert
* Fix: fixed empty format string warning with GCC 4.8
* Fix: fixed file-to-file comparison assert message being corrupted
2015-12-08 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.0
* Breaking: Renamed all unprefixed internal macros and functions that were
exposed in the API, and moved them to criterion/internal.
This shouldn't break your code if you did not use these in the first
place.
* Change: Added language-specific wrapping logic to decouple the language
the tests are written in from the test runner.
* Change: Rewrote the reporting logic to allow multiple test reports to be
written using any format.
* Addition: Added parallel jobs for the test runner.
* Addition: Added C++ allocator for STL collections based on
cr_malloc/cr_free.
* Addition: Added criterion::parameters in C++ for simpler parameter list
generation.
* Addition: Added saner defaults when the tests detect they run under
valgrind.
* Addition: Added basic Objective-C language support.
* Addition: Added JUnit XML reporting.
* Addition: Added JSON reporting.
* Addition: Added dynamic reporter registration.
* Addition: Added back support for GCC 4.6 when compiling C tests.
* Addition: Added single test execution mode.
* Removal: Removed all deprecated 1.x unprefixed assertion macros.
* Fix: Fixed some memory corruption happening on rare occasions on assert
messages.
* Fix: Fixed deadlocks happening at random when a large quantity of assert
is present.
* Fix: Fixed the library not compiling with the intel compiler collection.
* Deprecation: All cr_assume_strings_* macros are deprecated in favor of
cr_assume_str_*.
* Deprecation: All cr_assume_arrays_* macros are deprecated in favor of
cr_assume_arr_*.
2015-11-25 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.1.1
* Fix: Fixed bug where the TAP output access the assert message after
it has been freed, causing it to print garbage.
2015-09-21 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.1.0

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -2,13 +2,11 @@
<img src="doc/criterion-title.png" height="96" alt="Criterion Logo" />
=========
[![Unix Build Status](https://travis-ci.org/Snaipe/Criterion.svg?branch=bleeding)](https://travis-ci.org/Snaipe/Criterion)
[![Unix Build Status](https://api.travis-ci.org/Snaipe/Criterion.svg?branch=bleeding)](https://travis-ci.org/Snaipe/Criterion)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/Snaipe/Criterion?svg=true&branch=bleeding)](https://ci.appveyor.com/project/Snaipe/Criterion/branch/bleeding)
[![Coverage Status](https://img.shields.io/codecov/c/github/Snaipe/Criterion/bleeding.svg)](https://codecov.io/github/Snaipe/Criterion?branch=bleeding)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Snaipe/Criterion/blob/master/LICENSE)
[![Version](https://img.shields.io/github/tag/Snaipe/Criterion.svg?label=version&style=flat)](https://github.com/Snaipe/Criterion/releases)
![Analytics](https://ga-beacon.appspot.com/UA-68371536-1/Criterion/README.md?pixel)
[![Version](https://img.shields.io/badge/version-v2.3.0--rc1-blue.svg?style=flat)](https://github.com/Snaipe/Criterion/releases)
A dead-simple, yet extensible, C and C++ unit testing framework.
@ -48,12 +46,7 @@ the user would have with other frameworks:
### Binary archives
* [Linux (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.1.0/criterion-v2.1.0-linux-x86_64.tar.bz2)
* [OS X (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.1.0/criterion-v2.1.0-osx-x86_64.tar.bz2)
* [Windows (MSVC - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.1.0/criterion-v2.1.0-windows-msvc-x86_64.tar.bz2)
* [Windows (MinGW - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.1.0/criterion-v2.1.0-windows-mingw-x86_64.tar.bz2)
[comment]: # (Don't forget to change x86_64 to x64 on windows links on the next release)
Binary releases are available [on the release page](https://github.com/Snaipe/Criterion/releases)
If you have a different platform, you can still [build the library from source](http://criterion.readthedocs.org/en/latest/setup.html#installation)
@ -77,16 +70,20 @@ Sample tests can be found in the [sample directory][samples].
### Getting help
Gitter.im chat room: [![Join the chat at https://gitter.im/Snaipe/Criterion](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Snaipe/Criterion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
IRC channel: [#criterion][irc-chan] on irc.freenode.net
| Channel | Description |
| --- | --- |
[![Subscribe to the mailing list](https://img.shields.io/badge/ml-criterion@freelists.org-46BC99.svg)][mailing-list] | Criterion mailing list on freelists.org
[![Join the chat at https://gitter.im/Snaipe/Criterion](https://badges.gitter.im/Join%20Chat.svg)][gitter-chan] | `Snaipe/Criterion` on gitter.im
[![Join #criterion on freenode](https://img.shields.io/badge/irc-%23criterion-46BC99.svg)][irc-chan] | `#criterion` on irc.freenode.net
### Misc
* [autotools skeleton for projects with criterion tests][autotools]
* [CMake find module for Criterion][find-module]
## Credits
Logo done by [Greehm](http://www.cargocollective.com/pbouigue)
Logo made by [Paul Bouigue](http://www.cargocollective.com/pbouigue)
[online-docs]: http://criterion.readthedocs.org/
[pdf-docs]: http://readthedocs.org/projects/criterion/downloads/pdf/latest/
@ -101,6 +98,9 @@ Logo done by [Greehm](http://www.cargocollective.com/pbouigue)
[sample-signal]: ./samples/signal.c
[sample-report]: ./samples/report.c
[autotools]: ./dev/autotools
[find-module]: ./dev/FindCriterion.cmake
[irc-chan]: http://webchat.freenode.net/?channels=%23criterion&uio=MTY9dHJ1ZSYyPXRydWUmOT10cnVlJjExPTE5NQ4e
[gitter-chan]: https://gitter.im/Snaipe/Criterion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[mailing-list]: http://www.freelists.org/list/criterion

View file

@ -1,41 +1,58 @@
version: 2.1.0_b{build}-{branch}
version: 2.3.0-rc1_b{build}-{branch}
os: Visual Studio 2015
init:
- git config --global core.autocrlf input
- 'SET PATH=C:\MinGW\bin;%PATH%;C:\MinGW\msys\1.0\bin;%APPVEYOR_BUILD_FOLDER%\build;%APPVEYOR_BUILD_FOLDER%\build\Debug'
environment:
COVERALLS_REPO_TOKEN:
secure: 5nuCg+faxFPeppoNNcSwVobswAVFUf8ut83vw8CX/4W2y0kZkGmwEfCUxSQWiQDU
CI_NAME: appveyor
CI_JOB_ID: $(APPVEYOR_JOB_ID)
GCOV_PREFIX: $(APPVEYOR_BUILD_FOLDER)
PYTHON_BIN: python
PYTHONIOENCODING: "utf-8" # consider cmd encoding to be unicode
CRAM_SHELL: "C:\\msys64\\usr\\bin\\sh.exe"
matrix:
- COMPILER: mingw
GENERATOR: "MSYS Makefiles"
CXXFLAGS: -D__NO_INLINE__
BUILD_FLAGS: -j2
- COMPILER: msvc
GENERATOR: "Visual Studio 14 2015"
GENERATOR: "Visual Studio 14 2015 Win64"
CFLAGS: /MP
CXXFLAGS: /MP
BUILD_FLAGS: /verbosity:m
init:
- git config --global core.autocrlf input
- set MSYSTEM=MINGW64
# Disable windows process crash popup
# See: https://msdn.microsoft.com/en-us/library/bb513638%28VS.85%29.aspx
- reg add "HKLM\SYSTEM\CurrentControlSet\Control\Windows" /f /v ErrorMode /t REG_DWORD /d 2
- reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /f /v DontShowUI /t REG_DWORD /d 1
- reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /f /v Disable /t REG_DWORD /d 1
- set PATH=C:\Python35;C:\Python35\Scripts;C:\msys64\mingw64\bin;C:\msys64\mingw32\bin;C:\msys64\usr\bin;%PATH%
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\build;%APPVEYOR_BUILD_FOLDER%\build\Debug;%APPVEYOR_BUILD_FOLDER%\build\external\bin;%APPVEYOR_BUILD_FOLDER%\build\external\lib"
- set MSYSTEM=MINGW64
- pip install cram==0.7
# Remove Xamarin msbuild warnings
- del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
clone_depth: 5
platform:
- x86
- x64
configuration:
- Debug
- Release
- RelWithDebInfo
install:
- ps: $env:RELEASE_NAME = $env:APPVEYOR_REPO_BRANCH -replace "/", "-"
# Hack to make git think it is on the tip of the repo branch
- 'git checkout -B %APPVEYOR_REPO_BRANCH%'
# Patch buggy cram
- sh -c "patch /c/Python35/lib/site-packages/cram/_test.py .cmake/cram-env.patch"
# Configure project
- 'mkdir build && cd build'
- >
@ -50,7 +67,8 @@ install:
..
build_script:
- cmake --build .
# open dummy fd 0 to prevent errors at configure time for autoconf dependencies
- cmake --build . -- %BUILD_FLAGS% 0<nul
before_deploy:
- ps: |
@ -63,20 +81,14 @@ before_deploy:
test_script:
- cmake --build . --target criterion_tests
- ps: |
ctest -j2
sh -c "ctest --output-on-failure --timeout 10"
if (-not $lastexitcode -eq 0) {
type Testing/Temporary/LastTest.log
$host.setshouldexit(1)
}
#after_test:
# - 'make coveralls'
notifications:
- provider: Email
to: [franklinmathieu@gmail.com]
on_build_status_changed: true
deploy:
provider: GitHub
auth_token:

25
debian.copyright Normal file
View file

@ -0,0 +1,25 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Criterion
Upstream-Contact: Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
Source: http://github.com/Snaipe/Criterion
Files: *
Copyright: 2015-2016, Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

1
dependencies/boxfort vendored Submodule

@ -0,0 +1 @@
Subproject commit 9f7ba3716c800a53639c9fe68fd453296f982c99

1
dependencies/debugbreak vendored Submodule

@ -0,0 +1 @@
Subproject commit 6b79ec8d8f8d4603111f580a0537f8f31c484c32

@ -1 +1 @@
Subproject commit 68c57f664d4fabbc5b80327fbf5661a3a5a51e06
Subproject commit 51e79a84fd91881d7424b28271c6dda4e0d97c11

@ -1 +1 @@
Subproject commit 2762164acfaa712fea7dec6ed760ff88f7d2e026
Subproject commit 0d52904da5d7bd0a3eac3c47e9f9bb10cd78a26e

1
dependencies/nanomsg vendored Submodule

@ -0,0 +1 @@
Subproject commit 7e12a20e038234060d41d03c20721d08117f8607

1
dependencies/nanopb vendored Submodule

@ -0,0 +1 @@
Subproject commit 56f7c488df99ae655b47b5838055e48b886665a1

23
description.txt Normal file
View file

@ -0,0 +1,23 @@
Criterion is a dead-simple, yet extensible, C and C++ unit testing framework.
Most test frameworks for C require a lot of boilerplate code to
set up tests and test suites -- you need to create a main,
then register new test suites, then register the tests within
these suits, and finally call the right functions.
This gives the user great control, at the unfortunate cost of simplicity.
Criterion follows the KISS principle, while keeping the control
the user would have with other frameworks:
* C99 and C++11 compatible.
* Tests are automatically registered when declared.
* Implements a xUnit framework structure.
* A default entry point is provided, no need to declare a main
unless you want to do special handling.
* Test are isolated in their own process, crashes and signals can be
reported and tested.
* Unified interface between C and C++: include the criterion header and it *just* works.
* Supports parameterized tests and theories.
* Progress and statistics can be followed in real time with report hooks.
* TAP output format can be enabled with an option.

View file

@ -4,9 +4,9 @@
# - Try to find Criterion
#
# Once done this will define
# CRITERION_FOUND - System has LibXml2
# CRITERION_INCLUDE_DIRS - The LibXml2 include directories
# CRITERION_LIBRARIES - The libraries needed to use LibXml2
# CRITERION_FOUND - System has Criterion
# CRITERION_INCLUDE_DIRS - The Criterion include directories
# CRITERION_LIBRARIES - The libraries needed to use Criterion
find_package(PkgConfig)
@ -19,9 +19,9 @@ set(CRITERION_LIBRARIES ${CRITERION_LIBRARY})
set(CRITERION_INCLUDE_DIRS ${CRITERION_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set CRITERION_FOUND to TRUE
# handle the QUIET and REQUIRED arguments and set CRITERION_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(LibXml2 DEFAULT_MSG
find_package_handle_standard_args(Criterion DEFAULT_MSG
CRITERION_LIBRARY CRITERION_INCLUDE_DIR)
mark_as_advanced(CRITERION_INCLUDE_DIR CRITERION_LIBRARY)

14
dev/autotools/Makefile.am Normal file
View file

@ -0,0 +1,14 @@
# use the provided wrapper script to output things properly
LOG_COMPILER = $(top_srcdir)/build-aux/criterion-tap-test
# use the TAP log driver
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
check_PROGRAMS = criterion_tests
criterion_tests_SOURCES = simple.c
criterion_tests_LDFLAGS = -lcriterion
TESTS = criterion_tests
EXTRA_DIST = $(TESTS)

27
dev/autotools/README.md Normal file
View file

@ -0,0 +1,27 @@
# Autotools skeleton
This is a project skeleton that uses criterion tests with the TAP test driver.
## Running the tests
The default setup assumes that criterion is installed on your system.
```
$ ./autogen.sh
$ mkdir build && cd build
$ ../configure
$ make check
```
## License
The project skeleton is licensed under the [wtfpl](http://www.wtfpl.net). Do
whatever you want with it.
### License clause
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://www.wtfpl.net/ for more details.

17
dev/autotools/autogen.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh -e
# copy TAP driver into build-aux
automake_ver=$(automake --version | \grep -E -o '[0-9]\.[0-9]{2}')
mkdir -p build-aux
cp -f /usr/share/automake-$automake_ver/tap-driver.sh build-aux
# create criterion TAP log compiler
# this is necessary to print TAP (and only TAP) on the standard output,
# and always exit with 0 to let the TAP driver handle errors itself.
echo >build-aux/criterion-tap-test """#!/bin/sh
\$1 -Otap:- --always-succeed 2>&1 >/dev/null
"""
chmod +x build-aux/criterion-tap-test
autoreconf -vi

View file

@ -0,0 +1,15 @@
AC_INIT([Criterion Autotools Tests], [1.0], [your@email.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CHECK_LIB([criterion], [criterion_initialize], [], [
AC_MSG_ERROR([unable to find Criterion])
], [])
AC_PROG_AWK
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT

9
dev/autotools/simple.c Normal file
View file

@ -0,0 +1,9 @@
#include <criterion/criterion.h>
Test(misc, failing) {
cr_assert(0);
}
Test(misc, passing) {
cr_assert(1);
}

2406
doc/Doxyfile Normal file

File diff suppressed because it is too large Load diff

25
doc/_static/style.css vendored Normal file
View file

@ -0,0 +1,25 @@
.breatheparameterlist li p {
display: inline;
}
.breatheenumvalues li p {
display: inline;
}
.container > dl > dt {
display: block;
width: 100%;
clear: both;
}
.container > dl > dt:before {
content: " ▼ ";
}
.container > dl > dt.open:before {
content: " ▶ ";
}
.container > dl {
margin-bottom: 0 !important; /* Dirty hack */
}

17
doc/_templates/page.html vendored Normal file
View file

@ -0,0 +1,17 @@
{% extends "!page.html" %}
{% set css_files = css_files + ["_static/style.css"] %}
{% block footer %}
<script type="text/javascript">
$(document).ready(function() {
$(".container > dl > *").hide();
$(".container > dl > dt").show();
$(".container > dl > dt").click(function() {
$(this).parent().children().not("dt").toggle(400);
$(this).parent().children("dt").toggleClass("open");
})
});
</script>
{% endblock %}

View file

@ -9,136 +9,43 @@ As each ``assert`` macros have an ``expect`` counterpart with the exact same
number of parameters and name suffix, there is no benefit in adding ``expect``
macros to this list. Hence only ``assert`` macros are represented here.
All ``assert`` macros may take an optional ``printf`` format string and
parameters.
Base Assertions
-----------------
.. doxygengroup:: BaseAsserts
Common Assertions
-----------------
======================================================================= =========================================================================== ===========================================
Macro Passes if and only if Notes
======================================================================= =========================================================================== ===========================================
cr_assert(Condition, [Message, [Args...]]) ``Condition`` is true.
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_not(Condition, [Message, [Args...]]) ``Condition`` is false.
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_null(Value, [Message, [Args...]]) ``Value`` is ``NULL``.
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_not_null(Value, [Message, [Args...]]) ``Value`` is not ``NULL``.
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_eq(Actual, Expected, [Message, [Args...]]) ``Actual`` is equal to ``Expected``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_neq(Actual, Unexpected, [Message, [Args...]]) ``Actual`` is not equal to ``Unexpected``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_lt(Actual, Reference, [Message, [Args...]]) ``Actual`` is less than ``Reference``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_leq(Actual, Reference, [Message, [Args...]]) ``Actual`` is less or equal to ``Reference``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_gt(Actual, Reference, [Message, [Args...]]) ``Actual`` is greater than ``Reference``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_geq(Actual, Reference, [Message, [Args...]]) ``Actual`` is greater or equal to ``Reference``. Compatible with C++ operator overloading
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_float_eq(Actual, Expected, Epsilon, [Message, [Args...]]) ``Actual`` is equal to ``Expected`` with a tolerance of ``Epsilon``. Use this to test equality between floats
----------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_float_neq(Actual, Unexpected, Epsilon, [Message, [Args...]]) ``Actual`` is not equal to ``Unexpected`` with a tolerance of ``Epsilon``. Use this to test inequality between floats
======================================================================= =========================================================================== ===========================================
.. doxygengroup:: CommonBinAsserts
.. doxygengroup:: CommonUnaryAsserts
.. doxygengroup:: FloatAsserts
String Assertions
-----------------
Note: these macros are meant to deal with *native* strings, i.e. char arrays.
Most of them won't work on ``std::string`` in C++, with some exceptions -- for
``std::string``, you should use regular comparison assersions, as listed above.
.. doxygengroup:: StringAsserts
=========================================================== =================================================================== ===========================================
Macro Passes if and only if Notes
=========================================================== =================================================================== ===========================================
cr_assert_str_empty(Value, [Message, [Args...]]) ``Value`` is an empty string. Also works on std::string
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_not_empty(Value, [Message, [Args...]]) ``Value`` is not an empty string. Also works on std::string
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_eq(Actual, Expected, [Message, [Args...]]) ``Actual`` is lexicographically equal to ``Expected``.
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_neq(Actual, Unexpected, [Message, [Args...]]) ``Actual`` is not lexicographically equal to ``Unexpected``.
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_lt(Actual, Reference, [Message, [Args...]]) ``Actual`` is lexicographically less than ``Reference``.
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_leq(Actual, Reference, [Message, [Args...]]) ``Actual`` is lexicographically less or equal to ``Reference``.
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_gt(Actual, Reference, [Message, [Args...]]) ``Actual`` is lexicographically greater than ``Reference``.
----------------------------------------------------------- ------------------------------------------------------------------- -------------------------------------------
cr_assert_str_geq(Actual, Reference, [Message, [Args...]]) ``Actual`` is lexicographically greater or equal to ``Reference``.
=========================================================== =================================================================== ===========================================
Wide String Assertions
----------------------
.. doxygengroup:: WideStringAsserts
Array Assertions
-----------------
=========================================================================== =========================================================================== ===========================================
Macro Passes if and only if Notes
=========================================================================== =========================================================================== ===========================================
cr_assert_arr_eq(Actual, Expected, [Message, [Args...]]) ``Actual`` is byte-to-byte equal to ``Expected``. This should not be used on struct arrays,
consider using ``cr_assert_arr_eq_cmp``
instead.
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_neq(Actual, Unexpected, [Message, [Args...]]) ``Actual`` is not byte-to-byte equal to ``Unexpected``. This should not be used on struct arrays,
consider using ``cr_assert_arr_neq_cmp``
instead.
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_eq_cmp(Actual, Expected, Size, Cmp, [Message, [Args...]]) ``Actual`` is comparatively equal to ``Expected`` Only available in C++ and GNU C99
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_neq_cmp(Actual, Unexpected, Size, Cmp, [Message, [Args...]]) ``Actual`` is not comparatively equal to ``Expected`` Only available in C++ and GNU C99
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_lt_cmp(Actual, Reference, Size, Cmp, [Message, [Args...]]) ``Actual`` is comparatively less than ``Reference`` Only available in C++ and GNU C99
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_leq_cmp(Actual, Reference, Size, Cmp, [Message, [Args...]]) ``Actual`` is comparatively less or equal to ``Reference`` Only available in C++ and GNU C99
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_gt_cmp(Actual, Reference, Size, Cmp, [Message, [Args...]]) ``Actual`` is comparatively greater than ``Reference`` Only available in C++ and GNU C99
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_arr_geq_cmp(Actual, Reference, Size, Cmp, [Message, [Args...]]) ``Actual`` is comparatively greater or equal to ``Reference`` Only available in C++ and GNU C99
=========================================================================== =========================================================================== ===========================================
.. doxygengroup:: ArrayAsserts
.. doxygengroup:: SafeArrCmpAsserts
Exception Assertions
--------------------
The following assertion macros are only defined for C++.
=========================================================================== =========================================================================== ===========================================
Macro Passes if and only if Notes
=========================================================================== =========================================================================== ===========================================
cr_assert_throw(Statement, Exception, [Message, [Args...]]) ``Statement`` throws an instance of ``Exception``.
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_no_throw(Statement, Exception, [Message, [Args...]]) ``Statement`` does not throws an instance of ``Exception``.
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_any_throw(Statement, [Message, [Args...]]) ``Statement`` throws any kind of exception.
--------------------------------------------------------------------------- --------------------------------------------------------------------------- -------------------------------------------
cr_assert_none_throw(Statement, [Message, [Args...]]) ``Statement`` does not throw any exception.
=========================================================================== =========================================================================== ===========================================
.. doxygengroup:: ExceptionAsserts
File Assertions
---------------
=============================================================================== ============================================================================ ===========================================
Macro Passes if and only if Notes
=============================================================================== ============================================================================ ===========================================
cr_assert_file_contents_eq_str(File, ExpectedContents, [Message, [Args...]]) The contents of ``File`` are equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_file_contents_neq_str(File, ExpectedContents, [Message, [Args...]]) The contents of ``File`` are not equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stdout_eq_str(ExpectedContents, [Message, [Args...]]) The contents of ``stdout`` are equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stdout_neq_str(ExpectedContents, [Message, [Args...]]) The contents of ``stdout`` are not equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stderr_eq_str(ExpectedContents, [Message, [Args...]]) The contents of ``stderr`` are equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stderr_neq_str(ExpectedContents, [Message, [Args...]]) The contents of ``stderr`` are not equal to the string ``ExpectedContents``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_file_contents_eq(File, RefFile, [Message, [Args...]]) The contents of ``File`` are equal to the contents of ``RefFile``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_file_contents_neq(File, RefFile, [Message, [Args...]]) The contents of ``File`` are not equal to the contents of ``RefFile``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stdout_eq(RefFile, [Message, [Args...]]) The contents of ``stdout`` are equal to the contents of ``RefFile``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stdout_neq(RefFile, [Message, [Args...]]) The contents of ``stdout`` are not equal to the contents of ``RefFile``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stderr_eq(RefFile, [Message, [Args...]]) The contents of ``stderr`` are equal to the contents of ``RefFile``.
------------------------------------------------------------------------------- ---------------------------------------------------------------------------- -------------------------------------------
cr_assert_stderr_neq(RefFile, [Message, [Args...]]) The contents of ``stderr`` are not equal to the contents of ``RefFile``.
=============================================================================== ============================================================================ ===========================================
.. doxygengroup:: FileAsserts

View file

@ -13,10 +13,25 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext"))
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# hack for readthedocs to cause it to run doxygen first
# https://github.com/rtfd/readthedocs.org/issues/388
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
from subprocess import call
call('doxygen')
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'breathe',
]
breathe_projects = { "criterion-doxygen": "doxyxml/" }
breathe_default_project = "criterion-doxygen"
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -32,14 +47,14 @@ master_doc = 'index'
# General information about the project.
project = u'Criterion'
copyright = u'2015, Franklin "Snaipe" Mathieu'
copyright = u'2015-2016, Franklin "Snaipe" Mathieu'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.1.0'
version = '2.3.0-rc1'
# The full version, including alpha/beta/rc tags.
release = version

61
doc/debug.rst Normal file
View file

@ -0,0 +1,61 @@
Debugging and Coverage information
==================================
.. _gdb-ref:
Debugging with GDB
------------------
In one terminal do:
.. code-block:: bash
$ ./simple.c.bin --debug
Process simple.c.bin created; pid = 20803
Listening on port 1234
In another terminal connect to this debug session:
.. code-block:: bash
$ gdb -q ./test
Reading symbols from ./test...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x00007ffff7dd9d90 in _start() from target:/lib64/ld-linux-x86-64.so.2
(gdb) continue
...
[Inferior 1 (process 25269) exited normally]
(gdb) q
After ``continue`` the first test is run:
.. code-block:: bash
Remote debugging from host 127.0.0.1
[RUN ] misc::failing
[----] /media/data/devel/Criterion/samples/simple.c:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0,00s)
Child exited with status 0
And a new process is created for the next test:
.. code-block:: bash
Process /media/data/devel/Criterion/build/samples/simple.c.bin created; pid = 26414
Listening on port 1234
Connect your remote debugger to this test with ``remote target localhost:1234``
and run the test with ``continue``
To use a different port use ``--debug --debug-transport=<protocol>:<port>``
.. _coverage-ref:
Coverage of Criterion tests
---------------------------
To use gcov, you have to compile your tests with the two GCC Options
``-fprofile-arcs`` and ``ftest-coverage``.

View file

@ -16,33 +16,36 @@ Command line arguments
* ``--ascii``: Don't use fancy unicode symbols or colors in the output.
* ``-jN or --jobs N``: Use ``N`` parallel jobs to run the tests. ``0`` picks
a number of jobs ideal for your hardware configuration.
* ``--pattern [PATTERN]``: Run tests whose string identifier matches
* ``--filter [PATTERN]``: Run tests whose string identifier matches
the given shell wildcard pattern (see dedicated section below). (\*nix only)
* ``--no-early-exit``: The test workers shall not prematurely exit when done and
will properly return from the main, cleaning up their process space.
This is useful when tracking memory leaks with ``valgrind --tool=memcheck``.
* ``--debug[=debugger]``: Run tests with a debugging server attached.
``debugger`` can be 'gdb', 'lldb', or 'windbg' (windows only).
* ``--debug-transport [TRANSPORT]``: Make the debugging server use the
specified remote transport. Only transports of the form ``tcp:port`` are
currently supported. ``tcp:1234`` is the default.
* ``--no-early-exit``: This flag is deprecated and no longer does anything.
* ``-S or --short-filename``: The filenames are displayed in their short form.
* ``--always-succeed``: The process shall exit with a status of ``0``.
* ``--tap[=FILE]``: Writes a TAP (Test Anything Protocol) report to FILE.
No file or ``"-"`` means ``stderr``. This option is equivalent to
``--output=tap:FILE``.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--xml[=FILE]``: Writes JUnit4 XML report to FILE.
No file or ``"-"`` means ``stderr``. This option is equivalent to
``--output=xml:FILE``.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--json[=FILE]``: Writes a JSON report to FILE.
No file or ``"-"`` means ``stderr``. This option is equivalent to
``--output=json:FILE``.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--verbose[=level]``: Makes the output verbose. When provided with an integer,
sets the verbosity level to that integer.
* ``-OPROVIDER:FILE or --output=PROVIDER:FILE``: Write a test report to FILE
using the output provider named by PROVIDER. FILE may be a relative path, or
``"-"`` to write to ``stderr``.
using the output provider named by PROVIDER.
If FILE is ``"-"``, it implies ``--quiet``, and the report shall be written
to ``stderr``.
Shell Wildcard Pattern
----------------------
Extglob patterns in criterion are matched against a test's string identifier.
This feature is only available on \*nix systems where ``PCRE`` is provided.
In the table below, a ``pattern-list`` is a list of patterns separated by ``|``.
Any extglob pattern can be constructed by combining any of the following
@ -81,7 +84,6 @@ Environment Variables
Environment variables are alternatives to command line switches when set to 1.
* ``CRITERION_ALWAYS_SUCCEED``: Same as ``--always-succeed``.
* ``CRITERION_NO_EARLY_EXIT``: Same as ``--no-early-exit``.
* ``CRITERION_FAIL_FAST``: Same as ``--fail-fast``.
* ``CRITERION_USE_ASCII``: Same as ``--ascii``.
* ``CRITERION_JOBS``: Same as ``--jobs``. Sets the number of jobs to
@ -93,3 +95,8 @@ Environment variables are alternatives to command line switches when set to 1.
to its value. (\*nix only)
* ``CRITERION_DISABLE_TIME_MEASUREMENTS``: Disables any time measurements on
the tests.
* ``CRITERION_OUTPUTS``: Can be set to a comma-separated list of
``PROVIDER:FILE`` entries. For instance, setting the variable to
``tap:foo.tap,xml:bar.xml`` has the same effect as specifying ``--tap=foo.tap``
and ``--xml=bar.xml`` at once.
* ``CRITERION_ENABLE_TAP``: (Deprecated, use CRITERION_OUTPUTS) Same as ``--tap``.

View file

@ -17,9 +17,17 @@ A report hook can be declared using the ``ReportHook`` macro:
The macro takes a Phase parameter that indicates the phase at which the function
shall be run. Valid phases are described below.
**Note**: there are no guarantees regarding the order of execution of report hooks
on the same phase. In other words, all report hooks of a specific phase could
be executed in any order.
.. note::
There are no guarantees regarding the order of execution of report hooks
on the same phase. In other words, all report hooks of a specific phase could
be executed in any order.
.. note::
Aborting the runner with any means (abort(), exit(), cr_assert(), ...) is
unsupported. If you need to abort the runner, you need to iterate all
subsequent tests and set their `disabled` field to 1.
Testing Phases
--------------

View file

@ -9,9 +9,11 @@ Criterion
starter
assert
hooks
logging
env
output
parameterized
theories
internal
debug
faq

View file

@ -30,8 +30,6 @@ logging_threshold enum criterion_logging_level The logging level
------------------- ---------------------------------- --------------------------------------------------------------
logger struct criterion_logger * The logger (see below)
------------------- ---------------------------------- --------------------------------------------------------------
no_early_exit bool True iff the test worker should exit early
------------------- ---------------------------------- --------------------------------------------------------------
always_succeed bool True iff criterion_run_all_tests should always returns 1
------------------- ---------------------------------- --------------------------------------------------------------
use_ascii bool True iff the outputs should use the ASCII charset
@ -66,12 +64,11 @@ Example main
int main(int argc, char *argv[]) {
struct criterion_test_set *tests = criterion_initialize();
if (!criterion_handle_args(argc, argv, true))
return 0;
int result = 0;
if (criterion_handle_args(argc, argv, true))
result = !criterion_run_all_tests(tests);
int result = !criterion_run_all_tests(set);
criterion_finalize(set);
criterion_finalize(tests);
return result;
}

61
doc/logging.rst Normal file
View file

@ -0,0 +1,61 @@
Logging messages
================
Sometimes, it might be useful to print some output from within a test
or fixture -- and while this can be done trivially with a ``printf``,
it doesn't integrate well with the current output, nor does it work
*at all* when the process is testing a redirected stdout.
For these cases, Criterion exposes a logging facility:
.. code-block:: c
#include <criterion/criterion.h>
#include <criterion/logging.h>
Test(suite_name, test_name) {
cr_log_info("This is an informational message. They are not displayed "
"by default.");
cr_log_warn("This is a warning. They indicate some possible malfunction "
"or misconfiguration in the test.");
cr_log_error("This is an error. They indicate serious problems and "
"are usually shown before the test is aborted.");
}
``cr_log_info``, ``cr_log_warn`` and ``cr_log_error`` are all macros expanding
to a call to the ``cr_log`` function. All of them take a mandatory format string,
followed by optional parameters; for instance:
.. code-block:: c
cr_log_info("%d + %d = %d", 1, 2, 3);
If using C++, the output stream objects ``info``, ``warn`` and ``error`` are
defined within the ``criterion::logging`` namespace, and can be used in
conjunction with ``operator<<``:
.. code-block:: c++
#include <criterion/criterion.h>
#include <criterion/logging.h>
using criterion::logging::info;
using criterion::logging::warn;
using criterion::logging::error;
Test(suite_name, test_name) {
info << "This is an informational message. "
<< "They are not displayed by default."
<< std::flush;
warn << "This is a warning. "
<< "They indicate some possible malfunction "
<< "or misconfiguration in the test."
<< std::flush;
error << "This is an error. "
<< "They indicate serious problems and "
<< "are usually shown before the test is aborted."
<< std::flush;
}
Note that empty messages are ignored, and newlines in the log message splits
the passed string into as many messages are there are lines.

View file

@ -14,6 +14,8 @@ Adding parameterized tests
Adding parameterized tests is done by defining the parameterized test function,
and the parameter generator function:
.. doxygengroup:: ParameterizedBase
.. code-block:: c
#include <criterion/parameterized.h>
@ -37,6 +39,10 @@ identifier format.
``Type`` is the compound type of the generated array. ``params`` and ``nb_params``
are the pointer and the length of the generated array, respectively.
.. note::
The parameter array must be reachable after the function returns -- as
such, local arrays must be declared with `static` or dynamically allocated.
Passing multiple parameters
---------------------------
@ -55,7 +61,7 @@ easily use a struct to hold the context as a workaround:
};
ParameterizedTestParameters(suite_name, test_name) {
struct my_params params[] = {
static struct my_params params[] = {
// parameter set
};
@ -72,7 +78,7 @@ C++ users can also use a simpler syntax before returning an array of parameters:
.. code-block:: c++
ParameterizedTestParameters(suite_name, test_name) {
struct my_params params[] = {
static struct my_params params[] = {
// parameter set
};

1
doc/requirements.txt Normal file
View file

@ -0,0 +1 @@
breathe

View file

@ -7,7 +7,8 @@ Prerequisites
The library is supported on Linux, OS X, FreeBSD, and Windows.
The following compilers are supported to compile both the library and the tests:
* GCC 4.9+
* GCC 4.9+ (Can be relaxed to GCC 4.6+ when not using C++)
* Clang 3.4+
* MSVC 14+ (Included in Visual Studio 2015 or later)

View file

@ -6,6 +6,10 @@ Adding tests
Adding tests is done using the ``Test`` macro:
.. doxygendefine:: Test
Example:
.. code-block:: c
#include <criterion/criterion.h>
@ -147,21 +151,8 @@ Configuration reference
Here is an exhaustive list of all possible configuration parameters you can
pass:
============= =============== ==============================================================
Parameter Type Description
============= =============== ==============================================================
.description const char * Adds a description. Cannot be ``NULL``.
------------- --------------- --------------------------------------------------------------
.init void (*)(void) Adds a setup function the be executed before the test.
------------- --------------- --------------------------------------------------------------
.fini void (*)(void) Adds a teardown function the be executed after the test.
------------- --------------- --------------------------------------------------------------
.disabled bool Disables the test.
------------- --------------- --------------------------------------------------------------
.signal int Expect the test to raise the specified signal.
------------- --------------- --------------------------------------------------------------
.exit_code int Expect the test to exit with the specified status.
============= =============== ==============================================================
.. doxygenstruct:: criterion_test_extra_data
:members:
Setting up suite-wise configuration
-----------------------------------
@ -169,6 +160,10 @@ Setting up suite-wise configuration
Tests under the same suite can have a suite-wise configuration -- this is done
using the ``TestSuite`` macro:
.. doxygendefine:: TestSuite
Example:
.. code-block:: c
#include <criterion/criterion.h>

View file

@ -10,6 +10,8 @@ parameters known as "data points".
Adding theories
---------------
.. doxygengroup:: TheoryBase
Adding theories is done by defining data points and a theory function:
.. code-block:: c
@ -53,53 +55,7 @@ making the test fail.
On top of those, more ``assume`` macro functions are available for common operations:
======================================================= ====================================================
Macro Description
======================================================= ====================================================
``cr_assume_not(Condition)`` Assumes Condition is false.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_null(Ptr)`` Assumes Ptr is NULL.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_not_null(Ptr)`` Assumes Ptr is not NULL.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_eq(Actual, Expected)`` Assumes Actual == Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_neq(Actual, Unexpected)`` Assumes Actual != Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_lt(Actual, Expected)`` Assumes Actual < Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_leq(Actual, Expected)`` Assumes Actual <= Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_gt(Actual, Expected)`` Assumes Actual > Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_geq(Actual, Expected)`` Assumes Actual >= Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_float_eq(Actual, Expected, Epsilon)`` Assumes Actual == Expected with an error of Epsilon.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_float_neq(Actual, Unexpected, Epsilon)`` Assumes Actual != Expected with an error of Epsilon.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_eq(Actual, Expected)`` Assumes Actual and Expected are the same string.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_neq(Actual, Unexpected)`` Assumes Actual and Expected are not the same string.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_lt(Actual, Expected)`` Assumes Actual is less than Expected
lexicographically.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_leq(Actual, Expected)`` Assumes Actual is less or equal to Expected
lexicographically.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_gt(Actual, Expected)`` Assumes Actual is greater than Expected
lexicographically.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_str_geq(Actual, Expected)`` Assumes Actual is greater or equal to Expected
lexicographically.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_arr_eq(Actual, Expected, Size)`` Assumes all elements of Actual (from 0 to Size - 1)
are equals to those of Expected.
------------------------------------------------------- ----------------------------------------------------
``cr_assume_arr_neq(Actual, Unexpected, Size)`` Assumes one or more elements of Actual (from 0 to
Size - 1) differs from their counterpart in Expected.
======================================================= ====================================================
.. doxygengroup:: TheoryInvariants
Configuring theories
--------------------

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,15 +21,45 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Functions to abort and continue tests
*****************************************************************************/
#ifndef CRITERION_ABORT_H_
# define CRITERION_ABORT_H_
#define CRITERION_ABORT_H_
# include "internal/common.h"
#include "internal/common.h"
CR_BEGIN_C_API
/**
* Aborts the current test, marking it as failed.
*
* This function does not return.
*/
CR_API CR_NORETURN void criterion_abort_test(void);
CR_INLINE static void criterion_continue_test(void) {}
/**
* Aborts the current test, marking it as skipped.
*
* This function does not return.
*/
CR_API CR_NORETURN void criterion_skip_test(const char *format, ...);
/**
* Continues the current test.
*
* Used as a counterpart to criterion_abort_test.
*/
CR_API void criterion_continue_test(void);
/**
* Kills the current test, marking it as failed.
*
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*/
CR_API void criterion_test_die(const char *msg, ...);
CR_END_C_API

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,128 +21,258 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Test intern memory managment
*****************************************************************************/
#ifndef CRITERION_ALLOC_H_
# define CRITERION_ALLOC_H_
#define CRITERION_ALLOC_H_
# ifdef __cplusplus
# include <memory>
# include <cstddef>
#ifdef __cplusplus
# include <memory>
# include <cstddef>
using std::size_t;
# else
# include <stddef.h>
# endif
# include "internal/common.h"
#else
# include <stddef.h>
#endif
#include "internal/common.h"
CR_BEGIN_C_API
/**
* Allocates a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by malloc(3)
* inside a test or its setup and teardown functions; cr_malloc must
* be use in its place for this purpose.
*
* This function is semantically identical to malloc(3).
*
* @param[in] size The minimal size in bytes of the newly allocated memory.
* @returns The pointer to the start of the allocated memory.
*/
CR_API void *cr_malloc(size_t size);
/**
* Allocates and zero-initialize a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by calloc(3)
* inside a test or its setup and teardown functions; cr_calloc must
* be use in its place for this purpose.
*
* This function is semantically identical to calloc(3).
*
* @param[in] nmemb The number of elements to allocate
* @param[in] size The minimal size of each element.
* @returns The pointer to the start of the allocated memory.
*/
CR_API void *cr_calloc(size_t nmemb, size_t size);
/**
* Reallocates a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by realloc(3)
* inside a test or its setup and teardown functions; cr_realloc must
* be used in its place for this purpose.
*
* This function is semantically identical to realloc(3).
*
* @param[in] ptr A pointer to the memory that needs to be resized.
* @param[in] size The minimal size of the reallocated memory.
* @returns The pointer to the start of the reallocated memory.
*/
CR_API void *cr_realloc(void *ptr, size_t size);
/**
* Free a block of memory allocated by cr_malloc, cr_free or cr_realloc.
*
* @param[in] ptr A pointer to the memory that needs to be freed.
*/
CR_API void cr_free(void *ptr);
CR_END_C_API
# ifdef __cplusplus
# include <type_traits>
#ifdef __cplusplus
# include <type_traits>
namespace criterion {
namespace criterion
{
void *(*const malloc)(size_t) = cr_malloc;
void(*const free)(void *) = cr_free;
void *(*const calloc)(size_t, size_t) = cr_calloc;
void *(*const realloc)(void *, size_t) = cr_realloc;
void *(*const malloc)(size_t) = cr_malloc;
void (*const free)(void *) = cr_free;
void *(*const calloc)(size_t, size_t) = cr_calloc;
void *(*const realloc)(void *, size_t) = cr_realloc;
/**
* Allocates and construct a new object.
*
* It is undefined behaviour to access a pointer returned by the new
* operator inside a test or its setup and teardown functions;
* new_obj must be used in its place for this purpose.
*
* This function is semantically identical to the new operator.
*
* @tparam T The type of the object to construct
* @param[in] params The constructor parameters of T.
* @returns The pointer to the newly constructed object.
*/
template <typename T, typename... Params>
T *new_obj(Params... params)
{
T *obj = static_cast<T *>(cr_malloc(sizeof (T)));
template<typename T, typename... Params>
T* new_obj(Params... params) {
T* obj = static_cast<T*>(cr_malloc(sizeof (T)));
new (obj) T(params...);
return obj;
}
new (obj) T(params...);
return obj;
}
template<typename T>
typename std::enable_if<std::is_fundamental<T>::value>::type*
new_arr(size_t len) {
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
*(reinterpret_cast<size_t*>(ptr)) = len;
T* arr = reinterpret_cast<T*>(reinterpret_cast<size_t*>(ptr) + 1);
return arr;
}
/**
* Allocates and construct a new array of primitive types
*
* It is undefined behaviour to access a pointer returned by the new[]
* operator inside a test or its setup and teardown functions;
* new_arr must be used in its place for this purpose.
*
* This function is semantically identical to the new[] operator.
*
* @tparam T The compound type of the array to construct
* @param[in] len The length of the array.
* @returns The pointer to the newly constructed array.
*/
template <typename T>
typename std::enable_if<std::is_fundamental<T>::value>::type
* new_arr(size_t len) {
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
template<typename T>
T* new_arr(size_t len) {
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
*(reinterpret_cast<size_t*>(ptr)) = len;
*(reinterpret_cast<size_t *>(ptr)) = len;
T *arr = reinterpret_cast<T *>(reinterpret_cast<size_t *>(ptr) + 1);
return arr;
}
T* arr = reinterpret_cast<T*>(reinterpret_cast<size_t*>(ptr) + 1);
for (size_t i = 0; i < len; ++i)
new (arr + i) T();
return arr;
}
/**
* Allocates and construct a new array of object types
*
* It is undefined behaviour to access a pointer returned by the new[]
* operator inside a test or its setup and teardown functions;
* new_arr must be used in its place for this purpose.
*
* This function is semantically identical to the new[] operator.
*
* @tparam T The compound type of the array to construct
* @param[in] len The length of the array.
* @returns The pointer to the newly constructed array.
*/
template <typename T>
T *new_arr(size_t len)
{
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
template<typename T>
void delete_obj(T* ptr) {
ptr->~T();
cr_free(ptr);
}
*(reinterpret_cast<size_t *>(ptr)) = len;
template<typename T>
void delete_arr(typename std::enable_if<std::is_fundamental<T>::value>::type* ptr) {
cr_free(ptr);
}
T *arr = reinterpret_cast<T *>(reinterpret_cast<size_t *>(ptr) + 1);
for (size_t i = 0; i < len; ++i)
new (arr + i)T();
return arr;
}
template<typename T>
void delete_arr(T* ptr) {
size_t *ptr_ = reinterpret_cast<size_t*>(ptr);
size_t len = *(ptr_ - 1);
T* arr = reinterpret_cast<T*>(ptr_);
for (size_t i = 0; i < len; ++i)
arr[i].~T();
cr_free(ptr_ - 1);
}
/**
* Destroys and frees an object allocated by new_obj.
*
* This function is semantically identical to the delete operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_obj(T *ptr)
{
ptr->~T();
cr_free(ptr);
}
template<typename T>
struct allocator {
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
/**
* Destroys and frees an array allocated by delete_arr.
*
* This function is semantically identical to the delete[] operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_arr(typename std::enable_if<std::is_fundamental<T>::value>::type *ptr)
{
cr_free(ptr);
}
template<typename U>
struct rebind {
typedef allocator<U> other;
};
/**
* Destroys and frees an array allocated by delete_arr.
*
* This function is semantically identical to the delete[] operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_arr(T *ptr)
{
size_t *ptr_ = reinterpret_cast<size_t *>(ptr);
size_t len = *(ptr_ - 1);
T *arr = reinterpret_cast<T *>(ptr_);
inline explicit allocator() {}
inline ~allocator() {}
inline explicit allocator(allocator const&) {}
template<typename U>
inline explicit allocator(allocator<U> const&) {}
for (size_t i = 0; i < len; ++i)
arr[i].~T();
cr_free(ptr_ - 1);
}
inline pointer address(reference r) { return &r; }
inline const_pointer address(const_reference r) { return &r; }
/**
* Allocator for use in the STL.
*
* This internally uses calls to the cr_malloc function family, which
* means that STL collections can be safely used inside tests or
* setup/teardown functions if this allocator is used.
*/
template <typename T>
struct allocator {
typedef T value_type;
typedef value_type *pointer;
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
inline pointer allocate(size_type cnt, typename std::allocator<void>::const_pointer = 0) {
return reinterpret_cast<pointer>(cr_malloc(cnt * sizeof (T)));
}
inline void deallocate(pointer p, size_type) { cr_free(p); }
inline size_type max_size() const {
return size_type(-1) / sizeof(T);
}
inline void construct(pointer p, const T& t) { new(p) T(t); }
inline void construct(pointer p, T&& t) { new (p) T(std::move(t)); }
inline void destroy(pointer p) { p->~T(); }
inline bool operator==(allocator const&) { return true; }
inline bool operator!=(allocator const& a) { return !operator==(a); }
template <typename U>
struct rebind {
typedef allocator<U> other;
};
inline explicit allocator() {}
inline ~allocator() {}
inline explicit allocator(allocator const &) {}
template <typename U>
inline explicit allocator(allocator<U> const &) {}
inline pointer address(reference r) { return &r; }
inline const_pointer address(const_reference r) { return &r; }
inline pointer allocate(size_type cnt, typename std::allocator<void>::const_pointer = 0)
{
return reinterpret_cast<pointer>(cr_malloc(cnt * sizeof (T)));
}
inline void deallocate(pointer p, size_type) { cr_free(p); }
inline size_type max_size() const
{
return size_type(-1) / sizeof (T);
}
inline void construct(pointer p, const T &t) { new(p) T(t); }
inline void construct(pointer p, T &&t) { new (p) T(std::move(t)); }
inline void destroy(pointer p) { p->~T(); }
inline bool operator==(allocator const &) { return true; }
inline bool operator!=(allocator const &a) { return !operator==(a); }
};
}
# endif
#endif
#endif /* !CRITERION_ALLOC_H_ */

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,28 +21,101 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Include this to use criterion
*****************************************************************************/
#ifndef CRITERION_H_
# define CRITERION_H_
#define CRITERION_H_
# include "types.h"
# include "assert.h"
# include "alloc.h"
#include "types.h"
#include "assert.h"
#include "alloc.h"
# include "internal/test.h"
/**
* Defines a new test.
*
* @param Suite The name of the test suite containing this test.
* @param Name The name of the test.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).\n
* Example: .exit_code = 1
*/
#define Test(Suite, Name, ...) internal
# define Test(...) CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
# define TestSuite(...) CR_EXPAND(CR_SUITE_BASE(__VA_ARGS__, .sentinel_ = 0))
/**
* Explicitely defines a test suite and its options.
*
* @param Name The name of the test suite.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).
* These options will provide the defaults for each test.
*/
#define TestSuite(Name, ...) internal
CR_BEGIN_C_API
/**
* Initializes criterion and builds a set of all discovered tests.
*
* Using any of the functions and macros provided by criterion before calling
* this results in undefined behaviour.
*
* @returns the set of tests
*/
CR_API struct criterion_test_set *criterion_initialize(void);
/**
* Release all resources allocated by criterion.
*
* Using any of the functions and macros provided by criterion except
* criterion_initialize after this function is called results in undefined
* behaviour.
*/
CR_API void criterion_finalize(struct criterion_test_set *tests);
/**
* Run all the tests in the test set.
*
* @param[in] tests The set of tests that are to be executed.
*
* @returns 1 if all tests succeeded or criterion_options.always_succeed
* is true, 0 otherwise.
*/
CR_API int criterion_run_all_tests(struct criterion_test_set *tests);
/**
* Handles all default command-line parameters, as documented in:
* <http://criterion.readthedocs.org/en/latest/env.html>, and appropriately
* sets criterion_options.
*
* @param[in] argc The number of arguments in argv.
* @param[in] argv A null-terminated array of strings representing the arguments.
* @param[in] handle_unknown_arg Whether the function should print a message
* and exit when an unknown parameter is encountered. Use false if you want
* to handle additional parameters yourself.
*
* @returns 0 if the process should exit immediately after, for instance after
* printing the help message.
*/
CR_API int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg);
/**
* Manually registers a new test within the specified test set.
*
* @param[in] tests The set of tests you want to insert the test in.
* @param[in] test The newly created test.
*/
CR_API void criterion_register_test(struct criterion_test_set *tests,
struct criterion_test *test);
struct criterion_test *test);
CR_API extern const struct criterion_test *const criterion_current_test;
CR_API extern const struct criterion_suite *const criterion_current_suite;
CR_END_C_API
#include "internal/test.h"
#endif /* !CRITERION_H_ */

View file

@ -0,0 +1,48 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_EMBEDDED_H_
#define CRITERION_EMBEDDED_H_
typedef signed long long int cr_ssize;
typedef unsigned long long int cr_size;
typedef unsigned char cr_byte;
typedef int cr_err;
typedef struct cr_io_ctx cr_io_ctx;
struct cr_embed_vtable {
cr_err (*init)(struct cr_io_ctx *ctx);
cr_ssize (*send)(const cr_byte *buf, cr_size size);
cr_ssize (*recv)(cr_byte *buf, cr_size size);
cr_err (*term)(struct cr_io_ctx *ctx);
};
struct cr_embed_properties {
struct cr_embed_vtable vtable;
struct cr_io_ctx *ctx;
};
int cr_embed_init(struct cr_embed_properties *props);
int cr_embed_term(struct cr_embed_properties *props);
#endif /* !CRITERION_EMBEDDED_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,18 +22,19 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_EVENT_H_
# define CRITERION_EVENT_H_
#define CRITERION_EVENT_H_
# ifdef __cplusplus
# include <cstddef>
# else
# include <stddef.h>
# endif
# include "internal/common.h"
#ifdef __cplusplus
# include <cstddef>
#else
# include <stddef.h>
#endif
#include "internal/common.h"
#include "stats.h"
CR_BEGIN_C_API
CR_API void criterion_send_event(int kind, void *data, size_t size);
CR_API void criterion_send_assert(struct criterion_assert_stats *stats);
CR_END_C_API

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,11 +21,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Report hooks
*****************************************************************************/
#ifndef CRITERION_HOOKS_H_
# define CRITERION_HOOKS_H_
#define CRITERION_HOOKS_H_
# include "internal/hooks.h"
#include "internal/hooks.h"
/**
* This enum lists all the phases of the runner lifecycle.
*/
typedef enum {
PRE_ALL,
PRE_SUITE,
@ -42,6 +49,24 @@ typedef enum {
typedef void (*f_report_hook)();
# define ReportHook(Kind) CR_REPORT_HOOK_IMPL(Kind)
/**
* ReportHook(Kind)(Type *param) { Function Body }
*
* Defines a report hook for the phase defined by Kind.
*
* The type of the parameter depends on the phase:
*
* - struct criterion_test_set for PRE_ALL.
* - struct criterion_suite_set for PRE_SUITE.
* - struct criterion_test for PRE_INIT and PRE_TEST.
* - struct criterion_assert_stats for ASSERT.
* - struct criterion_theory_stats for THEORY_FAIL.
* - struct criterion_test_stats for POST_TEST, POST_FINI, and TEST_CRASH.
* - struct criterion_suite_stats for POST_SUITE.
* - struct criterion_global_stats for POST_ALL.
*
* @param Kind The report phase to hook the function onto.
*/
#define ReportHook(Kind) CR_REPORT_HOOK_IMPL(Kind)
#endif /* !CRITERION_HOOKS_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,21 +22,22 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_ASPRINTF_COMPAT_H_
# define CRITERION_ASPRINTF_COMPAT_H_
#define CRITERION_ASPRINTF_COMPAT_H_
# ifdef __cplusplus
# include <cstdarg>
# else
# include <stdarg.h>
# endif
#ifdef __cplusplus
# include <cstdarg>
#else
# include <stdarg.h>
#endif
# include "common.h"
#include "common.h"
CR_BEGIN_C_API
CR_FORMAT(printf, 2, 3)
CR_API int cr_asprintf(char **strp, const char *fmt, ...);
CR_API int cr_vasprintf(char **strp, const char *fmt, va_list ap);
CR_API void cr_asprintf_free(char *buf);
CR_END_C_API

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,129 +22,118 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_COMMON_H_
# define CRITERION_COMMON_H_
#define CRITERION_COMMON_H_
# if defined(_MSC_VER)
# if _MSC_VER < 1900
# error \
Your version of MSVC++ is too old, please compile your tests using \
a c99 compiler, like MinGW or MSVC 14.0+ (Included in visual studio \
2015)
# endif
#if defined (_MSC_VER)
# if _MSC_VER < 1900
# error \
Your version of MSVC++ is too old, please compile your tests using \
a c99 compiler, like MinGW or MSVC 14.0+ (Included in visual studio \
2015)
# endif
#endif
# ifndef CR_IS_MSVC
# ifdef _MSC_VER
# define CR_IS_MSVC _MSC_VER
# else
# define CR_IS_MSVC 0
# endif
# endif
# ifdef __cplusplus
# define CR_ATTRIBUTE(Arg) [[gnu::Arg]]
# define CR_BEGIN_C_API extern "C" {
# define CR_END_C_API }
#ifndef CR_IS_MSVC
# ifdef _MSC_VER
# define CR_IS_MSVC _MSC_VER
# else
# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
# define CR_BEGIN_C_API
# define CR_END_C_API
# define CR_IS_MSVC 0
# endif
#endif
# ifdef __APPLE__
# define CR_SECTION_START_PREFIX __first
# define CR_SECTION_END_PREFIX __last
# define CR_SECTION_START_SUFFIX(Name) __asm("section$start$__DATA$" Name)
# define CR_SECTION_END_SUFFIX(Name) __asm("section$end$__DATA$" Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section("__DATA," Name))
# define CR_SECTION_SUFFIX_
# elif CR_IS_MSVC
# define CR_SECTION_START_PREFIX __start
# define CR_SECTION_END_PREFIX __stop
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) \
__pragma(data_seg(push)) \
__pragma(section(Name, read)) \
#ifdef __cplusplus
# ifdef __GNUC__
# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
# else
# define CR_ATTRIBUTE(Arg) [[gnu::Arg]]
# endif
# define CR_BEGIN_C_API extern "C" {
# define CR_END_C_API }
#else
# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
# define CR_BEGIN_C_API
# define CR_END_C_API
#endif
#ifdef __APPLE__
# define CR_SECTION_START_SUFFIX(Name) __asm("section$start$__DATA$" Name)
# define CR_SECTION_END_SUFFIX(Name) __asm("section$end$__DATA$" Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section("__DATA," Name))
# define CR_SECTION_SUFFIX_
#elif CR_IS_MSVC
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) \
__pragma(data_seg(push)) \
__pragma(section(Name, read)) \
__declspec(allocate(Name))
# define CR_SECTION_SUFFIX_ \
# define CR_SECTION_SUFFIX_ \
__pragma(data_seg(pop))
# else
# define CR_SECTION_START_PREFIX __start
# define CR_SECTION_END_PREFIX __stop
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section(Name))
# define CR_SECTION_SUFFIX_
# endif
#else
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section(Name))
# define CR_SECTION_SUFFIX_
#endif
# define CR_MAKE_IDENTIFIER_(Prefix, Id) CR_MAKE_IDENTIFIER__(Prefix, Id)
# define CR_MAKE_IDENTIFIER__(Prefix, Id) Prefix ## _ ## Id
#define CR_MAKE_IDENTIFIER_(Prefix, Id) CR_MAKE_IDENTIFIER__(Prefix, Id)
#define CR_MAKE_IDENTIFIER__(Prefix, Id) Prefix ## _ ## Id
# define CR_SECTION_START_(Name) CR_MAKE_IDENTIFIER_(CR_SECTION_START_PREFIX, Name)
# define CR_SECTION_END_(Name) CR_MAKE_IDENTIFIER_(CR_SECTION_END_PREFIX, Name)
#ifdef __GNUC__
# define CR_UNUSED CR_ATTRIBUTE(unused)
# define CR_NORETURN CR_ATTRIBUTE(noreturn)
# define CR_INLINE CR_ATTRIBUTE(always_inline) inline
#elif CR_IS_MSVC
# define CR_UNUSED __pragma(warning(suppress: 4100))
# define CR_NORETURN __declspec(noreturn)
# define CR_INLINE __forceinline
#else
# define CR_UNUSED
# define CR_NORETURN
# define CR_INLINE inline
#endif
# define CR_SECTION_START(Name) g_ ## Name ## _section_start
# define CR_SECTION_END(Name) g_ ## Name ## _section_end
#ifdef _WIN32
# define CR_SIZE_T_FORMAT "%Iu"
#else
# define CR_SIZE_T_FORMAT "%zu"
#endif
# define CR_DECL_SECTION_LIMITS(Type, Name) CR_DECL_SECTION_LIMITS_(Type, Name)
# define CR_DECL_SECTION_LIMITS_(Type, Name) \
extern Type CR_SECTION_START_(Name) CR_SECTION_START_SUFFIX(#Name); \
extern Type CR_SECTION_END_(Name) CR_SECTION_END_SUFFIX(#Name)
#ifdef __GNUC__
# define CR_FORMAT(Archetype, Index, Ftc) CR_ATTRIBUTE(format(Archetype, Index, Ftc))
#else
# define CR_FORMAT(Archetype, Index, Ftc)
#endif
# define CR_IMPL_SECTION_LIMITS(Type, Name) \
Type *const CR_SECTION_START(Name) = &CR_SECTION_START_(Name); \
Type *const CR_SECTION_END(Name) = &CR_SECTION_END_(Name)
# ifdef __GNUC__
# define CR_UNUSED CR_ATTRIBUTE(unused)
# define CR_NORETURN CR_ATTRIBUTE(noreturn)
# define CR_INLINE CR_ATTRIBUTE(always_inline) inline
# elif CR_IS_MSVC
# define CR_UNUSED __pragma(warning(suppress:4100))
# define CR_NORETURN __declspec(noreturn)
# define CR_INLINE __forceinline
# else
# define CR_UNUSED
# define CR_NORETURN
# define CR_INLINE inline
# endif
# ifdef _WIN32
# define CR_SIZE_T_FORMAT "%Iu"
# else
# define CR_SIZE_T_FORMAT "%zu"
# endif
# ifdef __GNUC__
# define CR_FORMAT(Archetype, Index, Ftc) CR_ATTRIBUTE(format(Archetype, Index, Ftc))
# else
# define CR_FORMAT(Archetype, Index, Ftc)
# endif
# if defined _WIN32 || defined __CYGWIN__
# ifdef CRITERION_BUILDING_DLL
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllexport)
# else
# define CR_API __declspec(dllexport)
# endif
#if defined _WIN32 || defined __CYGWIN__
# ifdef CRITERION_BUILDING_DLL
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllexport)
# else
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllimport)
# else
# define CR_API __declspec(dllimport)
# endif
# define CR_API __declspec(dllexport)
# endif
# else
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllimport)
# else
# define CR_API __declspec(dllimport)
# endif
# endif
# define CR_LOCAL
#else
# if __GNUC__ >= 4
# define CR_API CR_ATTRIBUTE(visibility("default"))
# define CR_LOCAL CR_ATTRIBUTE(visibility("hidden"))
# else
# define CR_API
# define CR_LOCAL
# else
# if __GNUC__ >= 4
# define CR_API CR_ATTRIBUTE(visibility("default"))
# define CR_LOCAL CR_ATTRIBUTE(visibility("hidden"))
# else
# define CR_API
# define CR_LOCAL
# endif
# endif
#endif
#ifdef __cplusplus
# define CR_STDN std::
#else
# define CR_STDN
#endif
#endif /* !CRITERION_COMMON_H_ */

View file

@ -0,0 +1,41 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_DEPRECATION_H_
#define CRITERION_INTERNAL_DEPRECATION_H_
#define CR_DEPRECATED(Msg) CR_DEPRECATED_(message(Msg))
#ifdef _MSC_VER
# define CR_DEPRECATED_(Msg) __pragma(Msg)
#else
# define CR_DEPRECATED_(Msg) _Pragma(#Msg)
#endif
#ifdef __GNUC__
# define CR_DEPRECATED_MEMBER(Member) Member __attribute__((deprecated))
#else
# define CR_DEPRECATED_MEMBER(Member) Member
#endif
#endif /* !CRITERION_INTERNAL_DEPRECATION_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,104 +22,106 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_DESIGNATED_INITIALIZER_COMPAT_HH_
# define CRITERION_DESIGNATED_INITIALIZER_COMPAT_HH_
#define CRITERION_DESIGNATED_INITIALIZER_COMPAT_HH_
# include "common.h"
#include "common.h"
# define CRITERION_ARG_LENGTH(...) CR_EXPAND(CRITERION_ARG_LENGTH_(__VA_ARGS__,\
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45,\
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26,\
25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,\
5, 4, 3, 2, 1, 0))
# define CRITERION_ARG_LENGTH_(_63, _62, _61, _60, _59, _58, _57, _56, _55, _54, _53, \
_52, _51, _50, _49, _48, _47, _46, _45, _44, _43, _42, _41, _40, _39, _38, \
_37, _36, _35, _34, _33, _32, _31, _30, _29, _28, _27, _26, _25, _24, _23, \
_22, _21, _20, _19, _18, _17, _16, _15, _14, _13, _12, _11, _10, _9, _8, \
_7, _6, _5, _4, _3, _2, _1, count, ...) count
#define CRITERION_ARG_LENGTH(...) \
CR_EXPAND(CRITERION_ARG_LENGTH_(__VA_ARGS__, \
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, \
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, \
25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, \
5, 4, 3, 2, 1, 0))
#define CRITERION_ARG_LENGTH_(_63, _62, _61, _60, _59, _58, _57, _56, _55, _54, _53, \
_52, _51, _50, _49, _48, _47, _46, _45, _44, _43, _42, _41, _40, _39, _38, \
_37, _36, _35, _34, _33, _32, _31, _30, _29, _28, _27, _26, _25, _24, _23, \
_22, _21, _20, _19, _18, _17, _16, _15, _14, _13, _12, _11, _10, _9, _8, \
_7, _6, _5, _4, _3, _2, _1, count, ...) count
# define CRITERION_APPLY_1(Macro, ...)
# define CRITERION_APPLY_2(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_1(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_3(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_2(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_4(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_3(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_5(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_4(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_6(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_5(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_7(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_6(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_8(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_7(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_9(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_8(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_10(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_9(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_11(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_10(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_12(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_11(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_13(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_12(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_14(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_13(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_15(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_14(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_16(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_15(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_17(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_16(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_18(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_17(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_19(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_18(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_20(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_19(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_21(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_20(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_22(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_21(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_23(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_22(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_24(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_23(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_25(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_24(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_26(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_25(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_27(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_26(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_28(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_27(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_29(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_28(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_30(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_29(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_31(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_30(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_32(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_31(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_33(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_32(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_34(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_33(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_35(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_34(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_36(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_35(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_37(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_36(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_38(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_37(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_39(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_38(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_40(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_39(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_41(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_40(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_42(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_41(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_43(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_42(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_44(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_43(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_45(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_44(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_46(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_45(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_47(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_46(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_48(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_47(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_49(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_48(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_50(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_49(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_51(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_50(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_52(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_51(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_53(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_52(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_54(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_53(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_55(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_54(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_56(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_55(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_57(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_56(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_58(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_57(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_59(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_58(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_60(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_59(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_61(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_60(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_62(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_61(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_63(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_62(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_64(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_63(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY_65(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_64(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_1(Macro, ...)
#define CRITERION_APPLY_2(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_1(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_3(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_2(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_4(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_3(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_5(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_4(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_6(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_5(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_7(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_6(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_8(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_7(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_9(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_8(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_10(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_9(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_11(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_10(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_12(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_11(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_13(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_12(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_14(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_13(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_15(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_14(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_16(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_15(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_17(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_16(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_18(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_17(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_19(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_18(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_20(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_19(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_21(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_20(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_22(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_21(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_23(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_22(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_24(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_23(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_25(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_24(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_26(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_25(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_27(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_26(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_28(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_27(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_29(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_28(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_30(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_29(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_31(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_30(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_32(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_31(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_33(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_32(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_34(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_33(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_35(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_34(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_36(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_35(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_37(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_36(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_38(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_37(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_39(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_38(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_40(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_39(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_41(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_40(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_42(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_41(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_43(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_42(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_44(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_43(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_45(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_44(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_46(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_45(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_47(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_46(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_48(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_47(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_49(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_48(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_50(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_49(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_51(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_50(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_52(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_51(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_53(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_52(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_54(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_53(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_55(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_54(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_56(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_55(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_57(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_56(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_58(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_57(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_59(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_58(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_60(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_59(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_61(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_60(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_62(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_61(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_63(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_62(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_64(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_63(Macro, Prefix, __VA_ARGS__))
#define CRITERION_APPLY_65(Macro, Prefix, Head, ...) Macro(Prefix, Head) CR_EXPAND(CRITERION_APPLY_64(Macro, Prefix, __VA_ARGS__))
# define CRITERION_APPLY__(Macro, Prefix, n, ...) CR_EXPAND(CRITERION_APPLY_##n(Macro, Prefix, __VA_ARGS__,))
# define CRITERION_APPLY_(Macro, n, Prefix, ...) CR_EXPAND(CRITERION_APPLY__(Macro, Prefix, n, __VA_ARGS__))
# define CRITERION_APPLY(Macro, ...) CR_EXPAND(CRITERION_APPLY_(Macro, CRITERION_ARG_LENGTH(__VA_ARGS__), __VA_ARGS__))
#define CRITERION_APPLY__(Macro, Prefix, n, ...) CR_EXPAND(CRITERION_APPLY_ ## n(Macro, Prefix, __VA_ARGS__, ))
#define CRITERION_APPLY_(Macro, n, Prefix, ...) CR_EXPAND(CRITERION_APPLY__(Macro, Prefix, n, __VA_ARGS__))
#define CRITERION_APPLY(Macro, ...) CR_EXPAND(CRITERION_APPLY_(Macro, CRITERION_ARG_LENGTH(__VA_ARGS__), __VA_ARGS__))
# define CRITERION_ADD_PREFIX_ONCE(Prefix, Field) Prefix Field;
# define CRITERION_ADD_PREFIX(...) \
#define CRITERION_ADD_PREFIX_ONCE(Prefix, Field) Prefix Field;
#define CRITERION_ADD_PREFIX(...) \
CR_EXPAND(CRITERION_APPLY(CRITERION_ADD_PREFIX_ONCE, __VA_ARGS__))
# ifdef __cplusplus
# define CRITERION_MAKE_STRUCT(Type, ...) []() { \
#ifdef __cplusplus
# define CRITERION_MAKE_STRUCT(Type, ...) \
[]() -> Type { \
Type t; \
std::memset(&t, 0, sizeof (t)); \
CR_EXPAND(CRITERION_ADD_PREFIX(t, __VA_ARGS__)) \
return t; \
}()
# else
# define CRITERION_MAKE_STRUCT(Type, ...) { __VA_ARGS__ }
# endif
} ()
#else
# define CRITERION_MAKE_STRUCT(Type, ...) { __VA_ARGS__ }
#endif
#endif /* !CRITERION_DESIGNATED_INITIALIZER_COMPAT_HH_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,63 +22,62 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_HOOKS_H_
# define CRITERION_INTERNAL_HOOKS_H_
#define CRITERION_INTERNAL_HOOKS_H_
# include "common.h"
# include "../types.h"
#include "common.h"
#include "../types.h"
# define CR_HOOK_IDENTIFIER_(Suffix) CR_HOOK_IDENTIFIER__(__LINE__, Suffix)
# define CR_HOOK_IDENTIFIER__(Line, Suffix) CR_HOOK_IDENTIFIER___(Line, Suffix)
# define CR_HOOK_IDENTIFIER___(Line, Suffix) hook_l ## Line ## _ ## Suffix
#define CR_HOOK_IDENTIFIER_(Suffix) CR_HOOK_IDENTIFIER__(__LINE__, Suffix)
#define CR_HOOK_IDENTIFIER__(Line, Suffix) CR_HOOK_IDENTIFIER___(Line, Suffix)
#define CR_HOOK_IDENTIFIER___(Line, Suffix) hook_l ## Line ## _ ## Suffix
# ifdef __cplusplus
# define CR_HOOK_PROTOTYPE_ \
#ifdef __cplusplus
# define CR_HOOK_PROTOTYPE_ \
extern "C" void CR_HOOK_IDENTIFIER_(impl)
# else
# define CR_HOOK_PROTOTYPE_ \
#else
# define CR_HOOK_PROTOTYPE_ \
void CR_HOOK_IDENTIFIER_(impl)
# endif
#endif
// Section abbreviations
# define CR_HOOK_SECTION_PRE_ALL cr_pra
# define CR_HOOK_SECTION_PRE_SUITE cr_prs
# define CR_HOOK_SECTION_PRE_INIT cr_pri
# define CR_HOOK_SECTION_PRE_TEST cr_prt
# define CR_HOOK_SECTION_ASSERT cr_ast
# define CR_HOOK_SECTION_THEORY_FAIL cr_thf
# define CR_HOOK_SECTION_TEST_CRASH cr_tsc
# define CR_HOOK_SECTION_POST_TEST cr_pot
# define CR_HOOK_SECTION_POST_FINI cr_pof
# define CR_HOOK_SECTION_POST_SUITE cr_pos
# define CR_HOOK_SECTION_POST_ALL cr_poa
/* Section abbreviations */
#define CR_HOOK_SECTION_PRE_ALL cr_pra
#define CR_HOOK_SECTION_PRE_SUITE cr_prs
#define CR_HOOK_SECTION_PRE_INIT cr_pri
#define CR_HOOK_SECTION_PRE_TEST cr_prt
#define CR_HOOK_SECTION_ASSERT cr_ast
#define CR_HOOK_SECTION_THEORY_FAIL cr_thf
#define CR_HOOK_SECTION_TEST_CRASH cr_tsc
#define CR_HOOK_SECTION_POST_TEST cr_pot
#define CR_HOOK_SECTION_POST_FINI cr_pof
#define CR_HOOK_SECTION_POST_SUITE cr_pos
#define CR_HOOK_SECTION_POST_ALL cr_poa
# define CR_HOOK_SECTION(Kind) CR_HOOK_SECTION_ ## Kind
#define CR_HOOK_SECTION(Kind) CR_HOOK_SECTION_ ## Kind
# define CR_HOOK_SECTION_STRINGIFY__(Sec) #Sec
# define CR_HOOK_SECTION_STRINGIFY_(Sec) CR_HOOK_SECTION_STRINGIFY__(Sec)
# define CR_HOOK_SECTION_STRINGIFY(Kind) CR_HOOK_SECTION_STRINGIFY_(CR_HOOK_SECTION(Kind))
#define CR_HOOK_SECTION_STRINGIFY__(Sec) #Sec
#define CR_HOOK_SECTION_STRINGIFY_(Sec) CR_HOOK_SECTION_STRINGIFY__(Sec)
#define CR_HOOK_SECTION_STRINGIFY(Kind) CR_HOOK_SECTION_STRINGIFY_(CR_HOOK_SECTION(Kind))
# define CR_HOOK_PARAM_TYPE_PRE_ALL struct criterion_test_set *
# define CR_HOOK_PARAM_TYPE_PRE_SUITE struct criterion_suite_set *
# define CR_HOOK_PARAM_TYPE_PRE_INIT struct criterion_test *
# define CR_HOOK_PARAM_TYPE_PRE_TEST struct criterion_test *
# define CR_HOOK_PARAM_TYPE_ASSERT struct criterion_assert_stats *
# define CR_HOOK_PARAM_TYPE_THEORY_FAIL struct criterion_theory_stats *
# define CR_HOOK_PARAM_TYPE_TEST_CRASH struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_TEST struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_FINI struct criterion_test_stats *
# define CR_HOOK_PARAM_TYPE_POST_SUITE struct criterion_suite_stats *
# define CR_HOOK_PARAM_TYPE_POST_ALL struct criterion_global_stats *
#define CR_HOOK_PARAM_TYPE_PRE_ALL struct criterion_test_set *
#define CR_HOOK_PARAM_TYPE_PRE_SUITE struct criterion_suite_set *
#define CR_HOOK_PARAM_TYPE_PRE_INIT struct criterion_test *
#define CR_HOOK_PARAM_TYPE_PRE_TEST struct criterion_test *
#define CR_HOOK_PARAM_TYPE_ASSERT struct criterion_assert_stats *
#define CR_HOOK_PARAM_TYPE_THEORY_FAIL struct criterion_theory_stats *
#define CR_HOOK_PARAM_TYPE_TEST_CRASH struct criterion_test_stats *
#define CR_HOOK_PARAM_TYPE_POST_TEST struct criterion_test_stats *
#define CR_HOOK_PARAM_TYPE_POST_FINI struct criterion_test_stats *
#define CR_HOOK_PARAM_TYPE_POST_SUITE struct criterion_suite_stats *
#define CR_HOOK_PARAM_TYPE_POST_ALL struct criterion_global_stats *
# define CR_HOOK_PARAM_TYPE(Kind) CR_HOOK_PARAM_TYPE_ ## Kind
#define CR_HOOK_PARAM_TYPE(Kind) CR_HOOK_PARAM_TYPE_ ## Kind
# define CR_REPORT_HOOK_IMPL(Kind) \
CR_HOOK_PROTOTYPE_(CR_HOOK_PARAM_TYPE(Kind)); \
CR_SECTION_(CR_HOOK_SECTION_STRINGIFY(Kind)) \
f_report_hook CR_HOOK_IDENTIFIER_(func) = \
(f_report_hook) CR_HOOK_IDENTIFIER_(impl) \
CR_SECTION_SUFFIX_; \
#define CR_REPORT_HOOK_IMPL(Kind) \
CR_HOOK_PROTOTYPE_(CR_HOOK_PARAM_TYPE(Kind)); \
CR_SECTION_(CR_HOOK_SECTION_STRINGIFY(Kind)) \
f_report_hook CR_HOOK_IDENTIFIER_(func) = \
(f_report_hook) CR_HOOK_IDENTIFIER_(impl) \
CR_SECTION_SUFFIX_; \
CR_HOOK_PROTOTYPE_
#endif /* !CRITERION_INTERNAL_HOOKS_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,9 +22,9 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_ORDERED_SET_H_
# define CRITERION_ORDERED_SET_H_
#define CRITERION_ORDERED_SET_H_
# include "../types.h"
#include "../types.h"
typedef int (*f_criterion_cmp)(void *, void *);
@ -32,7 +32,7 @@ struct criterion_ordered_set {
struct criterion_ordered_set_node *first;
size_t size;
f_criterion_cmp cmp;
void (*const dtor)(void *, void *);
void(*const dtor)(void *, void *);
};
struct criterion_ordered_set_node {
@ -42,17 +42,17 @@ struct criterion_ordered_set_node {
CR_BEGIN_C_API
CR_API struct criterion_ordered_set *new_ordered_set(f_criterion_cmp cmp,
void (*dtor)(void *, void *));
void (*dtor)(void *, void *));
CR_API void *insert_ordered_set(struct criterion_ordered_set *l,
void *ptr,
size_t size);
void *ptr,
size_t size);
CR_END_C_API
# define FOREACH_SET(Elt, Set) \
#define FOREACH_SET(Elt, Set) \
for (struct criterion_ordered_set_node *n = Set->first; n; n = n->next) \
for (int cond = 1; cond;) \
for (Elt = (void*) (n + 1); cond && (cond = 0, 1);)
for (Elt = (void *) (n + 1); cond && (cond = 0, 1);)
#endif /* !CRITERION_ORDERED_SET_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,51 +22,104 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_PARAMETERIZED_H_
# define CRITERION_INTERNAL_PARAMETERIZED_H_
#define CRITERION_INTERNAL_PARAMETERIZED_H_
# include "test.h"
# include "../types.h"
#include "test.h"
#include "../types.h"
# ifdef __cplusplus
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
struct criterion_test_params {
size_t size;
void *params;
size_t length;
void (*cleanup)(struct criterion_test_params *);
#ifdef __cplusplus
constexpr criterion_test_params(size_t size, void *params, size_t length)
: size(size),
params(params),
length(length),
cleanup(nullptr)
{}
constexpr criterion_test_params(size_t size, void *params, size_t length,
void(*cleanup)(struct criterion_test_params *))
: size(size),
params(params),
length(length),
cleanup(cleanup)
{}
template <typename T>
constexpr criterion_test_params(std::vector<T, criterion::allocator<T> > &vec,
void(*cleanup)(criterion_test_params *) = nullptr)
: size(sizeof (T)),
params(&vec[0]),
length(vec.size()),
cleanup(cleanup)
{}
template <typename T, unsigned int N>
constexpr criterion_test_params(T (&arr)[N],
void(*cleanup)(criterion_test_params *) = nullptr)
: size(sizeof (arr[0])),
params(static_cast<void *>(&arr)),
length(N),
cleanup(cleanup)
{}
#endif
};
#ifdef __cplusplus
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
extern "C" void CR_IDENTIFIER_(Category, Name, impl)(Param)
# else
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
#else
# define CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name) \
void CR_IDENTIFIER_(Category, Name, impl)(Param)
# endif
#endif
# define CR_PARAM_TEST_BASE(Param, Category, Name, ...) \
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name); \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_PARAMETERIZED, \
.param_ = CR_IDENTIFIER_(Category, Name, param), \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
(void(*)(void)) CR_IDENTIFIER_(Category, Name, impl), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
#define CR_PARAM_TEST_BASE(Param, Category, Name, ...) \
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name); \
CR_TEST_TRAMPOLINE_(Category, Name) \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
.compiler_ = CR_COMPILER_, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_PARAMETERIZED, \
.param_ = CR_IDENTIFIER_(Category, Name, param), \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
CR_IDENTIFIER_(Category, Name, jmp), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
CR_PARAM_TEST_PROTOTYPE_(Param, Category, Name)
# define CR_PARAM_TEST_PARAMS(Category, Name) \
#define CR_PARAM_TEST_PARAMS(Category, Name) \
static struct criterion_test_params CR_IDENTIFIER_(Category, Name, param)(void)
# ifdef __cplusplus
# define cr_make_param_array(Type, Array, ...) \
#ifdef __cplusplus
# define cr_make_param_array_(Type, Array, ...) \
criterion_test_params(sizeof (Type), (Array), __VA_ARGS__)
# else
# define cr_make_param_array(Type, Array, ...) \
(struct criterion_test_params) { .size = sizeof (Type), (void*)(Array), __VA_ARGS__ }
# endif
#else
# define cr_make_param_array_(Type, Array, ...) \
(struct criterion_test_params) { .size = sizeof (Type), (void *) (Array), __VA_ARGS__ }
#endif
#undef ParameterizedTest
#define ParameterizedTest(...) CR_EXPAND(CR_PARAM_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
#undef ParameterizedTestParameters
#define ParameterizedTestParameters(Suite, Name) CR_PARAM_TEST_PARAMS(Suite, Name)
#undef cr_make_param_array
#define cr_make_param_array(...) CR_EXPAND(cr_make_param_array_(__VA_ARGS__))
#endif /* !CRITERION_INTERNAL_PARAMETERIZED_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,52 +22,53 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_PREPROCESS_H_
# define CRITERION_PREPROCESS_H_
#define CRITERION_PREPROCESS_H_
# define CR_NOOP do {} while(0)
#define CR_NOOP do {} while (0)
# ifdef __cplusplus
# define CR_NOTHROW throw()
# else
# define CR_NOTHROW
# endif
#ifdef __cplusplus
# define CR_NOTHROW throw ()
#else
# define CR_NOTHROW
#endif
# define CR_EXPAND(x) x
# define CR_IDENTITY(...) __VA_ARGS__
#define CR_EXPAND(x) x
#define CR_IDENTITY(...) __VA_ARGS__
# define CR_STR(x) CR_EXPAND(CR_STR_(x))
# define CR_STR_(x) #x
#define CR_STR(x) CR_EXPAND(CR_STR_(x))
#define CR_STR_(x) #x
# define CR_VA_TAIL(...) CR_EXPAND(CR_VA_TAIL_HELPER(CR_VA_TAIL_SELECT(__VA_ARGS__), __VA_ARGS__))
#define CR_VA_TAIL(...) CR_EXPAND(CR_VA_TAIL_HELPER(CR_VA_TAIL_SELECT(__VA_ARGS__), __VA_ARGS__))
# define CR_VA_TAIL_HELPER(N, ...) CR_EXPAND(CR_VA_TAIL_HELPER_(N, __VA_ARGS__))
# define CR_VA_TAIL_HELPER_(N, ...) CR_EXPAND(CR_VA_TAIL_HELPER_##N(__VA_ARGS__))
# define CR_VA_TAIL_HELPER_1(Head)
# define CR_VA_TAIL_HELPER_2(Head, ...) __VA_ARGS__
#define CR_VA_TAIL_HELPER(N, ...) CR_EXPAND(CR_VA_TAIL_HELPER_(N, __VA_ARGS__))
#define CR_VA_TAIL_HELPER_(N, ...) CR_EXPAND(CR_VA_TAIL_HELPER_ ## N(__VA_ARGS__))
#define CR_VA_TAIL_HELPER_1(Head)
#define CR_VA_TAIL_HELPER_2(Head, ...) __VA_ARGS__
# define CR_VA_HEAD(...) CR_EXPAND(CR_VA_HEAD_HELPER(CR_VA_TAIL_SELECT(__VA_ARGS__), __VA_ARGS__))
#define CR_VA_HEAD(...) CR_EXPAND(CR_VA_HEAD_HELPER(CR_VA_TAIL_SELECT(__VA_ARGS__), __VA_ARGS__))
# define CR_VA_HEAD_HELPER(N, ...) CR_EXPAND(CR_VA_HEAD_HELPER_(N, __VA_ARGS__))
# define CR_VA_HEAD_HELPER_(N, ...) CR_EXPAND(CR_VA_HEAD_HELPER_##N(__VA_ARGS__))
# define CR_VA_HEAD_HELPER_1(Head) Head
# define CR_VA_HEAD_HELPER_2(Head, ...) Head
#define CR_VA_HEAD_HELPER(N, ...) CR_EXPAND(CR_VA_HEAD_HELPER_(N, __VA_ARGS__))
#define CR_VA_HEAD_HELPER_(N, ...) CR_EXPAND(CR_VA_HEAD_HELPER_ ## N(__VA_ARGS__))
#define CR_VA_HEAD_HELPER_1(Head) Head
#define CR_VA_HEAD_HELPER_2(Head, ...) Head
# define CR_VA_TAIL_SELECT(...) CR_EXPAND(CR_VA_TAIL_SELECT64(__VA_ARGS__, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 1, _))
#define CR_VA_TAIL_SELECT(...) \
CR_EXPAND(CR_VA_TAIL_SELECT64(__VA_ARGS__, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 1, _))
# define CR_VA_TAIL_SELECT64( \
#define CR_VA_TAIL_SELECT64( \
_01, _02, _03, _04, _05, _06, _07, _08, _09, _10, \
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
_61, _62, _63, X, ...) X
_61, _62, _63, X, ...) X
#endif /* !CRITERION_PREPROCESS_H_ */

View file

@ -1,48 +1,169 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_REDIRECT_H_
# define CRITERION_INTERNAL_REDIRECT_H_
#define CRITERION_INTERNAL_REDIRECT_H_
# include "common.h"
# include "assert.h"
#include "common.h"
#include "assert.h"
# define cr_assert_redir_op_(Fail, Fun, Op, File, Str, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((File), (Str)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
(CR_STR(File), Str), \
__VA_ARGS__ \
))
CR_BEGIN_C_API
# define cr_assert_redir_op_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_op_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
CR_API int cr_stdout_match_file(CR_STDN FILE *ref);
CR_API int cr_stdout_match_str(const char *ref);
CR_API int cr_stderr_match_file(CR_STDN FILE *ref);
CR_API int cr_stderr_match_str(const char *ref);
# define cr_assert_redir_f_op_(Fail, Fun, Op, File, Ref, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((File), (Ref)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_MATCH, \
(CR_STR(File), CR_STR(Ref)), \
__VA_ARGS__ \
))
CR_END_C_API
# define cr_assert_redir_f_op_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_op_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#define cr_assert_redir_op_(Fail, Fun, Op, File, Str, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((File), (Str)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
(CR_STR(File), Str), \
__VA_ARGS__ \
))
#define cr_assert_redir_op_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_op_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#define cr_assert_redir_f_op_(Fail, Fun, Op, File, Ref, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((File), (Ref)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_MATCH, \
(CR_STR(File), CR_STR(Ref)), \
__VA_ARGS__ \
))
#define cr_assert_redir_f_op_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_f_op_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#undef cr_assert_file_contents_eq_str
#define cr_assert_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, ==, __VA_ARGS__))
#undef cr_expect_file_contents_eq_str
#define cr_expect_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, ==, __VA_ARGS__))
#undef cr_assert_file_contents_neq_str
#define cr_assert_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, !=, __VA_ARGS__))
#undef cr_expect_file_contents_neq_str
#define cr_expect_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, !=, __VA_ARGS__))
#undef cr_assert_file_contents_eq
#define cr_assert_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, ==, __VA_ARGS__))
#undef cr_expect_file_contents_eq
#define cr_expect_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, ==, __VA_ARGS__))
#undef cr_assert_file_contents_neq
#define cr_assert_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, !=, __VA_ARGS__))
#undef cr_expect_file_contents_neq
#define cr_expect_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, !=, __VA_ARGS__))
#undef cr_assert_stdout_eq_str
#define cr_assert_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_str, ==, stdout, __VA_ARGS__))
#undef cr_expect_stdout_eq_str
#define cr_expect_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_str, ==, stdout, __VA_ARGS__))
#undef cr_assert_stdout_neq_str
#define cr_assert_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_str, !=, stdout, __VA_ARGS__))
#undef cr_expect_stdout_neq_str
#define cr_expect_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_str, !=, stdout, __VA_ARGS__))
#undef cr_assert_stderr_eq_str
#define cr_assert_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_str, ==, stderr, __VA_ARGS__))
#undef cr_expect_stderr_eq_str
#define cr_expect_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_str, ==, stderr, __VA_ARGS__))
#undef cr_assert_stderr_neq_str
#define cr_assert_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_str, !=, stderr, __VA_ARGS__))
#undef cr_expect_stderr_neq_str
#define cr_expect_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_str, !=, stderr, __VA_ARGS__))
#undef cr_assert_stdout_eq
#define cr_assert_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_file, ==, stdout, __VA_ARGS__))
#undef cr_expect_stdout_eq
#define cr_expect_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_file, ==, stdout, __VA_ARGS__))
#undef cr_assert_stdout_neq
#define cr_assert_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stdout_match_file, !=, stdout, __VA_ARGS__))
#undef cr_expect_stdout_neq
#define cr_expect_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stdout_match_file, !=, stdout, __VA_ARGS__))
#undef cr_assert_stderr_eq
#define cr_assert_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_file, ==, stderr, __VA_ARGS__))
#undef cr_expect_stderr_eq
#define cr_expect_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_file, ==, stderr, __VA_ARGS__))
#undef cr_assert_stderr_neq
#define cr_assert_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_ABORT_, cr_stderr_match_file, !=, stderr, __VA_ARGS__))
#undef cr_expect_stderr_neq
#define cr_expect_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_unop_va_(CR_FAIL_CONTINUES_, cr_stderr_match_file, !=, stderr, __VA_ARGS__))
#define cr_assert_redir_unop_(Fail, Fun, Op, File, Str, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((Str)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
(CR_STR(File), Str), \
__VA_ARGS__ \
))
#define cr_assert_redir_unop_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_unop_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#define cr_assert_redir_f_unop_(Fail, Fun, Op, File, Ref, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((Ref)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_MATCH, \
(CR_STR(File), CR_STR(Ref)), \
__VA_ARGS__ \
))
#define cr_assert_redir_f_unop_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_f_unop_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#endif /* !CRITERION_INTERNAL_REDIRECT_H_ */

View file

@ -1,138 +1,183 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_STDIO_FILEBUF_HXX_
# define CRITERION_INTERNAL_STDIO_FILEBUF_HXX_
#define CRITERION_INTERNAL_STDIO_FILEBUF_HXX_
# include <fstream>
#include <fstream>
/* *INDENT-OFF* */
namespace criterion { namespace internal {
/* *INDENT-ON* */
template <typename CharT, typename Traits = std::char_traits<CharT>>
class stdio_sync_filebuf : public std::basic_streambuf<CharT, Traits> {
public:
typedef Traits traits;
typedef std::basic_filebuf<CharT, Traits> super;
typedef typename Traits::int_type int_type;
typedef typename Traits::pos_type pos_type;
typedef typename Traits::off_type off_type;
template <typename CharT, typename Traits = std::char_traits<CharT> >
class stdio_sync_filebuf : public std::basic_streambuf<CharT, Traits> {
public:
typedef Traits traits;
typedef std::basic_filebuf<CharT, Traits> super;
typedef typename Traits::int_type int_type;
typedef typename Traits::pos_type pos_type;
typedef typename Traits::off_type off_type;
stdio_sync_filebuf(std::FILE *file)
: file(file)
, lastchar(Traits::eof())
{}
stdio_sync_filebuf(std::FILE *file)
: file(file),
lastchar(Traits::eof())
{}
stdio_sync_filebuf(stdio_sync_filebuf&& other) = default;
stdio_sync_filebuf& operator=(stdio_sync_filebuf&& other) = default;
stdio_sync_filebuf(stdio_sync_filebuf &&other) = default;
stdio_sync_filebuf &operator=(stdio_sync_filebuf &&other) = default;
void swap(stdio_sync_filebuf& other) {
super::swap(other);
std::swap(file, other.file);
std::swap(lastchar, other.lastchar);
}
void swap(stdio_sync_filebuf &other)
{
super::swap(other);
std::swap(file, other.file);
std::swap(lastchar, other.lastchar);
}
protected:
int_type syncgetc();
int_type syncungetc(int_type);
int_type syncputc(int_type);
protected:
int_type syncgetc();
int_type syncungetc(int_type);
int_type syncputc(int_type);
virtual std::streampos seekoff(std::streamoff off,
std::ios_base::seekdir dir,
std::ios_base::openmode = std::ios_base::in | std::ios_base::out) {
virtual std::streampos seekoff(std::streamoff off,
std::ios_base::seekdir dir,
std::ios_base::openmode = std::ios_base::in | std::ios_base::out)
{
int whence;
int whence;
if (dir == std::ios_base::beg)
whence = SEEK_SET;
else if (dir == std::ios_base::cur)
whence = SEEK_CUR;
if (dir == std::ios_base::beg)
whence = SEEK_SET;
else if (dir == std::ios_base::cur)
whence = SEEK_CUR;
else
whence = SEEK_END;
if (!fseek(file, off, whence))
return std::streampos(std::ftell(file));
return std::streamoff(-1);
}
virtual std::streampos seekpos(std::streampos pos,
std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out)
{
return seekoff(std::streamoff(pos), std::ios_base::beg, mode);
}
virtual std::streamsize xsgetn(CharT *s, std::streamsize n);
virtual std::streamsize xsputn(const CharT *s, std::streamsize n);
virtual int sync()
{
return std::fflush(file);
}
virtual int_type underflow()
{
int_type c = syncgetc();
return syncungetc(c);
}
virtual int_type uflow()
{
return lastchar = syncgetc();
}
static inline bool is_eof(int_type c)
{
static const int_type eof = Traits::eof();
return Traits::eq_int_type(c, eof);
}
virtual int_type overflow(int_type c = Traits::eof())
{
int_type ret;
if (is_eof(c)) {
if (std::fflush(file))
ret = Traits::eof();
else
whence = SEEK_END;
if (!fseek(file, off, whence))
return std::streampos(std::ftell(file));
return std::streamoff(-1);
ret = Traits::not_eof(c);
} else {
ret = syncputc(c);
}
virtual std::streampos seekpos(std::streampos pos,
std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out) {
return seekoff(std::streamoff(pos), std::ios_base::beg, mode);
}
virtual std::streamsize xsgetn(CharT* s, std::streamsize n);
virtual std::streamsize xsputn(const CharT* s, std::streamsize n);
virtual int sync() {
return std::fflush(file);
}
virtual int_type underflow() {
int_type c = syncgetc();
return syncungetc(c);
}
virtual int_type uflow() {
return lastchar = syncgetc();
}
static inline bool is_eof(int_type c) {
static const int_type eof = Traits::eof();
return Traits::eq_int_type(c, eof);
}
virtual int_type overflow(int_type c = Traits::eof()) {
int_type ret;
if (is_eof(c)) {
if (std::fflush(file))
ret = Traits::eof();
else
ret = Traits::not_eof(c);
} else {
ret = syncputc(c);
}
return ret;
}
virtual int_type pbackfail(int_type c = Traits::eof()) {
int_type ret = syncungetc(is_eof(c) && !is_eof(lastchar) ? lastchar : c);
lastchar = Traits::eof();
return ret;
}
private:
std::FILE *file;
bool file_open;
int_type lastchar;
};
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncgetc() {
return std::getc(file);
return ret;
}
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncungetc(stdio_sync_filebuf<char>::int_type c) {
return std::ungetc(c, file);
virtual int_type pbackfail(int_type c = Traits::eof())
{
int_type ret = syncungetc(is_eof(c) && !is_eof(lastchar) ? lastchar : c);
lastchar = Traits::eof();
return ret;
}
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncputc(stdio_sync_filebuf<char>::int_type c) {
return std::putc(c, file);
}
private:
std::FILE *file;
bool file_open;
int_type lastchar;
};
template <>
inline std::streamsize
stdio_sync_filebuf<char>::xsgetn(char *s, std::streamsize n) {
std::streamsize res = std::fread(s, 1, n, file);
lastchar = res > 0 ? traits::to_int_type(s[res - 1]) : traits::eof();
return res;
}
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncgetc()
{
return std::getc(file);
}
template <>
inline std::streamsize
stdio_sync_filebuf<char>::xsputn(const char *s, std::streamsize n) {
return std::fwrite(s, 1, n, file);
}
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncungetc(stdio_sync_filebuf<char>::int_type c)
{
return std::ungetc(c, file);
}
template <>
inline stdio_sync_filebuf<char>::int_type
stdio_sync_filebuf<char>::syncputc(stdio_sync_filebuf<char>::int_type c)
{
return std::putc(c, file);
}
template <>
inline std::streamsize
stdio_sync_filebuf<char>::xsgetn(char *s, std::streamsize n)
{
std::streamsize res = std::fread(s, 1, n, file);
lastchar = res > 0 ? traits::to_int_type(s[res - 1]) : traits::eof();
return res;
}
template <>
inline std::streamsize
stdio_sync_filebuf<char>::xsputn(const char *s, std::streamsize n)
{
return std::fwrite(s, 1, n, file);
}
/* *INDENT-OFF* */
}}
/* *INDENT-ON* */
#endif /* !CRITERION_INTERNAL_STDIO_FILEBUF_HXX_ */

View file

@ -1,114 +1,141 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_STREAM_HXX_
# define CRITERION_INTERNAL_STREAM_HXX_
#define CRITERION_INTERNAL_STREAM_HXX_
# include <fstream>
# include <cstdio>
# include <memory>
#include <fstream>
#include <cstdio>
#include <memory>
# include "stdio_filebuf.hxx"
#include "stdio_filebuf.hxx"
/* *INDENT-OFF* */
namespace criterion { namespace internal {
/* *INDENT-ON* */
template <typename CharT, typename Super>
class stream_mixin : public Super {
template <typename CharT, typename Super>
class stream_mixin : public Super {
public:
stream_mixin(FILE* f)
: Super()
, fbuf(new stdio_sync_filebuf<CharT>(f))
, file(f)
{
std::ios::rdbuf(&*fbuf);
}
stream_mixin(FILE *f)
: Super(),
fbuf(new stdio_sync_filebuf<CharT>(f)),
file(f)
{
std::ios::rdbuf(&*fbuf);
}
stream_mixin(const stream_mixin& other) = delete;
stream_mixin& operator=(const stream_mixin& other) = delete;
#if __cplusplus > 199711L
stream_mixin(const stream_mixin &other) = delete;
stream_mixin &operator=(const stream_mixin &other) = delete;
#endif
stream_mixin(stream_mixin&& other) :
fbuf(std::move(other.fbuf)),
file(std::move(other.file))
{}
stream_mixin(stream_mixin &&other) :
fbuf(std::move(other.fbuf)),
file(std::move(other.file))
{}
stream_mixin& operator=(stream_mixin&& other) {
fbuf = std::move(other.fbuf);
file = std::move(other.file);
}
stream_mixin &operator=(stream_mixin &&other)
{
fbuf = std::move(other.fbuf);
file = std::move(other.file);
}
void close(void) {
Super::flush();
Super::close();
std::fclose(file);
}
void close(void)
{
Super::flush();
Super::close();
std::fclose(file);
}
private:
std::shared_ptr<stdio_sync_filebuf<CharT>> fbuf;
std::FILE* file;
};
private:
std::shared_ptr<stdio_sync_filebuf<CharT> > fbuf;
std::FILE *file;
};
template <typename CharT>
using ofstream_mixin = stream_mixin<CharT, std::basic_ofstream<CharT>>;
template <typename CharT>
class basic_ofstream : public stream_mixin<CharT, std::basic_ofstream<CharT> > {
typedef stream_mixin<CharT, std::basic_ofstream<CharT> > super;
public:
basic_ofstream(FILE *f)
: super(f)
{}
template <typename CharT>
using ifstream_mixin = stream_mixin<CharT, std::basic_ifstream<CharT>>;
basic_ofstream(basic_ofstream &&other)
: super(std::move(other))
{}
};
template <typename CharT>
using fstream_mixin = stream_mixin<CharT, std::basic_fstream<CharT>>;
template <typename CharT>
class basic_ifstream : public stream_mixin<CharT, std::basic_ifstream<CharT> > {
typedef stream_mixin<CharT, std::basic_ifstream<CharT> > super;
public:
basic_ifstream(FILE *f)
: super(f)
{}
template <typename CharT>
class basic_ofstream : public ofstream_mixin<CharT> {
public:
basic_ofstream(FILE* f)
: ofstream_mixin<CharT>(f)
{}
basic_ifstream(basic_ifstream &&other)
: super(std::move(other))
{}
};
basic_ofstream(basic_ofstream&& other)
: ofstream_mixin<CharT>(std::move(other))
{}
};
template <typename CharT>
class basic_fstream : public stream_mixin<CharT, std::basic_fstream<CharT> > {
typedef stream_mixin<CharT, std::basic_fstream<CharT> > super;
public:
basic_fstream(FILE *f)
: super(f)
{}
template <typename CharT>
class basic_ifstream : public ifstream_mixin<CharT> {
public:
basic_ifstream(FILE* f)
: ifstream_mixin<CharT>(f)
{}
basic_fstream(basic_fstream &&other)
: super(std::move(other))
{}
};
basic_ifstream(basic_ifstream&& other)
: ifstream_mixin<CharT>(std::move(other))
{}
};
struct get_redirected_out_stream_ {
static inline basic_ofstream<char> &call(std::FILE *f)
{
static std::unique_ptr<basic_ofstream<char> > stream;
template <typename CharT>
class basic_fstream : public fstream_mixin<CharT> {
public:
basic_fstream(FILE* f)
: fstream_mixin<CharT>(f)
{}
if (!stream)
stream.reset(new basic_ofstream<char>(f));
return *stream;
}
};
basic_fstream(basic_fstream&& other)
: fstream_mixin<CharT>(std::move(other))
{}
};
struct get_redirected_in_stream_ {
static inline basic_ifstream<char> &call(std::FILE *f)
{
static std::unique_ptr<basic_ifstream<char> > stream;
struct get_redirected_out_stream_ {
static inline basic_ofstream<char>& call(std::FILE* f) {
static std::unique_ptr<basic_ofstream<char>> stream;
if (!stream)
stream.reset(new basic_ofstream<char>(f));
return *stream;
}
};
struct get_redirected_in_stream_ {
static inline basic_ifstream<char>& call(std::FILE* f) {
static std::unique_ptr<basic_ifstream<char>> stream;
if (!stream)
stream.reset(new basic_ifstream<char>(f));
return *stream;
}
};
if (!stream)
stream.reset(new basic_ifstream<char>(f));
return *stream;
}
};
/* *INDENT-OFF* */
}}
/* *INDENT-ON* */
#endif /* !CRITERION_INTERNAL_STREAM_HXX_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,76 +22,179 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_TEST_H_
# define CRITERION_INTERNAL_TEST_H_
#define CRITERION_INTERNAL_TEST_H_
# include "designated-initializer-compat.h"
# include "common.h"
#include "designated-initializer-compat.h"
#include "common.h"
# define CR_IDENTIFIER_(Category, Name, Suffix) \
#ifdef __OBJC__
# import <Foundation/Foundation.h>
#endif
#ifdef __cplusplus
# include <exception>
#endif
#define CR_IDENTIFIER_(Category, Name, Suffix) \
Category ## _ ## Name ## _ ## Suffix
# ifdef __cplusplus
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJCXX
# else
# define CR_LANG CR_LANG_CXX
# endif
#ifdef __cplusplus
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJCXX
# else
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJC
# else
# define CR_LANG CR_LANG_C
# endif
# define CR_LANG CR_LANG_CXX
# endif
#else
# ifdef __OBJC__
# define CR_LANG CR_LANG_OBJC
# else
# define CR_LANG CR_LANG_C
# endif
#endif
# ifdef __cplusplus
# define CR_TEST_PROTOTYPE_(Category, Name) \
#ifdef __cplusplus
# define CR_TEST_PROTOTYPE_(Category, Name) \
extern "C" void CR_IDENTIFIER_(Category, Name, impl)(void)
# else
# define CR_TEST_PROTOTYPE_(Category, Name) \
#else
# define CR_TEST_PROTOTYPE_(Category, Name) \
void CR_IDENTIFIER_(Category, Name, impl)(void)
# endif
#endif
# define CR_SUITE_IDENTIFIER_(Name, Suffix) \
#define CR_SUITE_IDENTIFIER_(Name, Suffix) \
suite_ ## Name ## _ ## Suffix
# define CR_TEST_BASE(Category, Name, ...) \
CR_TEST_PROTOTYPE_(Category, Name); \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_NORMAL, \
.param_ = (struct criterion_test_params(*)(void)) NULL, \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
CR_IDENTIFIER_(Category, Name, impl), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
CR_BEGIN_C_API
CR_API void criterion_internal_test_setup(void);
CR_API void criterion_internal_test_main(void (*fn)(void));
CR_API void criterion_internal_test_teardown(void);
CR_END_C_API
static const char *const cr_msg_test_init_std_exception = "Caught an unexpected exception during the test initialization: %s.";
static const char *const cr_msg_test_init_other_exception = "Caught some unexpected exception during the test initialization.";
static const char *const cr_msg_test_main_std_exception = "Caught an unexpected exception during the test execution: %s.";
static const char *const cr_msg_test_main_other_exception = "Caught some unexpected exception during the test execution.";
static const char *const cr_msg_test_fini_std_exception = "Caught an unexpected exception during the test finalization: %s.";
static const char *const cr_msg_test_fini_other_exception = "Caught some unexpected exception during the test finalization.";
#ifdef __cplusplus
# define CR_TEST_TRAMPOLINE_(Category, Name) \
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
try { \
criterion_internal_test_setup(); \
} catch (const std::exception &e) { \
criterion_test_die(cr_msg_test_init_std_exception, e.what()); \
} catch (...) { \
criterion_test_die(cr_msg_test_init_other_exception); \
} \
try { \
criterion_internal_test_main((void (*)(void))CR_IDENTIFIER_(Category, Name, impl)); \
} catch (const std::exception &e) { \
criterion_test_die(cr_msg_test_main_std_exception, e.what()); \
} catch (...) { \
criterion_test_die(cr_msg_test_main_other_exception); \
} \
try { \
criterion_internal_test_teardown(); \
} catch (const std::exception &e) { \
criterion_test_die(cr_msg_test_fini_std_exception, e.what()); \
} catch (...) { \
criterion_test_die(cr_msg_test_fini_other_exception); \
} \
}
#else
# if defined (__OBJC__) && defined (__EXCEPTIONS)
# define CR_TEST_TRAMPOLINE_(Category, Name) \
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
@try { \
criterion_internal_test_setup(); \
} @catch (NSException *e) { \
NSString *reason = [e reason]; \
criterion_test_die(cr_msg_test_init_std_exception, [reason UTF8String]); \
} @catch (...) { \
criterion_test_die(cr_msg_test_init_other_exception); \
} \
@try { \
criterion_internal_test_main((void (*)(void))CR_IDENTIFIER_(Category, Name, impl)); \
} @catch (NSException *e) { \
NSString *reason = [e reason]; \
criterion_test_die(cr_msg_test_main_std_exception, [reason UTF8String]); \
} @catch (...) { \
criterion_test_die(cr_msg_test_main_other_exception); \
} \
@try { \
criterion_internal_test_teardown(); \
} @catch (NSException *e) { \
NSString *reason = [e reason]; \
criterion_test_die(cr_msg_test_fini_std_exception, [reason UTF8String]); \
} @catch (...) { \
criterion_test_die(cr_msg_test_fini_other_exception); \
} \
}
# else
# define CR_TEST_TRAMPOLINE_(Category, Name) \
static inline void CR_IDENTIFIER_(Category, Name, jmp)(void) { \
criterion_internal_test_setup(); \
criterion_internal_test_main((void (*)(void))CR_IDENTIFIER_(Category, Name, impl)); \
criterion_internal_test_teardown(); \
}
# endif
#endif
#if defined (_MSC_VER)
# define CR_COMPILER_ CR_COMP_MSVC
#elif defined (__clang__)
# define CR_COMPILER_ CR_COMP_CLANG
#elif defined (__GNUC__)
# define CR_COMPILER_ CR_COMP_GCC
#else
# define CR_COMPILER_ CR_COMP_UNKNOWN
#endif
#define CR_TEST_BASE(Category, Name, ...) \
CR_TEST_PROTOTYPE_(Category, Name); \
CR_TEST_TRAMPOLINE_(Category, Name) \
struct criterion_test_extra_data CR_IDENTIFIER_(Category, Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
.compiler_ = CR_COMPILER_, \
.lang_ = CR_LANG, \
.kind_ = CR_TEST_NORMAL, \
.param_ = (struct criterion_test_params (*)(void))NULL, \
.identifier_ = #Category "/" #Name, \
.file_ = __FILE__, \
.line_ = __LINE__, \
__VA_ARGS__ \
)); \
struct criterion_test CR_IDENTIFIER_(Category, Name, meta) = { \
#Name, \
#Category, \
CR_IDENTIFIER_(Category, Name, jmp), \
&CR_IDENTIFIER_(Category, Name, extra) \
}; \
CR_SECTION_("cr_tst") \
struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \
= &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \
CR_TEST_PROTOTYPE_(Category, Name)
# define CR_SUITE_BASE(Name, ...) \
struct criterion_test_extra_data CR_SUITE_IDENTIFIER_(Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(struct criterion_test_extra_data, \
.file_ = __FILE__, \
.line_ = 0, \
__VA_ARGS__ \
)); \
struct criterion_suite CR_SUITE_IDENTIFIER_(Name, meta) = { \
#Name, \
&CR_SUITE_IDENTIFIER_(Name, extra), \
}; \
CR_SECTION_("cr_sts") \
struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \
= &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_
#define CR_SUITE_BASE(Name, ...) \
struct criterion_test_extra_data CR_SUITE_IDENTIFIER_(Name, extra) = \
CR_EXPAND(CRITERION_MAKE_STRUCT(criterion_test_extra_data, \
.file_ = __FILE__, \
.line_ = 0, \
__VA_ARGS__ \
)); \
struct criterion_suite CR_SUITE_IDENTIFIER_(Name, meta) = { \
#Name, \
&CR_SUITE_IDENTIFIER_(Name, extra), \
}; \
CR_SECTION_("cr_sts") \
struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \
= &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_
#undef Test
#define Test(...) CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
#undef TestSuite
#define TestSuite(...) CR_EXPAND(CR_SUITE_BASE(__VA_ARGS__, .sentinel_ = 0))
#endif /* !CRITERION_INTERNAL_TEST_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,23 +22,24 @@
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_THEORIES_H_
# define CRITERION_INTERNAL_THEORIES_H_
#define CRITERION_INTERNAL_THEORIES_H_
# include "test.h"
#include "test.h"
# ifdef __cplusplus
# include <cstddef>
#ifdef __cplusplus
# include <cstddef>
using std::size_t;
# else
# include <stddef.h>
# endif
#else
# include <stddef.h>
#endif
# ifdef __cplusplus
#ifdef __cplusplus
template <typename... T>
constexpr size_t criterion_va_num__(const T &...) {
return sizeof...(T);
constexpr size_t criterion_va_num__(const T & ...)
{
return sizeof ... (T);
}
# endif
#endif
struct criterion_datapoints {
size_t size;
@ -53,42 +54,51 @@ CR_API void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints,
CR_END_C_API
# ifdef __cplusplus
# define CR_TH_VA_NUM(Type, ...) criterion_va_num__(__VA_ARGS__)
# define CR_TH_TEMP_ARRAY(Type, ...) []() { static Type arr[] = { __VA_ARGS__ }; return &arr; }()
# else
# define CR_TH_VA_NUM(Type, ...) sizeof ((Type[]) { __VA_ARGS__ }) / sizeof (Type)
# define CR_TH_TEMP_ARRAY(Type, ...) &(Type[]) { __VA_ARGS__ }
# endif
#ifdef __cplusplus
# define CR_TH_VA_NUM(Type, ...) criterion_va_num__(__VA_ARGS__)
# define CR_TH_TEMP_ARRAY(Type, ...) []() -> Type * { static Type arr[] = { __VA_ARGS__ }; return reinterpret_cast<Type *>(&arr); } ()
#else
# define CR_TH_VA_NUM(Type, ...) sizeof ((Type[]) { __VA_ARGS__ }) / sizeof (Type)
# define CR_TH_TEMP_ARRAY(Type, ...) & (Type[]) { __VA_ARGS__ }
#endif
# define CR_TH_INTERNAL_TDPS(Category, Name) \
#define CR_TH_INTERNAL_TDPS(Category, Name) \
static struct criterion_datapoints CR_IDENTIFIER_(Category, Name, dps)[]
# define CR_TH_INTERNAL_TDP(Category, Name) \
#define CR_TH_INTERNAL_TDP(Category, Name) \
(CR_IDENTIFIER_(Category, Name, dps))
# define CR_TH_INTERNAL_DP(Type, ...) { \
sizeof (Type), \
CR_EXPAND(CR_TH_VA_NUM(Type, __VA_ARGS__)), \
#Type, \
#define CR_TH_INTERNAL_DP(Type, ...) \
{ \
sizeof (Type), \
CR_EXPAND(CR_TH_VA_NUM(Type, __VA_ARGS__)), \
#Type, \
CR_EXPAND(CR_TH_TEMP_ARRAY(Type, __VA_ARGS__)), \
}
# define CR_NB_DATAPOINTS(Var) \
#define CR_NB_DATAPOINTS(Var) \
(sizeof (Var) / sizeof (struct criterion_datapoints))
# define CR_VAARG_ID(Suffix, Category, Name, ...) \
#define CR_VAARG_ID(Suffix, Category, Name, ...) \
CR_IDENTIFIER_(Category, Name, Suffix)
# define CR_THEORY_BASE(Args, ...) \
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__,))Args; \
CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0)) { \
cr_theory_main( \
CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__,)), \
CR_NB_DATAPOINTS(CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__,))), \
(void(*)(void)) CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__,)) \
); \
} \
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__,))Args
#define CR_THEORY_BASE(Args, ...) \
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) Args; \
CR_EXPAND(CR_TEST_BASE(__VA_ARGS__, .sentinel_ = 0)) { \
cr_theory_main( \
CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__, )), \
CR_NB_DATAPOINTS(CR_EXPAND(CR_VAARG_ID(dps, __VA_ARGS__, ))), \
(void (*)(void))CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) \
); \
} \
void CR_EXPAND(CR_VAARG_ID(theory, __VA_ARGS__, )) Args
#define cr_assume_op_(Op, Actual, Expected) cr_assume((Actual) Op (Expected))
#define cr_assume_str_op_(Op, Actual, Expected) \
cr_assume(strcmp((Actual), (Expected)) Op 0)
#undef Theory
#define Theory(Args, ...) CR_EXPAND(CR_THEORY_BASE(Args, __VA_ARGS__))
#endif /* !CRITERION_INTERNAL_THEORIES_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,19 +21,19 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Logging functions
*****************************************************************************/
#ifndef CRITERION_LOGGING_H_
# define CRITERION_LOGGING_H_
#define CRITERION_LOGGING_H_
# ifdef __cplusplus
# include <cstdarg>
using std::va_list;
# else
# include <stdbool.h>
# include <stdarg.h>
# endif
# include "internal/common.h"
# include "internal/ordered-set.h"
# include "stats.h"
#include "internal/common.h"
#include "internal/ordered-set.h"
#include "internal/deprecation.h"
#include "stats.h"
CR_BEGIN_C_API
enum criterion_logging_level {
CRITERION_INFO = 1,
@ -42,72 +42,66 @@ enum criterion_logging_level {
CRITERION_LOG_LEVEL_QUIET = 1 << 30,
};
enum criterion_logging_prefix {
CRITERION_LOGGING_PREFIX_DASHES,
CRITERION_LOGGING_PREFIX_EQUALS,
CRITERION_LOGGING_PREFIX_RUN,
CRITERION_LOGGING_PREFIX_SKIP,
CRITERION_LOGGING_PREFIX_PASS,
CRITERION_LOGGING_PREFIX_FAIL,
CRITERION_LOGGING_PREFIX_ERR,
enum criterion_severity {
CR_LOG_INFO,
CR_LOG_WARNING,
CR_LOG_ERROR,
};
struct criterion_prefix_data {
const char *prefix;
const char *color;
};
# ifdef CRITERION_LOGGING_COLORS
# define CRIT_COLOR_NORMALIZE(Str) (criterion_options.use_ascii ? "" : Str)
# define CRIT_FG_BOLD "\33[0;1m"
# define CRIT_FG_RED "\33[0;31m"
# define CRIT_FG_GREEN "\33[0;32m"
# define CRIT_FG_GOLD "\33[0;33m"
# define CRIT_FG_BLUE "\33[0;34m"
# define CRIT_RESET "\33[0m"
# define CR_FG_BOLD CRIT_COLOR_NORMALIZE(CRIT_FG_BOLD)
# define CR_FG_RED CRIT_COLOR_NORMALIZE(CRIT_FG_RED)
# define CR_FG_GREEN CRIT_COLOR_NORMALIZE(CRIT_FG_GREEN)
# define CR_FG_GOLD CRIT_COLOR_NORMALIZE(CRIT_FG_GOLD)
# define CR_FG_BLUE CRIT_COLOR_NORMALIZE(CRIT_FG_BLUE)
# define CR_RESET CRIT_COLOR_NORMALIZE(CRIT_RESET)
# endif
CR_BEGIN_C_API
extern const struct criterion_prefix_data g_criterion_logging_prefixes[];
# define CRITERION_PREFIX_DASHES (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_DASHES])
# define CRITERION_PREFIX_EQUALS (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_EQUALS])
# define CRITERION_PREFIX_RUN (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_RUN ])
# define CRITERION_PREFIX_SKIP (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_SKIP ])
# define CRITERION_PREFIX_PASS (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_PASS ])
# define CRITERION_PREFIX_FAIL (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_FAIL ])
# define CRITERION_PREFIX_ERR (&g_criterion_logging_prefixes[CRITERION_LOGGING_PREFIX_ERR ])
CR_API void criterion_vlog(enum criterion_logging_level level, const char *msg, va_list args);
CR_FORMAT(printf, 3, 4)
CR_API void criterion_plog(enum criterion_logging_level level, const struct criterion_prefix_data *prefix, const char *msg, ...);
/**
* Prints a log message
*
* One can use this function, but it is more convenient to use the 3 macros.
*
* @param[in] severity Severity level of the log message
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*
*****************************************************************************/
CR_FORMAT(printf, 2, 3)
CR_API void criterion_log(enum criterion_logging_level level, const char *msg, ...);
CR_API void cr_log(enum criterion_severity severity, const char *msg, ...);
# define criterion_info(...) criterion_log(CRITERION_INFO, __VA_ARGS__)
# define criterion_important(...) criterion_log(CRITERION_IMPORTANT, __VA_ARGS__)
/**
* Prints a info message
*
* Call: cr_log_info(msg, ...)\n
* Prints a info message defined by msg and the following optional parameters
*
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*
*****************************************************************************/
#define cr_log_info(...) cr_log(CR_LOG_INFO, __VA_ARGS__)
# define criterion_pinfo(...) criterion_plog(CRITERION_INFO, __VA_ARGS__)
# define criterion_pimportant(...) criterion_plog(CRITERION_IMPORTANT, __VA_ARGS__)
/**
* Prints a warning message
*
* Call: cr_log_warn(msg, ...)\n
* Prints a warning message defined by msg and the following optional parameters
*
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*
*****************************************************************************/
#define cr_log_warn(...) cr_log(CR_LOG_WARNING, __VA_ARGS__)
# define criterion_perror(...) criterion_plog(CRITERION_IMPORTANT, CRITERION_PREFIX_ERR, __VA_ARGS__)
/**
* Prints a error message
*
* Call: cr_log_error(msg, ...)\n
* Prints a error message defined by msg and the following optional parameters
*
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*
*****************************************************************************/
#define cr_log_error(...) cr_log(CR_LOG_ERROR, __VA_ARGS__)
struct criterion_logger {
void (*log_pre_all )(struct criterion_test_set *set);
void (*log_pre_suite )(struct criterion_suite_set *set);
void (*log_pre_init )(struct criterion_test *test);
void (*log_pre_test )(struct criterion_test *test);
void (*log_pre_init )(struct criterion_suite *suite, struct criterion_test *test);
void (*log_pre_test )(struct criterion_suite *suite, struct criterion_test *test);
void (*log_assert )(struct criterion_assert_stats *stats);
void (*log_theory_fail )(struct criterion_theory_stats *stats);
void (*log_test_timeout )(struct criterion_test_stats *stats);
@ -119,12 +113,64 @@ struct criterion_logger {
void (*log_post_fini )(struct criterion_test_stats *stats);
void (*log_post_suite )(struct criterion_suite_stats *stats);
void (*log_post_all )(struct criterion_global_stats *stats);
void (*log_message )(enum criterion_severity, const char *msg);
};
extern struct criterion_logger normal_logging;
CR_END_C_API
#define CR_NORMAL_LOGGING (&normal_logging)
#define CR_NORMAL_LOGGING (&normal_logging)
#ifdef __cplusplus
# include <sstream>
namespace criterion
{ namespace logging
{
static void(*const log)(enum criterion_severity, const char *, ...) = cr_log;
class streambuf : public std::stringbuf {
public:
streambuf(enum criterion_severity severity__)
: std::stringbuf(), severity__(severity__)
{}
virtual int sync() override
{
criterion::logging::log(severity__, "%s", str().c_str());
str(std::string());
return 0;
}
private:
enum criterion_severity severity__;
};
class stream : public std::ostream {
public:
stream(enum criterion_severity severity__)
: std::ostream(&buf), buf(severity__)
{}
private:
streambuf buf;
};
stream info { CR_LOG_INFO };
stream warn { CR_LOG_WARNING };
stream error { CR_LOG_ERROR };
} }
#endif
/* Deprecated old logging system, schedule removal for 3.0 */
#ifndef CRITERION_NO_COMPAT
# define criterion_log(_, ...) CR_DEPRECATED("criterion_log is deprecated, please use cr_log instead.") cr_log_info(__VA_ARGS__)
# define criterion_info(...) CR_DEPRECATED("criterion_info is deprecated, please use cr_log_info instead.") cr_log_info(__VA_ARGS__)
# define criterion_pinfo(_, ...) CR_DEPRECATED("criterion_pinfo is deprecated, please use cr_log_info instead.") cr_log_info(__VA_ARGS__)
# define criterion_important(...) CR_DEPRECATED("criterion_important is deprecated, please use cr_log_info instead.") cr_log_info(__VA_ARGS__)
# define criterion_pimportant(_, ...) CR_DEPRECATED("criterion_pimportant is deprecated, please use cr_log_info instead.") cr_log_info(__VA_ARGS__)
# define criterion_perror(...) CR_DEPRECATED("criterion_perror is deprecated, please use cr_log_error instead.") cr_log_error(__VA_ARGS__)
#endif /* !CRITERION_NO_COMPAT */
#endif /* !CRITERION_LOGGING_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,28 +21,173 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief criterion options
*****************************************************************************/
#ifndef CRITERION_OPTIONS_H_
# define CRITERION_OPTIONS_H_
#define CRITERION_OPTIONS_H_
# include <stdbool.h>
# include "logging.h"
#include <stdbool.h>
#include "logging.h"
#include "internal/common.h"
enum criterion_debugger {
/**
* Do not run the underlying test in a debugger
*/
CR_DBG_NONE,
/**
* Run the test suspended, without a debugger, and print its PID.
*
* Allows external debuggers to attach.
*/
CR_DBG_IDLE,
/**
* Run the test with a debugging server compatible with the compiler
* it was built with.
*/
CR_DBG_NATIVE,
/**
* Run the test with gdbserver
*/
CR_DBG_GDB,
/**
* Run the test with lldb-server
*/
CR_DBG_LLDB,
/**
* Run the test with windbg in server mode
*/
CR_DBG_WINDBG,
};
struct criterion_options {
/**
* The current logging threshold.
*
* default: 1
*/
enum criterion_logging_level logging_threshold;
/**
* The logger that will be used during the execution of the runner.
*
* default: normal logger
*/
struct criterion_logger *logger;
/**
* This option doesn't do anything and is deprecated.
*/
bool no_early_exit;
/**
* Always return a success from criterion_run_all_tests.
*
* default: false
*/
bool always_succeed;
/**
* Disable unicode and ansi coloring from the logging system.
*
* default: false
*/
bool use_ascii;
/**
* Exit immediately after the first test failure.
*
* default: false
*/
bool fail_fast;
/**
* Disable all tests not matching this extglob pattern.
* if NULL, don't filter tests.
*
* default: NULL
*/
const char *pattern;
/**
* Only print the base file name compound of the source file containing
* the tests during reporting.
*
* default: false
*/
bool short_filename;
/**
* The maximum number of parallel jobs that the test runner will spawn.
* 0 means that this number shall be the number of cores on your system.
*
* default: 0
*/
size_t jobs;
/**
* Measure and report times.
*
* default: true
*/
bool measure_time;
/**
* Whether criterion should wait for incoming connections in server mode
*
* default: false
*/
bool wait_for_clients;
/**
* Raise a debug trap to crash the test if an assert fails so that a
* debugger can gain control.
*
* default: false
*/
bool crash;
/**
* Whether criterion should run its tests in a debugging server.
*
* The server hangs until a connection from a debugger gets accepted.
*
* This forces jobs = 1 and crash = true.
*
* default: CR_DBG_NONE;
*/
enum criterion_debugger debug;
/**
* The TCP port of the debugging server.
*
* default: 1234
*/
unsigned debug_port;
/**
* The default timeout for each test when none is specified, in seconds.
*
* If the value is non-positive, no timeout is applied.
*
* default: 0
*/
double timeout;
};
CR_BEGIN_C_API
extern struct criterion_options criterion_options;
/**
* The runtime options for the test runner.
*/
CR_API extern struct criterion_options criterion_options;
CR_END_C_API

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,14 +21,34 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*!
* @file
* @brief Report functions
*****************************************************************************/
#ifndef CRITERION_OUTPUT_H_
# define CRITERION_OUTPUT_H_
#define CRITERION_OUTPUT_H_
# include "stats.h"
#include "stats.h"
typedef void criterion_reporter(FILE *stream, struct criterion_global_stats *);
typedef void criterion_reporter (FILE *stream, struct criterion_global_stats *);
int criterion_register_output_provider(const char *name, criterion_reporter *reporter);
int criterion_add_output(const char *provider, const char *path);
/**
* Register an output provider.
*
* @param[in] name The name the output provider shall be registered as.
* @param[in] reporter The output reporting function.
* @returns 1 if no output provider is registered at that name, 0 otherwise,
* and -1 on error.
*/
CR_API int criterion_register_output_provider(const char *name, criterion_reporter *reporter);
/**
* Use an output provider to write a report in a specific path.
*
* @param[in] provider The name of a registered output provider.
* @param[in] path The path to the file to write the report to.
* @returns -1 on error.
*/
CR_API int criterion_add_output(const char *provider, const char *path);
#endif /* !CRITERION_OUTPUT_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,24 +21,83 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Parameterized tests
*****************************************************************************/
#ifndef CRITERION_PARAMETERIZED_H_
# define CRITERION_PARAMETERIZED_H_
#define CRITERION_PARAMETERIZED_H_
# include "alloc.h"
# include "assert.h"
# include "internal/parameterized.h"
#include "alloc.h"
#include "assert.h"
# define ParameterizedTest(...) CR_EXPAND(CR_PARAM_TEST_BASE(__VA_ARGS__, .sentinel_ = 0))
/**
* @defgroup ParameterizedBase Parameterized test & generator macros
* @{
*/
# define ParameterizedTestParameters(Category, Name) CR_PARAM_TEST_PARAMS(Category, Name)
/**
* ParameterizedTest(Type *param, Suite, Name, [Options...]) { Function Body }
*
* Defines a new parameterized test.
*
* A parameterized test only takes one parameter -- to pass multiple parameters,
* use a structure type.
*
* @param Type The type of the parameter.
* @param Suite The name of the test suite containing this test.
* @param Name The name of the test.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).
* Example: `.exit_code = 1`
*/
#define ParameterizedTest(Type, Suite, Name, ...) internal
# ifdef __cplusplus
# include <vector>
/**
* Defines the parameter generator prototype for the associated parameterized
* test.
*
* @param Suite The name of the test suite containing the test.
* @param Test The name of the test.
* @returns A constructed instance of criterion::parameters, or the result of
* the cr_make_param_array macro.
*/
#define ParameterizedTestParameters(Suite, Name) internal
namespace criterion {
template <typename T>
using parameters = std::vector<T, criterion::allocator<T>>;
/**
* Constructs a parameter list used as a return value for a parameter generator.
*
* This is only recommended for C sources. For C++, use `criterion::parameters`
* or `criterion_test_params`.
*
* @param Type The type of the array subscript.
* @param Array The array of parameters.
* @param Len The length of the array.
* @param Cleanup The optional cleanup function for the array.
* @returns The parameter list.
*/
#define cr_make_param_array(Type, Array, Len, Cleanup) internal
/** @} */
#ifdef __cplusplus
# include <vector>
namespace criterion
{
/**
* Represents a C++ dynamic parameter list for a parameter generator.
*
* @ingroup ParameterizedBase
*
* @param T The type of the parameter.
*/
template <typename T>
using parameters = std::vector<T, criterion::allocator<T> >;
}
# endif
#endif
#include "internal/parameterized.h"
#endif /* !CRITERION_PARAMETERIZED_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,102 +21,554 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Redirect functions and file asserts
*****************************************************************************/
#ifndef CRITERION_REDIRECT_H_
# define CRITERION_REDIRECT_H_
#define CRITERION_REDIRECT_H_
# include "internal/common.h"
# include "internal/redirect.h"
#include "internal/common.h"
# ifdef __cplusplus
# include <cstdio>
# else
# include <stdio.h>
# endif
#ifdef __cplusplus
# include <cstdio>
#else
# include <stdio.h>
#endif
CR_BEGIN_C_API
/**
* Redirect stdout for testing.
*/
CR_API void cr_redirect_stdout(void);
/**
* Redirect stderr for testing.
*/
CR_API void cr_redirect_stderr(void);
/**
* Redirect stdin for testing.
* This is implicitely called before each test.
*/
CR_API void cr_redirect_stdin(void);
CR_API CR_STDN FILE* cr_get_redirected_stdout(void);
CR_API CR_STDN FILE* cr_get_redirected_stderr(void);
CR_API CR_STDN FILE* cr_get_redirected_stdin(void);
/**
* Get a file handle representing the read-end of the redirected stdout.
*
* @returns the file handle.
*/
CR_API CR_STDN FILE *cr_get_redirected_stdout(void);
CR_API int cr_file_match_str(CR_STDN FILE* f, const char *str);
CR_API int cr_file_match_file(CR_STDN FILE* f, CR_STDN FILE* ref);
/**
* Get a file handle representing the read-end of the redirected stderr.
*
* @returns the file handle.
*/
CR_API CR_STDN FILE *cr_get_redirected_stderr(void);
/**
* Get a file handle representing the write-end of the redirected stdin.
*
* @returns the file handle.
*/
CR_API CR_STDN FILE *cr_get_redirected_stdin(void);
/**
* Compare the contents of a file with a string.
*
* @param[in] f The file to compare the contents to.
* @param[in] str The string to compare the contents to.
* @returns 1 if the contents of the file is equal to the string, 0 otherwise.
*/
CR_API int cr_file_match_str(CR_STDN FILE *f, const char *str);
/**
* Compare the contents of a file with the contents of another file.
*
* @param[in] f The first file to compare the contents to.
* @param[in] ref The second file to compare the contents to.
* @returns 1 if the contents of the files are equal, 0 otherwise.
*/
CR_API int cr_file_match_file(CR_STDN FILE *f, CR_STDN FILE *ref);
/**
* Create a file mock.
*
* @param[in] max_size The maximum size in bytes of the file mock.
* @returns the file handle representing the mock.
*/
CR_API CR_STDN FILE *cr_mock_file_size(size_t max_size);
CR_END_C_API
# define cr_assert_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, ==, __VA_ARGS__))
# define cr_expect_file_contents_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, ==, __VA_ARGS__))
/**
* @defgroup FileAsserts File content assertions
* @{
*/
# define cr_assert_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, !=, __VA_ARGS__))
# define cr_expect_file_contents_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, !=, __VA_ARGS__))
/**
* Passes if the contents of \c File are equal to the string \c ExpectedContents
*
* Passes if the contents of \c File are equal to the string
* \c ExpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_file_contents_eq_str(File, ExpectedContents, FormatString, ...) internal
# define cr_assert_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, ==, __VA_ARGS__))
# define cr_expect_file_contents_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, ==, __VA_ARGS__))
/**
* Passes if the contents of \c File are equal to the string \c ExpectedContents
*
* Passes if the contents of \c File are equal to the string
* \c ExpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_file_contents_eq_str(File, ExpectedContents, FormatString, ...) internal
# define cr_assert_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, !=, __VA_ARGS__))
# define cr_expect_file_contents_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, !=, __VA_ARGS__))
/**
* Passes if the contents of \c File are not equal to the string
* \c UnexpectedContents
*
* Passes if the contents of \c File are not equal to the string
* \c UnexpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_file_contents_neq_str(File, UnexpectedContents, FormatString, ...) internal
# define cr_assert_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, ==, cr_get_redirected_stdout(), __VA_ARGS__))
# define cr_expect_stdout_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, ==, cr_get_redirected_stdout(), __VA_ARGS__))
/**
* Passes if the contents of \c File are not equal to the string
* \c UnexpectedContents
*
* Passes if the contents of \c File are not equal to the string
* \c UnexpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_file_contents_neq_str(File, UnexpectedContents, FormatString, ...) internal
# define cr_assert_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, !=, cr_get_redirected_stdout(), __VA_ARGS__))
# define cr_expect_stdout_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, !=, cr_get_redirected_stdout(), __VA_ARGS__))
/**
* Passes if the contents of \c File are equal to the contents of \c RefFile
*
* Passes if the contents of \c File are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_file_contents_eq(File, RefFile, FormatString, ...) internal
# define cr_assert_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, ==, cr_get_redirected_stderr(), __VA_ARGS__))
# define cr_expect_stderr_eq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, ==, cr_get_redirected_stderr(), __VA_ARGS__))
/**
* Passes if the contents of \c File are equal to the contents of \c RefFile
*
* Passes if the contents of \c File are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_file_contents_eq(File, RefFile, FormatString, ...) internal
# define cr_assert_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_ABORT_, cr_file_match_str, !=, cr_get_redirected_stderr(), __VA_ARGS__))
# define cr_expect_stderr_neq_str(...) CR_EXPAND(cr_assert_redir_op_va_(CR_FAIL_CONTINUES_, cr_file_match_str, !=, cr_get_redirected_stderr(), __VA_ARGS__))
/**
* Passes if the contents of \c File are not equal to the contents of
* \c RefFile
*
* Passes if the contents of \c File are not equal to the contents of
* \c RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_file_contents_neq(File, RefFile, FormatString, ...) internal
# define cr_assert_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, ==, cr_get_redirected_stdout(), __VA_ARGS__))
# define cr_expect_stdout_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, ==, cr_get_redirected_stdout(), __VA_ARGS__))
/**
* Passes if the contents of \c File are not equal to the contents of
* \c RefFile
*
* Passes if the contents of \c File are not equal to the contents of
* \c RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] File Pointer to a FILE object that specifies an input stream
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_file_contents_neq(File, RefFile, FormatString, ...) internal
# define cr_assert_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, !=, cr_get_redirected_stdout(), __VA_ARGS__))
# define cr_expect_stdout_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, !=, cr_get_redirected_stdout(), __VA_ARGS__))
/**@}*/
# define cr_assert_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, ==, cr_get_redirected_stderr(), __VA_ARGS__))
# define cr_expect_stderr_eq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, ==, cr_get_redirected_stderr(), __VA_ARGS__))
/**
* @defgroup StreamAsserts Standard stream assertions
* @{
*/
# define cr_assert_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_ABORT_, cr_file_match_file, !=, cr_get_redirected_stderr(), __VA_ARGS__))
# define cr_expect_stderr_neq(...) CR_EXPAND(cr_assert_redir_f_op_va_(CR_FAIL_CONTINUES_, cr_file_match_file, !=, cr_get_redirected_stderr(), __VA_ARGS__))
/**
* Passes if the contents of \c stdout are equal to the contents of the string
* \c ExpectedContents
*
* Passes if the contents of \c stdout are equal to the contents of the string
* \c ExpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stdout_eq_str(ExpectedContents, FormatString, ...) internal
# ifdef __cplusplus
# include "internal/stream.hxx"
/**
* Passes if the contents of \c stdout are equal to the contents of the string
* \c ExpectedContents
*
* Passes if the contents of \c stdout are equal to the contents of the string
* \c ExpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stdout_eq_str(ExpectedContents, FormatString, ...) internal
namespace criterion {
/**
* Passes if the contents of \c stdout are not equal to the contents of the
* string \c UnexpectedContents
*
* Passes if the contents of \c stdout are not equal to the contents of the
* string \c UnexpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stdout_neq_str(UnexpectedContents, FormatString, ...) internal
using ofstream = internal::basic_ofstream<char>;
using ifstream = internal::basic_ifstream<char>;
using fstream = internal::basic_fstream<char>;
/**
* Passes if the contents of \c stdout are not equal to the contents of the
* string \c UnexpectedContents
*
* Passes if the contents of \c stdout are not equal to the contents of the
* string \c UnexpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stdout_neq_str(UnexpectedContents, FormatString, ...) internal
static inline ofstream& get_redirected_cin(void) {
return internal::get_redirected_out_stream_::call(cr_get_redirected_stdin());
}
/**
* Passes if the contents of \c stderr are equal to the contents of the string
* \c ExpectedContents
*
* Passes if the contents of \c stderr are equal to the contents of the string
* \c ExpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stderr_eq_str(ExpectedContents, FormatString, ...) internal
static inline ifstream& get_redirected_cout(void) {
return internal::get_redirected_in_stream_::call(cr_get_redirected_stdout());
}
/**
* Passes if the contents of \c stderr are equal to the contents of the string
* \c ExpectedContents
*
* Passes if the contents of \c stderr are equal to the contents of the string
* \c ExpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] ExpectedContents C string with the ExpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stderr_eq_str(ExpectedContents, FormatString, ...) internal
static inline ifstream& get_redirected_cerr(void) {
return internal::get_redirected_in_stream_::call(cr_get_redirected_stderr());
}
/**
* Passes if the contents of \c stderr are not equal to the contents of the
* string \c UnexpectedContents
*
* Passes if the contents of \c stderr are not equal to the contents of the
* string \c UnexpectedContents.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stderr_neq_str(UnexpectedContents, FormatString, ...) internal
# if __GNUC__ >= 5
static inline fstream mock_file(size_t max_size) {
return fstream(cr_mock_file_size(max_size));
}
/**
* Passes if the contents of \c stderr are not equal to the contents of the
* string \c UnexpectedContents
*
* Passes if the contents of \c stderr are not equal to the contents of the
* string \c UnexpectedContents.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] UnexpectedContents C string with the UnexpectedContents
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stderr_neq_str(UnexpectedContents, FormatString, ...) internal
static inline fstream mock_file(void) {
return mock_file(4096);
}
# endif
/**
* Passes if the contents of \c stdout are equal to the contents of \c RefFile
*
* Passes if the contents of \c stdout are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stdout_eq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stdout are equal to the contents of \c RefFile
*
* Passes if the contents of \c stdout are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stdout_eq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stdout are not equal to the contents of \c
* RefFile
*
* Passes if the contents of \c stdout are not equal to the contents of \c
* RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stdout_neq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stdout are not equal to the contents of \c
* RefFile
*
* Passes if the contents of \c stdout are not equal to the contents of \c
* RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stdout_neq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stderr are equal to the contents of \c RefFile
*
* Passes if the contents of \c stderr are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stderr_eq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stderr are equal to the contents of \c RefFile
*
* Passes if the contents of \c stderr are equal to the contents of \c RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stderr_eq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stderr are not equal to the contents of \c
* RefFile
*
* Passes if the contents of \c stderr are not equal to the contents of \c
* RefFile.
* Otherwise the test is marked as failure and the execution of the function
* is aborted.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_assert_stderr_neq(RefFile, FormatString, ...) internal
/**
* Passes if the contents of \c stderr are not equal to the contents of \c
* RefFile
*
* Passes if the contents of \c stderr are not equal to the contents of \c
* RefFile.
* Otherwise the test is marked as failure but the execution will continue.
*
* The optional string is printed on failure.
*
* @param[in] RefFile Pointer to a FILE object that specifies an input stream
* @param[in] FormatString (optional) printf-like format string
* @param[in] ... (optional) format string parameters
*
*****************************************************************************/
#define cr_expect_stderr_neq(RefFile, FormatString, ...) internal
/**@}*/
#ifdef __cplusplus
# include "internal/stream.hxx"
namespace criterion
{
typedef internal::basic_ofstream<char> ofstream;
typedef internal::basic_ifstream<char> ifstream;
typedef internal::basic_fstream<char> fstream;
static inline ofstream &get_redirected_cin(void)
{
return internal::get_redirected_out_stream_::call(cr_get_redirected_stdin());
}
static inline ifstream &get_redirected_cout(void)
{
return internal::get_redirected_in_stream_::call(cr_get_redirected_stdout());
}
static inline ifstream &get_redirected_cerr(void)
{
return internal::get_redirected_in_stream_::call(cr_get_redirected_stderr());
}
# if __GNUC__ >= 5
static inline fstream mock_file(size_t max_size)
{
return fstream(cr_mock_file_size(max_size));
}
static inline fstream mock_file(void)
{
return mock_file(4096);
}
# endif
}
#endif
#include "internal/redirect.h"
#endif /* !CRITERION_REDIRECT_H_ */

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,10 +21,21 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*!
* @file
* @brief Test stats
*****************************************************************************/
#ifndef CRITERION_STATS_H_
# define CRITERION_STATS_H_
#define CRITERION_STATS_H_
# include "types.h"
#include "types.h"
#include "internal/deprecation.h"
enum criterion_test_status {
CR_STATUS_PASSED = 0,
CR_STATUS_FAILED = 1,
CR_STATUS_SKIPPED = 2,
};
struct criterion_assert_stats {
const char *message;
@ -38,7 +49,8 @@ struct criterion_assert_stats {
struct criterion_test_stats {
struct criterion_test *test;
struct criterion_assert_stats *asserts;
bool failed;
bool CR_DEPRECATED_MEMBER(failed);
enum criterion_test_status test_status;
int passed_asserts;
int failed_asserts;
int signal;
@ -48,6 +60,7 @@ struct criterion_test_stats {
bool crashed;
unsigned progress;
const char *file;
const char *message;
struct criterion_test_stats *next;
};

View file

@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015 Franklin "Snaipe" Mathieu <http://snai.pe/>
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -21,80 +21,380 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*!
* @file
* @brief Theory tests
*****************************************************************************/
#ifndef CRITERION_THEORIES_H_
# define CRITERION_THEORIES_H_
#define CRITERION_THEORIES_H_
# include "criterion.h"
# include "internal/theories.h"
#include "criterion.h"
CR_BEGIN_C_API
/**
* Aborts the current theory iteration.
* This function does not return.
*/
CR_API void cr_theory_abort(void);
CR_END_C_API
// Theory and datapoint macros
/**
* @defgroup TheoryBase Theory and datapoint macros
* @{
*/
# define Theory(Args, ...) CR_EXPAND(CR_THEORY_BASE(Args, __VA_ARGS__))
/**
* Defines a new theory test.
*
* The parameters are selected from a cartesian product defined by a
* TheoryDataPoints macro.
*
* Example:
* @code{.c}
* Theory((int arg0, double arg1), suite, test) {
* // function body
* };
* @endcode
*
* @param Params A list of function parameters.
* @param Suite The name of the test suite containing this test.
* @param Name The name of the test.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).
* Example: .exit_code = 1
*/
#define Theory(Params, Suite, Name, ...) internal
# define TheoryDataPoints(Category, Name) CR_TH_INTERNAL_TDPS(Category, Name)
# define TheoryDataPoint(Category, Name) CR_TH_INTERNAL_TDP(Category, Name)
# define DataPoints(Type, ...) CR_EXPAND(CR_TH_INTERNAL_DP(Type, __VA_ARGS__))
/**
* Defines an array of data points.
*
* The types of the specified data points *must* match the types of the
* associated theory.
*
* Each entry in the array must be the result of the `DataPoints` macro.
*
* Example:
* @code{.c}
* TheoryDataPoints(suite, test) = {
* DataPoints(int, 1, 2, 3), // first theory parameter
* DataPoints(double, 4.2, 0, -INFINITY), // second theory parameter
* };
* @endcode
*
* @param Suite The name of the test suite containing this test.
* @param Name The name of the test.
*/
#define TheoryDataPoints(Suite, Name) CR_TH_INTERNAL_TDPS(Suite, Name)
// Theory invariants
/**
* Defines a new set of data points.
*
* @param Type The type of each data point in the set.
* @param ... The data points in the set.
*/
#define DataPoints(Type, ...) CR_EXPAND(CR_TH_INTERNAL_DP(Type, __VA_ARGS__))
# define cr_assume(Condition) \
do { \
if (!(Condition)) \
cr_theory_abort(); \
/**@}*/
/**
* @defgroup TheoryInvariants Theory invariants
* @{
*/
/**
* Assumes `Condition` is true
*
* Evaluates `Condition` and continues execution if it is true.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Condition Condition to test
*
*****************************************************************************/
#define cr_assume(Condition) \
do { \
if (!(Condition)) \
cr_theory_abort(); \
} while (0)
# define cr_assume_not(Condition) cr_assume(!(Condition))
/**
* Assumes `Condition` is false
*
* Evaluates `Condition` and continues execution if it is false.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Condition Condition to test
*
*****************************************************************************/
#define cr_assume_not(Condition) cr_assume(!(Condition))
# define cr_assume_op_(Op, Actual, Expected) cr_assume((Actual) Op (Expected))
# define cr_assume_eq(Actual, Expected) cr_assume_op_(==, Actual, Expected)
# define cr_assume_neq(Actual, Expected) cr_assume_op_(!=, Actual, Expected)
# define cr_assume_gt(Actual, Expected) cr_assume_op_(>, Actual, Expected)
# define cr_assume_geq(Actual, Expected) cr_assume_op_(>=, Actual, Expected)
# define cr_assume_lt(Actual, Expected) cr_assume_op_(<, Actual, Expected)
# define cr_assume_leq(Actual, Expected) cr_assume_op_(<=, Actual, Expected)
/**
* Assumes `Actual` is equal to `Expected`
*
* Continues execution if `Actual` is equal to `Expected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Expected Expected value
*
*****************************************************************************/
#define cr_assume_eq(Actual, Expected) cr_assume_op_(==, Actual, Expected)
# define cr_assume_null(Value) cr_assume_eq(Value, NULL)
# define cr_assume_not_null(Value) cr_assume_neq(Value, NULL)
/**
* Assumes `Actual` is not equal to `Unexpected`
*
* Continues execution if `Actual` is not equal to `Unexpected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Unexpected Unexpected value
*
*****************************************************************************/
#define cr_assume_neq(Actual, Unexpected) cr_assume_op_(!=, Actual, Unexpected)
# define cr_assume_float_eq(Actual, Expected, Epsilon) \
cr_assume((Expected) - (Actual) <= (Epsilon) \
&& (Actual) - (Expected) <= (Epsilon))
/**
* Assumes `Actual` is greater than `Reference`
*
* Continues execution if `Actual` is greater than `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_gt(Actual, Reference) cr_assume_op_(>, Actual, Reference)
# define cr_assume_float_neq(Actual, Expected, Epsilon) \
cr_assume((Expected) - (Actual) > (Epsilon) \
|| (Actual) - (Expected) > (Epsilon))
/**
* Assumes `Actual` is greater or equal to `Reference`
*
* Continues execution if `Actual` is greater or equal to `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_geq(Actual, Reference) cr_assume_op_(>=, Actual, Reference)
# define cr_assume_str_op_(Op, Actual, Expected) \
cr_assume(strcmp((Actual), (Expected)) Op 0)
/**
* Assumes `Actual` is less than `Reference`
*
* Continues execution if `Actual` is less than `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_lt(Actual, Reference) cr_assume_op_(<, Actual, Reference)
# define cr_assume_str_eq(Actual, Expected) cr_assume_str_op_(==, Actual, Expected)
# define cr_assume_str_neq(Actual, Expected) cr_assume_str_op_(!=, Actual, Expected)
# define cr_assume_str_lt(Actual, Expected) cr_assume_str_op_(<, Actual, Expected)
# define cr_assume_str_leq(Actual, Expected) cr_assume_str_op_(<=, Actual, Expected)
# define cr_assume_str_gt(Actual, Expected) cr_assume_str_op_(>, Actual, Expected)
# define cr_assume_str_geq(Actual, Expected) cr_assume_str_op_(>=, Actual, Expected)
/**
* Assumes `Actual` is less or equal to `Reference`
*
* Continues execution if `Actual` is less or equal to `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_leq(Actual, Reference) cr_assume_op_(<=, Actual, Reference)
# define cr_assume_arr_eq(Actual, Expected, Size) cr_assume(!memcmp((A), (B), (Size)))
# define cr_assume_arr_neq(Actual, Expected, Size) cr_assume(memcmp((A), (B), (Size)))
/**
* Assumes `Value` is NULL.
*
* Continues execution if `Value` is NULL.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Value Value to test
*
*****************************************************************************/
#define cr_assume_null(Value) cr_assume_eq(Value, NULL)
// Deprecated
/**
* Assumes `Value` is not NULL.
*
* Continues execution if `Value` is not NULL.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Value Value to test
*
*****************************************************************************/
#define cr_assume_not_null(Value) cr_assume_neq(Value, NULL)
# ifndef CRITERION_NO_COMPAT
# define cr_assume_strings_eq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_eq, cr_assume_str_eq) cr_assume_str_eq(__VA_ARGS__)
# define cr_assume_strings_neq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_neq, cr_assume_str_neq) cr_assume_str_neq(__VA_ARGS__)
# define cr_assume_strings_lt(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_lt, cr_assume_str_lt) cr_assume_str_lt(__VA_ARGS__)
# define cr_assume_strings_leq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_leq, cr_assume_str_leq) cr_assume_str_leq(__VA_ARGS__)
# define cr_assume_strings_gt(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_gt, cr_assume_str_gt) cr_assume_str_gt(__VA_ARGS__)
# define cr_assume_strings_geq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_geq, cr_assume_str_geq) cr_assume_str_geq(__VA_ARGS__)
/**
* Assumes `Actual` is equal to `Expected` with a tolerance of `Epsilon`
*
* Continues execution if `Actual` is equal to `Expected` with a tolerance of Epsilon.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @note Use this to test equality between floats
*
* @param[in] Actual Value to test
* @param[in] Expected Expected value
* @param[in] Epsilon Tolerance between Actual and Expected
*
*****************************************************************************/
#define cr_assume_float_eq(Actual, Expected, Epsilon) \
cr_assume((Expected) - (Actual) <= (Epsilon) \
&& (Actual) - (Expected) <= (Epsilon))
# define cr_assume_arrays_eq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_arrays_eq, cr_assume_arr_eq) cr_assume_arr_eq(__VA_ARGS__)
# define cr_assume_arrays_neq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_arrays_neq, cr_assume_arr_neq) cr_assume_arr_neq(__VA_ARGS__)
# endif
/**
* Assumes `Actual` is not equal to `Expected` with a tolerance of `Epsilon`
*
* Continues execution if `Actual` is not equal to `Expected` with a tolerance of Epsilon.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @note Use this to test equality between floats
*
* @param[in] Actual Value to test
* @param[in] Expected Expected value
* @param[in] Epsilon Tolerance between Actual and Expected
*
*****************************************************************************/
#define cr_assume_float_neq(Actual, Expected, Epsilon) \
cr_assume((Expected) - (Actual) > (Epsilon) \
|| (Actual) - (Expected) > (Epsilon))
/**
* Assumes `Actual` is lexicographically equal to `Expected`
*
* Continues execution if `Actual` is lexicographically equal to `Expected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual String to test
* @param[in] Expected Expected string
*
*****************************************************************************/
#define cr_assume_str_eq(Actual, Expected) cr_assume_str_op_(==, Actual, Expected)
/**
* Assumes `Actual` is not lexicographically equal to `Unexpected`
*
* Continues execution if `Actual` is not lexicographically equal to `Unexpected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual String to test
* @param[in] Unexpected Unexpected string
*
*****************************************************************************/
#define cr_assume_str_neq(Actual, Unexpected) cr_assume_str_op_(!=, Actual, Unexpected)
/**
* Assumes `Actual` is lexicographically less than `Reference`
*
* Continues execution if `Actual` is lexicographically less than `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_str_lt(Actual, Reference) cr_assume_str_op_(<, Actual, Reference)
/**
* Assumes `Actual` is lexicographically less or equal to `Reference`
*
* Continues execution if `Actual` is lexicographically less or equal to `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_str_leq(Actual, Reference) cr_assume_str_op_(<=, Actual, Reference)
/**
* Assumes `Actual` is lexicographically greater than `Reference`
*
* Continues execution if `Actual` is lexicographically greater than `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_str_gt(Actual, Reference) cr_assume_str_op_(>, Actual, Reference)
/**
* Assumes `Actual` is lexicographically greater or equal to `Reference`
*
* Continues execution if `Actual` is lexicographically greater or equal to `Reference`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @param[in] Actual Value to test
* @param[in] Reference Reference value
*
*****************************************************************************/
#define cr_assume_str_geq(Actual, Reference) cr_assume_str_op_(>=, Actual, Reference)
/**
* Assumes `Actual` is byte-to-byte equal to `Expected`
*
* Continues execution if `Actual` is byte-to-byte equal to `Expected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @warning This should not be used on struct arrays
*
* @param[in] Actual Array to test
* @param[in] Expected Expected array
* @param[in] Size The size of both arrays
*
*****************************************************************************/
#define cr_assume_arr_eq(Actual, Expected, Size) cr_assume(!memcmp((Actual), (Expected), (Size)))
/**
* Assumes `Actual` is not byte-to-byte equal to `Unexpected`
*
* Continues execution if `Actual` is not byte-to-byte equal to `Unexpected`.
* Otherwise the current theory iteration aborts without marking the test as
* failure.
*
* @warning This should not be used on struct arrays
*
* @param[in] Actual Array to test
* @param[in] Unexpected Unexpected array
* @param[in] Size The size of both arrays
*
*****************************************************************************/
#define cr_assume_arr_neq(Actual, Unexpected, Size) cr_assume(memcmp((Actual), (Unexpected), (Size)))
/**@}*/
/* Deprecated */
#ifndef CRITERION_NO_COMPAT
# define cr_assume_strings_eq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_eq, cr_assume_str_eq) cr_assume_str_eq(__VA_ARGS__)
# define cr_assume_strings_neq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_neq, cr_assume_str_neq) cr_assume_str_neq(__VA_ARGS__)
# define cr_assume_strings_lt(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_lt, cr_assume_str_lt) cr_assume_str_lt(__VA_ARGS__)
# define cr_assume_strings_leq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_leq, cr_assume_str_leq) cr_assume_str_leq(__VA_ARGS__)
# define cr_assume_strings_gt(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_gt, cr_assume_str_gt) cr_assume_str_gt(__VA_ARGS__)
# define cr_assume_strings_geq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_strings_geq, cr_assume_str_geq) cr_assume_str_geq(__VA_ARGS__)
# define cr_assume_arrays_eq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_arrays_eq, cr_assume_arr_eq) cr_assume_arr_eq(__VA_ARGS__)
# define cr_assume_arrays_neq(...) CRITERION_ASSERT_DEPRECATED_B(cr_assume_arrays_neq, cr_assume_arr_neq) cr_assume_arr_neq(__VA_ARGS__)
#endif
#include "internal/theories.h"
#endif /* !CRITERION_THEORIES_H_ */

Some files were not shown because too many files have changed in this diff Show more