Commit Graph

46 Commits

Author SHA1 Message Date
Mark VanderVoord a60383ec34 Update licenses to new standards... plus New Years bump 2025-01-01 12:05:55 -05:00
Mark VanderVoord 0b28344d23 bump version 2023-02-06 16:13:29 -05:00
Mark VanderVoord 16d12416fd Force ourselves to test with Ruby 3.
Fix some issues that have been lurking.
2023-01-09 14:16:30 -05:00
Krzysztof Chruscinski 9b9f93ff7d Ensure alignment of CMock_Guts_Buffer
Another attempt to fix something that was previously fixed by
73255670 but got reversed due to breaking something else.

The issue is that CMock_Guts_Buffer was unsigned char thus it
may have been unaligned (byte aligned). Portions from this buffer
where casted to a structure. On certain architectures alignment
must be maintained when accessing 32bit or 64 bit data and that
was not maintained with byte aligned array.

Instead of using attribute that may be complier specific, changing
type of array to long long.
2022-05-30 13:18:46 +02:00
Mark VanderVoord 3d4ba8d20b Grab latest unity.
Bump Version.
2021-06-18 14:43:57 -04:00
Mark VanderVoord aa5113e012 Update apt-get in the hopes that this makes multilib happy. 2021-01-29 10:12:40 -05:00
Mark VanderVoord 4dd557f2df Merge pull request #311 from andred/master
allow compilation with stricter warnings
2021-01-07 18:02:24 -05:00
Michael Brockus 3e28a5412d use files method 2020-08-06 13:26:00 -07:00
André Draszik 7ee27d6891 cmock: annotate pure & const APIs (fix Wsuggest-attribute= warnings)
GCC (& Clang) have the notion of pure and const functions [1],
where those attributes are intended to help the optimiser.

Annotate a few APIs here with the appropriate key words, which
also fixes Wsuggest-attribute=pure and Wsuggest-attribute=const
warnings, which a source base might have enabled:

.../src/cmock.c: In function ‘CMock_Guts_MemNext’:
.../src/cmock.c:118:22: warning: function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure]
  118 | CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNext(CMOCK_MEM_INDEX_TYPE previous_item_index)
      |                      ^~~~~~~~~~~~~~~~~~
.../src/cmock.c: In function ‘CMock_Guts_MemEndOfChain’:
.../src/cmock.c:140:22: warning: function might be candidate for attribute ‘pure’ if it is known to return normally [-Wsuggest-attribute=pure]
  140 | CMOCK_MEM_INDEX_TYPE CMock_Guts_MemEndOfChain(CMOCK_MEM_INDEX_TYPE root_index)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~
.../src/cmock.c: In function ‘CMock_Guts_GetAddressFor’:
.../src/cmock.c:158:7: warning: function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure]
  158 | void* CMock_Guts_GetAddressFor(CMOCK_MEM_INDEX_TYPE index)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
.../src/cmock.c: In function ‘CMock_Guts_MemBytesCapacity’:
.../src/cmock.c:173:22: warning: function might be candidate for attribute ‘const’ [-Wsuggest-attribute=const]
  173 | CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesCapacity(void)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~
.../src/cmock.c: In function ‘CMock_Guts_MemBytesFree’:
.../src/cmock.c:181:22: warning: function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure]
  181 | CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesFree(void)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~
.../src/cmock.c: In function ‘CMock_Guts_MemBytesUsed’:
.../src/cmock.c:189:22: warning: function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure]
  189 | CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesUsed(void)
      |                      ^~~~~~~~~~~~~~~~~~~~~~~

