63 Commits

Author SHA1 Message Date
Mark VanderVoord d482f56066 Protect against more function-looking macros (Fixes#502) 2026-06-19 15:58:08 -04:00
Mark VanderVoord 1ef72ca854 Protect against function-looking structs (Fixes #513) 2026-06-19 15:10:14 -04:00
Mark VanderVoord 85058d1407 Fixed skeleton path handling, etc (#488) 2026-06-19 14:42:09 -04:00
Mark VanderVoord 411f6852f9 Add documentation to avoid problems like #518 and #521. 2026-06-19 13:50:21 -04:00
Mark VanderVoord 383c43246c Merge pull request #531 from ThrowTheSwitch/feature/better_arrays
Feature/better arrays
2026-06-19 10:53:54 -04:00
Mark VanderVoord 990954c548 Made the last two features actually cooperate. 2026-06-18 20:25:31 -04:00
Mark VanderVoord de4e53cd7b The array plugin can now compare strings as byte arrays, even though they are treated like strings everywhere else. (Fixes #262 and #177) 2026-06-18 19:56:22 -04:00
Mark VanderVoord 84705b2e84 Rename some misnamed tests. 2026-06-18 19:41:35 -04:00
Mark VanderVoord 336a52bf57 Verify #463 isn't currently an error, and won't return. 2026-06-18 18:49:03 -04:00
Mark VanderVoord aaf9559a57 Finish better identification of array pointer/len pairs.
Add fallback _ExpectWithArrayExtended when this happens for flexibility.
Fixes issue #520
2026-06-18 16:34:24 -04:00
Mark VanderVoord 8c1f88fb82 Improve the automatic detection of argument pairs related to arrays/pointers and lengths 2026-06-18 12:50:29 -04:00
Mark VanderVoord a0207f3800 void* handling within the array plugin defaults to bytes. 2026-06-16 21:41:07 -04:00
Mark VanderVoord bad95c5f54 Handle void pointers as pointer comparisons unless the array plugin gives more information. (Fixes #400) 2026-06-16 21:34:32 -04:00
Mark VanderVoord f756eeaf55 Fix handling of array of pointers (Fixes issue #450) 2026-06-16 18:14:51 -04:00
Mark VanderVoord 82ef7e53cf Fix handling of variable-length-arrays (fixed issue #479) 2026-06-16 17:39:40 -04:00
Mark VanderVoord af610445b3 flesh out tests for arrays and pointers and separate. 2026-06-16 17:02:56 -04:00
Mark VanderVoord a0de150635 Improve the array handling by making the public interfaces still use arrays. 2026-06-16 16:18:22 -04:00
Mark VanderVoord 3d4ddfdc4c Fix const pointer handling in return values 2026-06-16 15:37:14 -04:00
Mark VanderVoord 29ef16e54b Tidy handling of system tests to depend more on the defines involved then separate tracking.
Remove yml files that are no longer needed.
2026-06-16 15:20:21 -04:00
Mark VanderVoord 725e2d90ef cleanup the way defines are handled in tests. 2026-05-29 16:28:57 -04:00
Mark VanderVoord c06bbe791c run examples fully and pass optional yaml file to them.
begin to automatically reject tests based on criteria.
2026-05-29 16:09:22 -04:00
Mark VanderVoord c40a6e08c6 Refactored self-tests to use ceedling-formatted tools files 2026-05-28 16:48:53 -04:00
Mark VanderVoord 5f0296eb0a Fix naming to avoid that extra colon for parsing. 2026-05-22 14:41:22 -04:00
Mark VanderVoord 165de30b7d Bump to latest Unity 2026-05-22 14:17:29 -04:00
Mark VanderVoord 04b5b21ffd Give system tests more verbose output during testing. 2026-05-22 13:35:09 -04:00
Mark VanderVoord f20c59b029 Make the output more verbose for self-tests. 2026-05-22 11:41:00 -04:00
Mark VanderVoord 6a9e3afe14 update the create_makefile script to be independent and not require pointless middleware scripts. 2026-05-18 17:41:21 -04:00
Mark VanderVoord 13da43dc95 Merge pull request #530 from ThrowTheSwitch/refactor/inherit_targets
Refactor/inherit targets
2026-05-18 16:42:41 -04:00
Mark VanderVoord 469fe271f5 Add missing type to parsing test. 2026-05-18 16:38:07 -04:00
Mark VanderVoord a99deea71a Refactor test reporting for better final summary. 2026-05-18 16:06:36 -04:00
Mark VanderVoord be420840b3 make the cmock modifier files optional as 2nd argument in config 2026-05-16 23:40:08 -04:00
Mark VanderVoord d83c7017e0 Refactor cmock tests to identify the closest matching cmock overlay 2026-05-16 23:02:07 -04:00
Mark VanderVoord 5c6f42ae45 Tiny tweaks to prepare for next phase 2026-05-16 22:48:24 -04:00
Mark VanderVoord f7c3f73b21 Tweak naming to fall-through to the correct target 2026-05-16 14:48:47 -04:00
Mark VanderVoord f7689b8cc3 continue (update the styling of the targets) 2026-05-16 14:36:36 -04:00
Mark VanderVoord feda84f23b continuing 2026-05-15 23:53:09 -04:00
Mark VanderVoord 7d99f0f51d Start refactoring targets to use those coming from unity. so far we are refactoring to pull project-specific config 2026-05-15 23:31:56 -04:00
Mark VanderVoord 9900e4c5f5 pull in latest unity. bump version 2026-03-20 20:17:33 -04:00
Mark VanderVoord ecd7e7154c Merge pull request #527 from sullivanmj/patch-1
Fix links to other Markdown documentation
2026-03-08 16:15:18 -04:00
Matt Sullivan abcd75ffbc Fix links to other Markdown documentation 2026-03-05 09:24:40 -06:00
Mark VanderVoord f368744ca5 Updates for the new year 2026-01-23 11:19:02 -05:00
Mark VanderVoord 94dcd39765 move to latest unity. 2025-07-09 17:02:47 -04:00
Mark VanderVoord 75c3f3c7b3 minor tweaks 2025-07-09 17:02:21 -04:00
Mark VanderVoord 2671ad7046 Merge pull request #504 from bal-stan/patch-1
Fix compiler error when compiling with `-Wcast-qual` and mocking const function arguments
2025-07-09 16:25:28 -04:00
Mark VanderVoord bf9a13a8d4 Merge pull request #508 from rstahn/rstahn-patch-1
Add option 'create_error_stubs' (default is 'true')
2025-07-09 13:23:10 -04:00
Mark VanderVoord bb0b0e06f5 Fix confusing output when failing within a callback
Unset argument detail before calling callback
2025-07-04 10:48:40 -04:00
ml-physec 2bb9086214 Unset argument detail before calling callback 2025-07-04 16:32:37 +02:00
Roland Stahn ad9ce635c3 Update main.yml
Remove trigger for branch rstahn-patch-1 for final PR
2025-06-13 12:45:11 +02:00
Roland Stahn 6f2a234dca Add tests with 'create_error_stubs' set to false 2025-06-13 11:35:32 +02:00
Roland Stahn 338279285b Delete test/unit/cmock_generator_plugin_expect_c_test.rb 2025-06-13 11:32:27 +02:00
Roland Stahn 16ec975a87 Add first testcase with 'create_error_stubs' set to false
Change-Id: I33728023c1397e2bdbe62304638f578482ec8f58
2025-06-12 14:15:21 +02:00
Roland Stahn 0cefcf05f9 Update description of 'create_error_stubs'
Change-Id: Ica84be72a229a4fd90e3d5ce0b3449722699f637
2025-06-11 12:55:28 +02:00
Roland Stahn c9154a19dd Add description for 'create_error_stubs' 2025-06-08 22:57:20 +02:00
Roland Stahn 3ba7de2cb7 Style fixes 2025-06-03 13:51:15 +02:00
Roland Stahn bd41b3f939 Add option create_error_stubs to testcase 2025-06-03 13:26:34 +02:00
Roland Stahn b1d0e36aa3 Update main.yml (run tests on branches) 2025-06-03 13:18:11 +02:00
Roland Stahn d20dca34ab Add option 'create_error_stubs' in before 2025-06-03 13:14:23 +02:00
Roland Stahn f60fe4b808 Add option 'create_error_stubs'
Proposal for issue #507
2025-06-02 11:44:37 +02:00
bal-stan 076df6dd5c Fix compiler error when compiling with -Wcast-qual and mocking const function arguments 2025-04-01 16:24:48 +00:00
Mark VanderVoord 204117cb59 Merge pull request #499 from bal-stan/cast-memcpy-dest-pointers
Always cast `memcpy` source pointers to `const void *`
2025-02-18 16:33:38 -05:00
Mark VanderVoord 8ce70396d1 Merge pull request #500 from ThrowTheSwitch/mvandervoord-patch-1
Create FUNDING.yml
2025-02-17 09:15:48 -05:00
Mark VanderVoord 4eb6c1cada Create FUNDING.yml 2025-02-17 09:15:26 -05:00
bal-stan 2bcc723e10 Always cast memcpy dest pointers to const void 2025-02-13 18:06:27 +00:00
213 changed files with 3756 additions and 2200 deletions
+13
View File
@@ -0,0 +1,13 @@
github: ThrowTheSwitch
#patreon: # Replace with a single Patreon username
#open_collective: # Replace with a single Open Collective username
#ko_fi: # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
#liberapay: # Replace with a single Liberapay username
#issuehunt: # Replace with a single IssueHunt username
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
#polar: # Replace with a single Polar username
#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
#thanks_dev: # Replace with a single thanks.dev username
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+4 -4
View File
@@ -1,8 +1,8 @@
[submodule "vendor/unity"]
path = vendor/unity
url = https://github.com/throwtheswitch/unity.git
branch = master
[submodule "vendor/c_exception"]
path = vendor/c_exception
url = https://github.com/throwtheswitch/cexception.git
branch = master
[submodule "vendor/unity"]
path = vendor/unity
url = https://github.com/throwtheswitch/unity.git
branch = master
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
+1 -1
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
+90 -13
View File
@@ -1,13 +1,13 @@
CMock: A Summary
================
*[ThrowTheSwitch.org](http://throwtheswitch.org)*
*[ThrowTheSwitch.org](http://throwtheswitch.org)*
*This documentation is released under a Creative Commons 3.0 Attribution Share-Alike License*
- [Known Issues](docs/CMockKnownIssues.md)
- [Change Log](docs/CMockChangeLog.md)
- [How Does CMock Validate Arguments](docs/CMock_ArgumentValidation.md)
- [Known Issues](CMockKnownIssues.md)
- [Change Log](CMockChangeLog.md)
- [How Does CMock Validate Arguments](CMock_ArgumentValidation.md)
What Exactly Are We Talking About Here?
---------------------------------------
@@ -138,7 +138,7 @@ that resembles a pointer or array, it breaks the argument into TWO arguments.
The first is the original pointer. The second specify the number of elements
it is to verify of that array. If you specify 1, it'll check one object. If 2,
it'll assume your pointer is pointing at the first of two elements in an array.
If you specify zero elements and `UNITY_COMPARE_PTRS_ON_ZERO_ARRAY` is defined,
If you specify zero elements and `UNITY_COMPARE_PTRS_ON_ZERO_ARRAY` is defined,
then this assertion can also be used to directly compare the pointers to verify
that they are pointing to the same memory address.
@@ -147,6 +147,27 @@ that they are pointing to the same memory address.
* `retval func(void)` => (nothing. In fact, an additional function is only generated if the params list contains pointers)
* `retval func(other, ptr* param)` => `void func_ExpectWithArrayAndReturn(other, ptr* param, int param_depth, retval_to_return)`
When the `:array_size_name` and `:array_size_type` options are configured, CMock
can recognize that a scalar parameter is the size of an adjacent pointer parameter
and pair them together. When a size parameter is paired with a pointer, the `_Expect`
call automatically uses it as the array depth, and `_ExpectWithArray` preserves
the original argument order without adding a separate depth argument.
When performing this type of automatic identification of arguments, CMock will also
generate an additional `_ExpectWithArrayExtended`, which accepts an explicit
depth for every pointer — allowing you to override the inferred depth when the
pairing heuristic guesses wrong:
* `void func(int size, ptr* buf)` =>
* `void func_ExpectWithArray(int size, ptr* buf)` _(depth inferred from `size`)_
* `void func_ExpectWithArrayExtended(int size, ptr* buf, int buf_Depth)` _(explicit override)_
`_ExpectWithArrayExtended` is only generated for functions where at least one
size parameter has been automatically identified. For all other functions the short
`_ExpectWithArray` already gives full depth control. This function can be used to correct
poor assumptions that CMock has made. It can also be used to separately verify a passed
length, but compare the actual contents for a DIFFERENT number of elements.
Ignore:
-------
@@ -357,6 +378,23 @@ generate a skeleton instead:
ruby cmock.rb --skeleton ../create/c/for/this.h
```
Using CMock Without Ceedling
----------------------------
CMock depends on the Unity test framework, but it does not *require* Ceedling. You can use the
generated mocks directly with the Unity test framework in whatever build system you prefer. One
important thing to remember when doing this is that you will need to call the `_Init` function
for each of your mocks BEFORE the tests and the `_Verify` function for each mock AFTER each test.
This allows CMock to perform all of its internal accounting. If you're running into problems where
some errors aren't getting caught, this is likely what you are missing.
There are many ways to accomplish this. Any is valid:
- These actions can be performed as part of `setUp` and `tearDown` in each test file
- You can hand-write your own RUN_TEST macro. If so, protect `_Verify` calls in `TEST_PROTECT`
- You can use Unity's test runner generator and it will automatically take care of this for you.
- You can use Ceedling and it will automatically take care of this for you.
Config Options:
---------------
@@ -420,6 +458,27 @@ from the defaults. We've tried to specify what the defaults are below.
* default: *nil*
* `:create_error_stubs`:
New users of CMock sometimes struggle with the concept that CMock is
generating differently named interface functions for a mock depending
on whether a function to be mocked has a return value or not (see
description of the plugins `:Expect`, `:ExpectAnyArgs`, `:Array`, `:Ignore`,
`:IgnoreStateless` above). They are looking e.g. for a function `func_Expect()`
while CMock generated the function `func_ExpectAndReturn()` instead.
This has proven to be a significant hurdle, because it is not easy to
spot the slightly different named function within the generated mock.
Therefore CMock (v2.6.0 and newer) is generating *both* functions
per default, although one of them has only a "stub" functionality:
on call it will always fail the test emitting a helpful error message
pointing towards the correct function.
Experienced CMock users on the other hand might prefer the original
behavior, where no additional error stubs are generated - e.g. to
ensure code completion offers only "real" functionality of the mock.
In this case, the option `:create_error_stubs` can be set to false.
* default: true
* `:enforce_strict_ordering`:
CMock always enforces the order that you call a particular function,
so if you expect GrabNabber(int size) to be called three times, it
@@ -637,7 +696,7 @@ from the defaults. We've tried to specify what the defaults are below.
for the test code to also see the newly generated header ,and not
the old header with inline functions, the build system has to add
the mock folder to the include paths.
Furthermore, we need to keep the order of include paths in mind. We
have to set the mock folder before the other includes to avoid the
test code including the original header instead of the newly
@@ -701,11 +760,7 @@ from the defaults. We've tried to specify what the defaults are below.
* `void GoBananas(Banana * bananas, int num_bananas)`
* `int write_data(int fd, const uint8_t * data, uint32_t size)`
To recognize functions like these, CMock looks for a parameter list
containing a pointer (which could be an array) followed by something that
could be an array size. "Something", by default, means an `int` or `size_t`
parameter with a name containing "size" or "len".
* `void store_data(int buf_size, uint8_t * buf)`
`:array_size_type` is a list of additional types (besides `int` and `size_t`)
that could be used for an array size parameter. For example, to get CMock to
@@ -720,8 +775,30 @@ from the defaults. We've tried to specify what the defaults are below.
cfg[:array_size_name] = 'size|len|num_'
Parameters must match *both* `:array_size_type` and `:array_size_name` (and
must come right after a pointer parameter) to be treated as an array size.
A parameter must match *both* `:array_size_type` and `:array_size_name` to be
treated as an array size.
**Pairing heuristic:** CMock scores each candidate size parameter against each
pointer parameter using name similarity. It strips size-words (e.g. "size",
"len") from the size parameter's name to derive a root, then checks whether
that root matches the pointer's name exactly (score 10), as a prefix or suffix
(score 7), or as a substring (score 5). Adjacency in the argument list adds a
small bonus (score +2). The highest-scoring pairing wins. This means CMock
correctly pairs `buff_size` with `buffer` even when another pointer appears
adjacent to `buff_size`.
Size parameters may appear either **before or after** the pointer they describe.
CMock recognizes both orderings:
* Size after pointer: `void func(uint8_t* buf, int buf_size)` — the `_Expect`
call uses `buf_size` as the depth automatically. `_ExpectWithArray` adds an
explicit `buf_Depth` argument after `buf` for manual override.
* Size before pointer: `void func(int buf_size, uint8_t* buf)` — the `_Expect`
call again uses `buf_size` as the depth automatically, and `_ExpectWithArray`
keeps arguments in their original order with no extra depth argument added.
An additional `_ExpectWithArrayExtended` variant is generated that does accept
an explicit depth, allowing you to override the inferred value when needed.
Once you've told it how to recognize your arrays, CMock will give you `_Expect`
calls that work more like `_ExpectWithArray`, and compare an array of objects
+1 -1
View File
@@ -14,7 +14,7 @@ all: setup test ${BUILD_DIR}/main run
setup:
mkdir -p ${BUILD_DIR}
mkdir -p ${OBJ}
ruby ../../scripts/create_makefile.rb --silent
ruby ../../scripts/create_makefile.rb
clean:
rm -rf ${BUILD_DIR}
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+2 -2
View File
@@ -1,12 +1,12 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
#include "unity.h"
#include "mock_foo.h"
#include "Mockfoo.h"
void setUp(void)
{
+75
View File
@@ -0,0 +1,75 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
:project:
:build_root: 'build/'
:colour: true
:paths:
:source:
- 'src/'
:include:
- 'src/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- 'build/mocks/'
- 'test/'
:test: 'test/'
:build: 'build/'
:mocks: 'build/mocks/'
:extension:
:object: '.o'
:executable: '.exe'
:defines:
:test:
- __monitor
- UNITY_SUPPORT_64
:cmock:
# Core configuration
:plugins: []
:verbosity: 2
:when_no_prototypes: :warn
# File configuration
:mock_path: 'build/mocks'
:skeleton_path: ''
:mock_prefix: 'Mock'
:mock_suffix: ''
# Parser configuration
:strippables:
- '(?:__attribute__\s*\([ (]*.*?[ )]*\)+)'
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude
:treat_inlines: :exclude
# Type handling configuration
:memcmp_if_unknown: true
:when_ptr: :compare_data
# Mock generation configuration
:weak: ''
:enforce_strict_ordering: false
:fail_on_unexpected_calls: true
:callback_include_count: true
:callback_after_arg_check: false
:includes:
- Types.h
:exclude_setjmp_h: false
+4 -4
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -20,7 +20,7 @@ REQUIRED_DIRS.each do |v|
end
# Load default configuration, for now
DEFAULT_CONFIG_FILE = 'gcc.yml'.freeze
DEFAULT_CONFIG_FILE = 'gcc_64.yml'.freeze
configure_toolchain(DEFAULT_CONFIG_FILE)
task :unit do
@@ -39,8 +39,8 @@ task :ci => [:default]
task :cruise => [:default]
desc 'Load configuration'
task :config, :config_file do |_t, args|
configure_toolchain(args[:config_file])
task :config, [:config_file, :cmock_overlay] do |_t, args|
configure_toolchain(args[:config_file], args[:cmock_overlay])
end
desc 'Return error on Failures'
+162 -118
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -22,32 +22,81 @@ module RakefileHelpers
YAML.load(yaml_string)
end
def load_configuration(config_file)
def find_cmock_target(targets_dir, config_file)
return config_file if File.exist?("#{targets_dir}/#{config_file}")
basename = File.basename(config_file, '.yml')
while basename.include?('_')
basename = basename.rpartition('_').first
candidate = "#{basename}.yml"
return candidate if File.exist?("#{targets_dir}/#{candidate}")
end
nil
end
def load_configuration(config_file, cmock_overlay = nil)
$cfg_file = config_file
$cfg = load_yaml(File.read("./targets/#{$cfg_file}"))
$colour_output = false unless $cfg['colour']
$proj = load_yaml(File.read('./project.yml'))
unity_targets_dir = '../../vendor/unity/test/targets'
cmock_targets_dir = '../../test/targets'
config_basename = File.basename(config_file)
path_specified = File.dirname(config_file) != '.'
# Resolve the target file location:
# - path specified → use only that location
# - no path → check current directory first, then vendor unity targets
unity_target = if path_specified
config_file
elsif File.exist?("./#{config_file}")
"./#{config_file}"
else
"#{unity_targets_dir}/#{config_file}"
end
if File.exist?(unity_target)
puts "Loading Unity target: #{unity_target}"
$unity_cfg = load_yaml(File.read(unity_target))
cmock_file = cmock_overlay || find_cmock_target(cmock_targets_dir, config_basename)
if cmock_file
puts "Loading CMock overlay: #{cmock_targets_dir}/#{cmock_file}"
$cmock_cfg = load_yaml(File.read("#{cmock_targets_dir}/#{cmock_file}"))
else
puts "No CMock overlay found for #{config_file}"
$cmock_cfg = {}
end
else
# CMock-only target (no Unity equivalent); it uses Unity format directly
puts "Loading CMock-only target: #{cmock_targets_dir}/#{config_basename}"
$unity_cfg = load_yaml(File.read("#{cmock_targets_dir}/#{config_basename}"))
$cmock_cfg = {}
end
$colour_output = $proj[:project][:colour]
end
def configure_clean
CLEAN.include("#{$cfg['compiler']['build_path']}*.*") unless $cfg['compiler']['build_path'].nil?
CLEAN.include("#{$proj[:project][:build_root]}*.*")
end
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
config_file += '.yml' unless config_file =~ /\.yml$/
load_configuration(config_file)
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE, cmock_overlay = nil)
config_file ||= DEFAULT_CONFIG_FILE
config_file += '.yml' unless config_file =~ /\.yml$/i
cmock_overlay += '.yml' if cmock_overlay && cmock_overlay !~ /\.yml$/i
load_configuration(config_file, cmock_overlay)
configure_clean
end
def unit_test_files
path = $cfg['compiler']['unit_tests_path'] + "Test*#{C_EXTENSION}"
path = $proj[:paths][:test] + "Test*#{C_EXTENSION}"
path.tr!('\\', '/')
FileList.new(path)
end
def local_include_dirs
include_dirs = $cfg['compiler']['includes']['items'].dup
include_dirs.delete_if { |dir| dir.is_a?(Array) }
include_dirs
$proj[:paths][:include].reject { |dir| dir.is_a?(Array) }
end
def extract_headers(filename)
@@ -55,9 +104,7 @@ module RakefileHelpers
lines = File.readlines(filename)
lines.each do |line|
m = line.match(/^\s*#include\s+"\s*(.+\.[hH])\s*"/)
unless m.nil?
includes << m[1]
end
includes << m[1] unless m.nil?
end
includes
end
@@ -65,9 +112,7 @@ module RakefileHelpers
def find_source_file(header, paths)
paths.each do |dir|
src_file = dir + header.ext(C_EXTENSION)
if File.exist?(src_file)
return src_file
end
return src_file if File.exist?(src_file)
end
nil
end
@@ -85,79 +130,96 @@ module RakefileHelpers
end
end
def squash(prefix, items)
result = ''
items.each { |item| result += " #{prefix}#{tackit(item)}" }
result
# All defines: project common + Unity target + CMock overlay + any extras
def all_defines(extra = [])
(($proj[:defines][:test] || []) +
($unity_cfg[:defines][:test] || []) +
(($cmock_cfg[:defines] || {})[:test] || []) +
extra).uniq
end
def build_compiler_fields
command = tackit($cfg['compiler']['path'])
defines = if $cfg['compiler']['defines']['items'].nil?
''
else
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
end
options = squash('', $cfg['compiler']['options'])
includes = squash($cfg['compiler']['includes']['prefix'], $cfg['compiler']['includes']['items'])
includes = includes.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ :command => command, :defines => defines, :options => options, :includes => includes }
# Toolchain-specific include paths: Array items in Unity's :paths: :test:
def toolchain_include_paths
if $unity_cfg[:paths] && $unity_cfg[:paths][:test]
$unity_cfg[:paths][:test]
else
[]
end
end
def compile(file, _defines = [])
compiler = build_compiler_fields
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
execute(cmd_str + obj_file)
obj_file
# Resolve argument template tokens into a flat argument string.
# Supports Ceedling-style positional tokens and legacy Unity COLLECTION_* tokens.
# ${5} → expands to one arg per include path (toolchain paths + project paths combined)
# ${6} → expands to one arg per define
# ${1} → input file(s)
# ${2} → output file
def build_argument_list(raw_args, toolchain_paths, project_paths, defines, input, output)
result = []
raw_args.each do |arg|
if arg.is_a?(Array)
result << arg.join
elsif arg.include?('${5}')
(toolchain_paths + project_paths).each do |p|
result << arg.gsub('${5}', p.is_a?(Array) ? p.join : p.to_s)
end
elsif arg.include?('${6}')
defines.each { |d| result << arg.gsub('${6}', d) }
elsif arg.include?('COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE')
toolchain_paths.each { |p| result << "-I\"#{p.is_a?(Array) ? p.join : p}\"" }
elsif arg.include?('COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR')
project_paths.each { |p| result << "-I\"#{p}\"" }
elsif arg.include?('COLLECTION_DEFINES_TEST_AND_VENDOR')
defines.each { |d| result << "-D#{d}" }
else
result << arg.gsub('${1}', input.to_s).gsub('${2}', output.to_s)
end
end
result.join(' ')
end
def build_linker_fields
command = tackit($cfg['linker']['path'])
options = if $cfg['linker']['options'].nil?
''
else
squash('', $cfg['linker']['options'])
end
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
''
else
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
end
includes = includes.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
{ :command => command, :options => options, :includes => includes }
def compile(file, extra_defines = [])
tool = $unity_cfg[:tools][:test_compiler]
ext = $unity_cfg[:extension][:object] || '.o'
build_root = $proj[:project][:build_root] || 'build/'
obj_file = build_root + File.basename(file, C_EXTENSION) + ext
cmd_str = "#{tackit(tool[:executable])} #{
build_argument_list(tool[:arguments],
toolchain_include_paths,
$proj[:paths][:include],
all_defines(extra_defines),
file, obj_file)}"
execute(cmd_str)
File.basename(obj_file)
end
def link_it(exe_name, obj_list)
linker = build_linker_fields
cmd_str = "#{linker[:command]}#{linker[:includes]} " \
"#{(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join}" \
"#{$cfg['linker']['bin_files']['prefix']} " \
"#{$cfg['linker']['bin_files']['destination']}" \
"#{exe_name}#{$cfg['linker']['bin_files']['extension']} #{linker[:options]}"
tool = $unity_cfg[:tools][:test_linker]
ext = $unity_cfg[:extension][:executable] || ''
build_root = $proj[:project][:build_root] || 'build/'
input_files = obj_list.uniq.map { |obj| build_root + obj }.join(' ')
output_file = build_root + exe_name + ext
cmd_str = "#{tackit(tool[:executable])} #{build_argument_list(tool[:arguments], [], [], [], input_files, output_file)}"
execute(cmd_str)
end
def build_simulator_fields
return nil if $cfg['simulator'].nil?
return nil unless $unity_cfg[:tools][:test_fixture]
command = if $cfg['simulator']['path'].nil?
''
else
"#{tackit($cfg['simulator']['path'])} "
end
pre_support = if $cfg['simulator']['pre_support'].nil?
''
else
squash('', $cfg['simulator']['pre_support'])
end
post_support = if $cfg['simulator']['post_support'].nil?
''
else
squash('', $cfg['simulator']['post_support'])
end
{ :command => command, :pre_support => pre_support, :post_support => post_support }
tool = $unity_cfg[:tools][:test_fixture]
executable = tackit(tool[:executable])
raw_args = tool[:arguments] || []
idx = raw_args.index('${1}')
if idx
pre = raw_args[0...idx].map { |a| a.is_a?(Array) ? a.join : a }.join(' ')
post = raw_args[(idx + 1)..].map { |a| a.is_a?(Array) ? a.join : a }.join(' ')
else
pre = ''
post = raw_args.map { |a| a.is_a?(Array) ? a.join : a }.join(' ')
end
{ command: "#{executable} ", pre_support: pre, post_support: post }
end
def execute(command_string, verbose = true, ok_to_fail = false)
@@ -174,7 +236,7 @@ module RakefileHelpers
def report_summary
summary = UnityTestSummary.new
summary.root = HERE
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
results_glob = "#{$proj[:project][:build_root]}*.test*"
results_glob.tr!('\\', '/')
results = Dir[results_glob]
summary.targets = results
@@ -185,71 +247,56 @@ module RakefileHelpers
def run_tests(test_files)
report 'Running system tests...'
# Tack on TEST define for compiling unit tests
load_configuration($cfg_file)
test_defines = ['TEST']
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
$cfg['compiler']['defines']['items'] << 'TEST'
include_dirs = local_include_dirs
# Build and execute each unit test
test_files.each do |test|
# Detect dependencies and build required required modules
header_list = (extract_headers(test) + ['cmock.h'] + [$cfg[:cmock][:unity_helper_path]]).compact.uniq
# Detect dependencies and build required modules
header_list = (extract_headers(test) + ['cmock.h'] + [($proj[:cmock] || {})[:unity_helper_path]]).compact.uniq
header_list.each do |header|
# create mocks if needed
next unless header =~ /Mock/
require '../../lib/cmock'
@cmock ||= CMock.new(".//targets//#{$cfg_file}")
@cmock.setup_mocks([$cfg['compiler']['source_path'] + header.gsub('Mock', '')])
@cmock ||= CMock.new($proj[:cmock])
@cmock.setup_mocks([$proj[:paths][:source].first + header.gsub('Mock', '')])
end
# compile all mocks
# compile all mocks and dependencies
obj_list = []
header_list.each do |header|
# compile source file header if it exists
src_file = find_source_file(header, include_dirs)
unless src_file.nil?
obj_list << compile(src_file, test_defines)
end
obj_list << compile(src_file, ['TEST']) unless src_file.nil?
end
# Build the test runner (generate if configured to do so)
test_base = File.basename(test, C_EXTENSION)
# Build the test runner
test_base = File.basename(test, C_EXTENSION)
runner_name = "#{test_base}_Runner.c"
if $cfg['compiler']['runner_path'].nil?
runner_path = "#{$cfg['compiler']['build_path']}#{runner_name}"
test_gen = UnityTestRunnerGenerator.new(".//targets//#{$cfg_file}")
test_gen.run(test, runner_path)
else
runner_path = $cfg['compiler']['runner_path'] + runner_name
end
runner_path = "#{$proj[:project][:build_root]}#{runner_name}"
UnityTestRunnerGenerator.new({}).run(test, runner_path)
obj_list << compile(runner_path, test_defines)
obj_list << compile(runner_path, ['TEST'])
# Build the test module
obj_list << compile(test, test_defines)
obj_list << compile(test, ['TEST'])
# Link the test executable
link_it(test_base, obj_list)
# Execute unit test and generate results file
simulator = build_simulator_fields
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
simulator = build_simulator_fields
build_root = $proj[:project][:build_root]
executable = build_root + test_base + ($unity_cfg[:extension][:executable] || '')
cmd_str = if simulator.nil?
executable
else
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
end
output = execute(cmd_str, true)
test_results = $cfg['compiler']['build_path'] + test_base
test_results += if output.match(/OK$/m).nil?
'.testfail'
else
'.testpass'
end
test_results = build_root + test_base
test_results += output.match(/OK$/m).nil? ? '.testfail' : '.testpass'
File.open(test_results, 'w') { |f| f.print output }
end
end
@@ -258,23 +305,20 @@ module RakefileHelpers
report 'Building application...'
obj_list = []
load_configuration(".//targets//#{$cfg_file}")
main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION
load_configuration($cfg_file)
main_path = $proj[:paths][:source].first + main + C_EXTENSION
# Detect dependencies and build required required modules
# Detect dependencies and build required modules
include_dirs = local_include_dirs
extract_headers(main_path).each do |header|
src_file = find_source_file(header, include_dirs)
unless src_file.nil?
obj_list << compile(src_file)
end
obj_list << compile(src_file) unless src_file.nil?
end
# Build the main source file
main_base = File.basename(main_path, C_EXTENSION)
obj_list << compile(main_path)
# Create the executable
link_it(main_base, obj_list)
link_it(File.basename(main_path, C_EXTENSION), obj_list)
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
-97
View File
@@ -1,97 +0,0 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
compiler:
path: gcc
source_path: 'src/'
unit_tests_path: &unit_tests_path 'test/'
build_path: &build_path 'build/'
options:
- -c
includes:
prefix: '-I'
items:
- 'src/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- *unit_tests_path
defines:
prefix: '-D'
items:
- __monitor
- UNITY_SUPPORT_64
object_files:
prefix: '-o'
extension: '.o'
destination: *build_path
linker:
path: gcc
options:
- -lm
includes:
prefix: '-I'
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.exe'
destination: *build_path
:cmock:
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro
# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: '' # Subdirectory to store stubs when generated (default: '')
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks
# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud
# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart
# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
#:includes_h_pre_orig_header: []
#:includes_h_post_orig_header: []
#:includes_c_pre_header: []
#:includes_c_post_header: []
#:array_size_type: [] # Specify a type or types that should be used for array lengths
#:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.
colour: true
-143
View File
@@ -1,143 +0,0 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0 Kickstart\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: 'src\'
unit_tests_path: &unit_tests_path 'test\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\lib\dl4tptinl8n.h']
- -z3
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian little
- --cpu ARM7TDMI
- --stack_align 4
- --interwork
- -e
- --silent
- --warnings_are_errors
- --fpu None
- --diag_suppress Pa050
includes:
prefix: '-I'
items:
- 'src/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- [*tools_root, 'arm\inc\']
- *unit_tests_path
defines:
prefix: '-D'
items:
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'common\bin\xlink.exe']
options:
- -rt
- [*tools_root, 'arm\lib\dl4tptinl8n.r79']
- -D_L_EXTMEM_START=0
- -D_L_EXTMEM_SIZE=0
- -D_L_HEAP_SIZE=120
- -D_L_STACK_SIZE=32
- -e_small_write=_formatted_write
- -s
- __program_start
- -f
- [*tools_root, '\arm\config\lnkarm.xcl']
includes:
prefix: '-I'
items:
- [*tools_root, 'arm\config\']
- [*tools_root, 'arm\lib\']
object_files:
path: *build_path
extension: '.r79'
bin_files:
prefix: '-o'
extension: '.d79'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\ioat91sam7X256.ddf']
- -d
- sim
:cmock:
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro
# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: './' # Subdirectory to store stubs when generated (default: '')
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks
# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud
# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart
# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
#:includes_h_pre_orig_header: []
#:includes_h_post_orig_header: []
#:includes_c_pre_header: []
#:includes_c_post_header: []
#:array_size_type: [] # Specify a type or types that should be used for array lengths
#:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.
-132
View File
@@ -1,132 +0,0 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
compiler:
path: [*tools_root, 'arm\bin\iccarm.exe']
source_path: 'src\'
unit_tests_path: &unit_tests_path 'test\'
build_path: &build_path 'build\'
options:
- --dlib_config
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
- --no_cse
- --no_unroll
- --no_inline
- --no_code_motion
- --no_tbaa
- --no_clustering
- --no_scheduling
- --debug
- --cpu_mode thumb
- --endian=little
- --cpu=ARM7TDMI
- --interwork
- --warnings_are_errors
- --fpu=None
- --diag_suppress=Pa050
- --diag_suppress=Pe111
- -e
- -On
includes:
prefix: '-I'
items:
- 'src/'
- '../../src/'
- '../../vendor/unity/src/'
- '../../vendor/unity/examples/example_3/helper/'
- './build/mocks/'
- [*tools_root, 'arm\inc\']
- *unit_tests_path
defines:
prefix: '-D'
items:
object_files:
prefix: '-o'
extension: '.r79'
destination: *build_path
linker:
path: [*tools_root, 'arm\bin\ilinkarm.exe']
options:
- --redirect _Printf=_PrintfLarge
- --redirect _Scanf=_ScanfSmall
- --semihosting
- --entry __iar_program_start
- --config
- [*tools_root, 'arm\config\generic.icf']
object_files:
path: *build_path
extension: '.o'
bin_files:
prefix: '-o'
extension: '.out'
destination: *build_path
simulator:
path: [*tools_root, 'common\bin\CSpyBat.exe']
pre_support:
- --silent
- [*tools_root, 'arm\bin\armproc.dll']
- [*tools_root, 'arm\bin\armsim.dll']
post_support:
- --plugin
- [*tools_root, 'arm\bin\armbat.dll']
- --backend
- -B
- -p
- [*tools_root, 'arm\config\debugger\atmel\ioat91sam7X256.ddf']
- -d
- sim
:cmock:
# Core conffiguration
:plugins: [] # What plugins should be used by CMock?
:verbosity: 2 # the options being 0 errors only, 1 warnings and errors, 2 normal info, 3 verbose
:when_no_prototypes: :warn # the options being :ignore, :warn, or :erro
# File configuration
:mock_path: './build/mocks' # Subdirectory to store mocks when generated (default: mocks)
:skeleton_path: '' # Subdirectory to store stubs when generated (default: '')
:mock_prefix: 'Mock' # Prefix to append to filenames for mocks
:mock_suffix: '' # Suffix to append to filenames for mocks
# Parser configuration
:strippables: ['(?:__attribute__\s*\([ (]*.*?[ )]*\)+)']
:attributes:
- __ramfunc
- __irq
- __fiq
- register
- extern
:c_calling_conventions:
- __stdcall
- __cdecl
- __fastcall
:treat_externs: :exclude # the options being :include or :exclud
:treat_inlines: :exclude # the options being :include or :exclud
# Type handling configuration
#:unity_helper_path: '' # specify a string of where to find a unity_helper.h file to discover custom type assertions
#:treat_as: {} # optionally add additional types to map custom types
#:treat_as_array: {} # hint to cmock that these types are pointers to something
#:treat_as_void: [] # hint to cmock that these types are actually aliases of void
:memcmp_if_unknown: true # allow cmock to use the memory comparison assertions for unknown types
:when_ptr: :compare_data # hint to cmock how to handle pointers in general, the options being :compare_ptr, :compare_data, or :smart
# Mock generation configuration
:weak: '' # Symbol to use to declare weak functions
:enforce_strict_ordering: false # Do we want cmock to enforce ordering of all function calls?
:fail_on_unexpected_calls: true # Do we want cmock to fail when it encounters a function call that wasn't expected?
:callback_include_count: true # Do we want cmock to include the number of calls to this callback, when using callbacks?
:callback_after_arg_check: false # Do we want cmock to enforce an argument check first when using a callback?
:includes: # You can add additional includes here, or specify the location with the options below
- Types.h
#:includes_h_pre_orig_header: []
#:includes_h_post_orig_header: []
#:includes_c_pre_header: []
#:includes_c_post_header: []
#:array_size_type: [] # Specify a type or types that should be used for array lengths
#:array_size_name: 'size|len' # Specify a name or names that CMock might automatically recognize as the length of an array
:exclude_setjmp_h: false # Don't use setjmp when running CMock. Note that this might result in late reporting or out-of-order failures.
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
@@ -1,7 +1,7 @@
/* =========================================================================
CMock - Automatic Mock Generation for C
ThrowTheSwitch.org
Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
SPDX-License-Identifier: MIT
========================================================================= */
+1 -1
View File
@@ -2,7 +2,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
+2 -1
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -43,6 +43,7 @@ class CMockConfig
:array_size_name => 'size|len',
:skeleton => false,
:exclude_setjmp_h => false,
:create_error_stubs => true,
# Format to look for inline functions.
# This is a combination of "static" and "inline" keywords ("static inline", "inline static", "inline", "static")
+38 -1
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -16,6 +16,17 @@ class CMockFileWriter
require 'fileutils'
FileUtils.mkdir_p "#{@config.mock_path}/" unless Dir.exist?("#{@config.mock_path}/")
FileUtils.mkdir_p "#{@config.mock_path}/#{"#{subdir}/" if subdir}" if subdir && !Dir.exist?("#{@config.mock_path}/#{"#{subdir}/" if subdir}")
rescue SystemCallError => e
raise "Unable to create mock output directory: #{e.message}. Check :mock_path ('#{@config.mock_path}') configuration."
end
def create_skeleton_subdir(subdir)
require 'fileutils'
base = effective_skeleton_path
FileUtils.mkdir_p base
FileUtils.mkdir_p "#{base}/#{subdir}" if subdir
rescue SystemCallError => e
raise "Unable to create skeleton output directory: #{e.message}. Check :skeleton_path ('#{base}') configuration."
end
def create_file(filename, subdir)
@@ -27,6 +38,27 @@ class CMockFileWriter
yield(file, filename)
end
update_file(full_file_name_done, full_file_name_temp)
rescue SystemCallError => e
raise "Unable to write mock file '#{full_file_name_done}': #{e.message}. Check :mock_path ('#{@config.mock_path}') and :subdir ('#{subdir}') configuration."
end
def create_skeleton_file(filename, subdir)
raise "Where's the block of data to create?" unless block_given?
base = effective_skeleton_path
full_file_name_temp = "#{base}/#{"#{subdir}/" if subdir}#{filename}.new"
full_file_name_done = "#{base}/#{"#{subdir}/" if subdir}#{filename}"
File.open(full_file_name_temp, 'w') do |file|
yield(file, filename)
end
update_file(full_file_name_done, full_file_name_temp)
rescue SystemCallError => e
raise "Unable to write skeleton file '#{full_file_name_done}': #{e.message}. Check :skeleton_path ('#{base}') and :subdir ('#{subdir}') configuration."
end
def skeleton_file_path(filename, subdir)
base = effective_skeleton_path
"#{base}/#{"#{subdir}/" if subdir}#{filename}"
end
def append_file(filename, subdir)
@@ -40,6 +72,11 @@ class CMockFileWriter
private ###################################
def effective_skeleton_path
path = @config.skeleton_path
path.nil? || path.empty? ? @config.mock_path : path
end
def update_file(dest, src)
require 'fileutils'
FileUtils.rm(dest, :force => true)
+41 -27
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -85,6 +85,7 @@ class CMockGenerator
:skeleton => true
}
@file_writer.create_skeleton_subdir(@subdir)
create_skeleton_source_file(mock_project)
end
@@ -133,9 +134,9 @@ class CMockGenerator
end
def create_skeleton_source_file(mock_project)
filename = "#{@config.mock_path}/#{"#{@subdir}/" if @subdir}#{mock_project[:module_name]}.c"
filename = @file_writer.skeleton_file_path("#{mock_project[:module_name]}.c", @subdir)
existing = File.exist?(filename) ? File.read(filename) : ''
@file_writer.create_file("#{mock_project[:module_name]}.c", @subdir) do |file, fullname|
@file_writer.create_skeleton_file("#{mock_project[:module_name]}.c", @subdir) do |file, fullname|
blank_project = mock_project.clone
blank_project[:parsed_stuff] = { :functions => [] }
if existing.empty?
@@ -210,24 +211,30 @@ class CMockGenerator
def create_source_header_section(file, filename, mock_project)
header_file = (mock_project[:folder] || '') + filename.sub(/.*\K\.c/, mock_project[:module_ext])
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n" unless mock_project[:parsed_stuff][:functions].empty?
file << "#include <string.h>\n"
file << "#include <stdlib.h>\n"
unless @exclude_setjmp_h
file << "#include <setjmp.h>\n"
end
file << "#include \"cmock.h\"\n"
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
file << "#include \"#{header_file}\"\n"
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
file << "\n"
strs = []
mock_project[:parsed_stuff][:functions].each do |func|
strs << func[:name]
func[:args].each { |arg| strs << arg[:name] }
end
strs.uniq.sort.each do |str|
file << "static const char* CMockString_#{str} = \"#{str}\";\n"
if mock_project[:skeleton]
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
file << "#include \"#{header_file}\"\n"
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
else
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n" unless mock_project[:parsed_stuff][:functions].empty?
file << "#include <string.h>\n"
file << "#include <stdlib.h>\n"
unless @exclude_setjmp_h
file << "#include <setjmp.h>\n"
end
file << "#include \"cmock.h\"\n"
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
file << "#include \"#{header_file}\"\n"
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
file << "\n"
strs = []
mock_project[:parsed_stuff][:functions].each do |func|
strs << func[:name]
func[:args].each { |arg| strs << arg[:name] }
end
strs.uniq.sort.each do |str|
file << "static const char* CMockString_#{str} = \"#{str}\";\n"
end
end
file << "\n"
end
@@ -296,11 +303,20 @@ class CMockGenerator
file << "}\n\n"
end
def function_return_type(function)
# When const_ptr? is true, the "const" in :modifier belongs after the asterisk (e.g. "int* const"),
# not as a prefix (which would incorrectly produce "const int*").
ret = if function[:return][:const_ptr?]
"#{function[:return][:type]} const"
else
(function[:modifier].empty? ? '' : "#{function[:modifier]} ") + function[:return][:type]
end
ret + (function[:c_calling_convention] ? " #{function[:c_calling_convention]}" : '')
end
def create_mock_implementation(file, function)
# prepare return value and arguments
function_mod_and_rettype = (function[:modifier].empty? ? '' : "#{function[:modifier]} ") +
(function[:return][:type]) +
(function[:c_calling_convention] ? " #{function[:c_calling_convention]}" : '')
function_mod_and_rettype = function_return_type(function)
args_string = function[:args_string]
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
@@ -359,9 +375,7 @@ class CMockGenerator
def create_function_skeleton(file, function, existing)
# prepare return value and arguments
function_mod_and_rettype = (function[:modifier].empty? ? '' : "#{function[:modifier]} ") +
(function[:return][:type]) +
(function[:c_calling_convention] ? " #{function[:c_calling_convention]}" : '')
function_mod_and_rettype = function_return_type(function)
args_string = function[:args_string]
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
+68 -15
View File
@@ -1,7 +1,7 @@
# =========================================================================
# CMock - Automatic Mock Generation for C
# ThrowTheSwitch.org
# Copyright (c) 2007-25 Mike Karlesky, Mark VanderVoord, & Greg Williams
# Copyright (c) 2007-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
# SPDX-License-Identifier: MIT
# =========================================================================
@@ -13,6 +13,7 @@ class CMockGeneratorPluginArray
@config = config
@ptr_handling = @config.when_ptr
@ordered = @config.enforce_strict_ordering
@error_stubs = @config.create_error_stubs
@utils = utils
@unity_helper = @utils.helpers[:unity_helper]
@priority = 8
@@ -20,28 +21,68 @@ class CMockGeneratorPluginArray
def instance_typedefs(function)
function[:args].inject('') do |all, arg|
arg[:ptr?] ? all + " int Expected_#{arg[:name]}_Depth;\n" : all
arg[:ptr?] || arg[:string?] ? all + " int Expected_#{arg[:name]}_Depth;\n" : all
end
end
def mock_function_declarations(function)
return nil unless function[:contains_ptr?]
args_call_i = function[:args].map { |m| m[:ptr?] ? "#{m[:name]}, #{m[:name]}_Depth" : (m[:name]).to_s }.join(', ')
args_call_o = function[:args].map { |m| m[:ptr?] ? "#{m[:name]}, (#{m[:name]}_Depth)" : (m[:name]).to_s }.join(', ')
func_name = function[:name]
# C function signature: always explicit depth for every pointer/string arg
args_string = function[:args].map do |m|
type = @utils.arg_type_with_const(m)
m[:ptr?] ? "#{type} #{m[:name]}, int #{m[:name]}_Depth" : "#{type} #{m[:name]}"
m[:ptr?] || m[:string?] ? "#{@utils.arg_declaration(m)}, int #{m[:name]}_Depth" : @utils.arg_declaration(m)
end.join(', ')
# Short macro params: paired ptrs (before OR after) omit _Depth (auto-filled from paired size arg)
# string? args always need an explicit _Depth
args_call_i = function[:args].map do |m|
(m[:ptr?] || m[:string?]) && !m[:array_size_name] ? "#{m[:name]}, #{m[:name]}_Depth" : m[:name].to_s
end.join(', ')
# Short macro call: paired ptrs pass paired size name as depth automatically
args_call_o = function[:args].map do |m|
if (m[:ptr?] || m[:string?]) && m[:array_size_name]
"#{m[:name]}, (#{m[:array_size_name]})"
elsif m[:ptr?] || m[:string?]
"#{m[:name]}, (#{m[:name]}_Depth)"
else
m[:name].to_s
end
end.join(', ')
# Extended macro params: every ptr/string gets an explicit _Depth
args_call_ext_i = function[:args].map do |m|
m[:ptr?] || m[:string?] ? "#{m[:name]}, #{m[:name]}_Depth" : m[:name].to_s
end.join(', ')
# Extended macro call: every ptr/string passes (name_Depth)
args_call_ext_o = function[:args].map do |m|
m[:ptr?] || m[:string?] ? "#{m[:name]}, (#{m[:name]}_Depth)" : m[:name].to_s
end.join(', ')
has_paired = function[:args].any? { |m| m[:array_size_name] }
lines = ''
if function[:return][:void?]
"#define #{function[:name]}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) TEST_FAIL_MESSAGE(\"#{function[:name]} requires _ExpectWithArray (not AndReturn)\");\n" \
"#define #{function[:name]}_ExpectWithArray(#{args_call_i}) #{function[:name]}_CMockExpectWithArray(__LINE__, #{args_call_o})\n" \
"void #{function[:name]}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string});\n"
if @error_stubs
lines << "#define #{func_name}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArray (not AndReturn)\");\n"
lines << "#define #{func_name}_ExpectWithArrayExtendedAndReturn(#{args_call_ext_i}, cmock_retval) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArrayExtended (not AndReturn)\");\n" if has_paired
end
lines << "#define #{func_name}_ExpectWithArray(#{args_call_i}) #{func_name}_CMockExpectWithArray(__LINE__, #{args_call_o})\n"
lines << "#define #{func_name}_ExpectWithArrayExtended(#{args_call_ext_i}) #{func_name}_CMockExpectWithArray(__LINE__, #{args_call_ext_o})\n" if has_paired
lines << "void #{func_name}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string});\n"
else
"#define #{function[:name]}_ExpectWithArray(#{args_call_i}) TEST_FAIL_MESSAGE(\"#{function[:name]} requires _ExpectWithArrayAndReturn\");\n" \
"#define #{function[:name]}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) #{function[:name]}_CMockExpectWithArrayAndReturn(__LINE__, #{args_call_o}, cmock_retval)\n" \
"void #{function[:name]}_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, #{args_string}, #{function[:return][:str]});\n"
if @error_stubs
lines << "#define #{func_name}_ExpectWithArray(#{args_call_i}) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArrayAndReturn\");\n"
lines << "#define #{func_name}_ExpectWithArrayExtended(#{args_call_ext_i}) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArrayExtendedAndReturn\");\n" if has_paired
end
lines << "#define #{func_name}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) #{func_name}_CMockExpectWithArrayAndReturn(__LINE__, #{args_call_o}, cmock_retval)\n"
lines << "#define #{func_name}_ExpectWithArrayExtendedAndReturn(#{args_call_ext_i}, cmock_retval) #{func_name}_CMockExpectWithArrayAndReturn(__LINE__, #{args_call_ext_o}, cmock_retval)\n" if has_paired
lines << "void #{func_name}_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, #{args_string}, #{function[:return][:str]});\n"
end
lines
end
def mock_interfaces(function)
@@ -49,11 +90,18 @@ class CMockGeneratorPluginArray
lines = []
func_name = function[:name]
# C function: always explicit depth for every pointer/string arg
args_string = function[:args].map do |m|
type = @utils.arg_type_with_const(m)
m[:ptr?] ? "#{type} #{m[:name]}, int #{m[:name]}_Depth" : "#{type} #{m[:name]}"
m[:ptr?] || m[:string?] ? "#{@utils.arg_declaration(m)}, int #{m[:name]}_Depth" : @utils.arg_declaration(m)
end.join(', ')
call_string = function[:args].map { |m| m[:ptr?] ? "#{m[:name]}, #{m[:name]}_Depth" : m[:name] }.join(', ')
# Call to CMockExpectParameters_: :before-paired ptrs pass only ptr name (their depth is set from paired size arg)
# string? args always pass their depth explicitly
call_string = function[:args].map do |m|
(m[:ptr?] || m[:string?]) && m[:array_size_order] != :before ? "#{m[:name]}, #{m[:name]}_Depth" : m[:name]
end.join(', ')
lines << if function[:return][:void?]
"void #{func_name}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string})\n"
else
@@ -62,6 +110,11 @@ class CMockGeneratorPluginArray
lines << "{\n"
lines << @utils.code_add_base_expectation(func_name)
lines << " CMockExpectParameters_#{func_name}(cmock_call_instance, #{call_string});\n"
# Override depths for :before-paired pointers. CMockExpectParameters_ sets these from the paired
# size arg; the explicit _Depth param here allows _ExpectWithArrayExtended to override that value.
function[:args].each do |arg|
lines << " cmock_call_instance->Expected_#{arg[:name]}_Depth = #{arg[:name]}_Depth;\n" if (arg[:ptr?] || arg[:string?]) && arg[:array_size_order] == :before
end
lines << " cmock_call_instance->ReturnVal = cmock_to_return;\n" unless function[:return][:void?]
lines << "}\n\n"
end

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