[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Signed-off-by: André Draszik <git@andred.net>
2020-05-25 15:39:21 +01:00
Mark VanderVoord 7ec556d209 Bump Version 2020-05-03 16:10:55 -04:00
Tuc-An d78b5e4ab6 change CMOCK_MEM_INDEX_TYPE default type to size_t 2020-03-25 07:19:54 -04:00
Tuc-An 24daea45ab switch comments to C-style to improve compatibility with pre-C99 and match unity 2020-03-25 05:41:14 -04:00
Michael Brockus 4d0ea1afda Update meson.build 2020-01-27 23:18:39 -08:00
mvandervoord 543c230f33 bump version 2019-11-12 18:27:33 -05:00
John Lindgren c787042e6d Fix off-by-one error in out-of-memory check.
We should be able to allocate up to CMock_Guts_MemBytesFree() minus
CMOCK_MEM_INDEX_SIZE.  An incorrect less-than-or-equal prevented
allocating the very last byte.
2019-10-30 10:30:25 -04:00
John Lindgren ea71fb0e0e CMock_Guts_MemBytesUsed() should return 0 initially.
Set CMock_Guts_FreePtr to CMOCK_MEM_ALIGN_SIZE initially (the same
value it is reset to by CMock_Guts_MemFreeAll().  This makes sure
that the value returned by CMock_Guts_MemBytesUsed() is 0 initially
and not a negative value.
2019-10-30 10:22:05 -04:00
John Lindgren 74fa13f6a0 CMOCK_MEM_ALIGN should not change depending on #include order.
The value of CMOCK_MEM_ALIGN changed depending on whether unity.h
or cmock.h was included first.  Since cmock_internals.h uses
features from unity.h, it should include unity.h.
2019-10-30 10:14:30 -04:00
mvandervoord cda809765e Protect again memory overruns.
Get rid of warnings.
2019-10-23 17:12:18 -04:00
Mark VanderVoord b90706424a Switching to universal version being in the header file itself. 2019-10-21 10:13:19 -04:00
Mark VanderVoord bc8e20e88d Merge pull request #246 from michaelbadcrumble/meson_support
Add Meson support in CMock.
2019-09-26 08:50:27 -04:00
Michael Brockus 0e9f8c54bc Created sub meson.build in source directory. 2019-09-20 16:25:04 -07:00
John Lindgren b76d570d4a Replace IgnoreMode with ExpectAnyArgsBool (no functional change).
IgnoreMode was used only for the ExpectAnyArgs plugin, and the
semantics of it were backwards:

  - IgnoreMode = CMOCK_ARG_NONE means to ignore all arguments
  - IgnoreMode = CMOCK_ARG_ALL means to verify all arguments

ExpectAnyArgsBool should make the purpose and semantics of this
field clearer.

Additionally, ExpectAnyArgs doesn't use FinalReturn for anything.
2019-09-16 13:28:14 -04:00
Mark VanderVoord 035141e2ab - Added capacity accessor for easier testing
- Made test size-agnostic for easier boundary checking.
2019-07-07 14:15:35 -04:00
Mark VanderVoord 99c2223a1d Back out broken changes. (See issue #210. Thanks @HamboLagos) 2019-07-03 11:09:06 -04:00
Brendan McDonnell b409ba6a1d Grammar fix--"fewer times", not "less times" 2019-03-01 21:52:12 -05:00
Matthijs Zeeman 732556700d Fix alignment error of CMock_Guts_Buffer
Changed allocation to use CMOCK_MEM_INDEX_TYPE instead of unsigned char. This may allocate extra memory if CMOCK_MEM_SIZE  is not a multiple of CMOCK_MEM_INDEX_SIZE. Had to substitute CMock_Guts_Buffer with a define in this case because  pointers are not constants.
2018-06-21 11:33:13 +02:00
Minich b9da6d6def Do not change CMock_Guts_Buffer or CMock_Guts_BufferSize unless
realloc() was successful. Prior to this change, if realloc() failed, the
current test would fail for out-of-memory, but subsequent tests would
continue trying to run with CMock_Guts_Buffer at address 0x00000000 and
thinking that the buffer size was sufficient. Therefore depending on the
system and how it handles (or doesn't handle) null pointer
dereferencing, subsequent tests might pass, fail in strange ways, or
crash the test app.
2017-10-31 12:03:31 -04:00
Oscar Edvardsson 9e49bace32 Before memcpy'ing when returning through pointer, check that destination is not NULL. 2017-02-16 17:05:35 +01:00
Mark VanderVoord dda0351471 Make smarter guesses about memory alignment based on the size of long discovered by unity 2017-02-06 07:04:22 -05:00
Mijail 8c8c2a2292 Avoid possible Undefined Behavior
(related to a possible negative zero, as reported by RV-Match)
2017-02-02 17:19:02 +01:00
Mark VanderVoord 3fa4de14be -fix whitespace 2016-01-04 19:27:48 -05:00
Mark VanderVoord 647876644b - Centralized error strings to a few constants.
- Made use of the new UNITY_SET_DETAILS feature to background set up function & argument details for messages
- CMock now takes up a lot less memory! woo!
2015-12-10 16:58:10 -05:00
Mark VanderVoord 4fcca4bab7 - Moved the "Out of Memory" string into a const to stop repeating it.
- Added test for Out of Memory error
- reorder the way we handle includes in CMock internals to match the way it works in Unity
2015-12-10 11:09:26 -05:00
Mark VanderVoord a4a67519d1 cleanup to follow a more strict C standard 2014-05-23 11:23:44 -04:00
Mark VanderVoord efcd13d3aa Make sure CMock releases its dynamically allocated memory at the end of the entire suite. 2014-05-21 19:23:18 -04:00
Mark VanderVoord 86594eea25 * split :args_only feature from :ignore plugin to be its own :expect_any_args plugin
* made :expect_any_args work with intermixed expects the way you would think it should work.
2014-03-03 19:28:50 -05:00
Antony Male 26191e604f Edit TestCMockC.c so it will (mostly) run on 16-bit platforms.
This is useful when testing embedded code, and trying to gain
confidence that CMock works correctly, is configured correctly,
etc.

This involved creating cmock_internal.h which holds #defines
used by cmock.c. These are then also used in TestCMockc.c
instead of hard-coded data sizes.
2013-06-28 12:21:09 +01:00
Dennis Lambe Jr 932785fd71 Added the return_thru_ptr and ignore_arg plugins 2012-12-19 19:06:10 -05:00
mkarlesky b7ab7eabf1 Made EOLs consistent.
Updated build & version info.

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@203 bf332499-1b4d-0410-844d-d2d48d5cc64c
2011-01-13 21:07:07 +00:00
mvandervoord e9a7151241 - Reworked memory handling to avoid realloc problems if it decides to relocate the block.
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@202 bf332499-1b4d-0410-844d-d2d48d5cc64c
2011-01-13 18:10:57 +00:00
mvandervoord 4a0df26994 - drop cexception_include which is no longer needed
- correct which define needed to be long in cmock.c
- beefed up testing of unity TEST_IGNORE in relation to mocking

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@174 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-06-27 19:02:07 +00:00
mvandervoord e91f739e43 - updated default to internal temp type
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@169 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-06-21 12:57:32 +00:00
mvandervoord 2bf2364b82 - make the ptr size more flexible
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@166 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-06-18 18:32:32 +00:00
mvandervoord 36de9c6fc4 - added copyright notices to code (oops)
- protected against people using extern "C"

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@161 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-04-27 02:14:44 +00:00
mvandervoord 14d639bbd8 - made index follow alignment rules too
- added support to track line numbers
- tweaked color support

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@158 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-03-24 01:06:51 +00:00
mvandervoord e79a5f13d1 - added cmock.c file for handling generic parts
- switched to better memory management technique


git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@155 bf332499-1b4d-0410-844d-d2d48d5cc64c
2010-03-08 13:32:31 +00:00