mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-11 06:40:29 +00:00
Compare commits
74 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df5ba4f2fc | |||
| d141b59324 | |||
| b992f1f2e9 | |||
| e851a39d58 | |||
| dc34a9000c | |||
| 55dd1f1ce5 | |||
| 9e8d1f93ef | |||
| 783bbde34d | |||
| 92debabbf0 | |||
| d20d18e75c | |||
| 5f74197056 | |||
| 6e048b07ff | |||
| d482f56066 | |||
| 1ef72ca854 | |||
| 85058d1407 | |||
| 411f6852f9 | |||
| 383c43246c | |||
| 990954c548 | |||
| de4e53cd7b | |||
| 84705b2e84 | |||
| 336a52bf57 | |||
| aaf9559a57 | |||
| 8c1f88fb82 | |||
| a0207f3800 | |||
| bad95c5f54 | |||
| f756eeaf55 | |||
| 82ef7e53cf | |||
| af610445b3 | |||
| a0de150635 | |||
| 3d4ddfdc4c | |||
| 29ef16e54b | |||
| 725e2d90ef | |||
| c06bbe791c | |||
| c40a6e08c6 | |||
| 5f0296eb0a | |||
| 165de30b7d | |||
| 04b5b21ffd | |||
| f20c59b029 | |||
| 6a9e3afe14 | |||
| 13da43dc95 | |||
| 469fe271f5 | |||
| a99deea71a | |||
| be420840b3 | |||
| d83c7017e0 | |||
| 5c6f42ae45 | |||
| f7c3f73b21 | |||
| f7689b8cc3 | |||
| feda84f23b | |||
| 7d99f0f51d | |||
| 9900e4c5f5 | |||
| ecd7e7154c | |||
| abcd75ffbc | |||
| f368744ca5 | |||
| 94dcd39765 | |||
| 75c3f3c7b3 | |||
| 2671ad7046 | |||
| bf9a13a8d4 | |||
| bb0b0e06f5 | |||
| 2bb9086214 | |||
| ad9ce635c3 | |||
| 6f2a234dca | |||
| 338279285b | |||
| 16ec975a87 | |||
| 0cefcf05f9 | |||
| c9154a19dd | |||
| 3ba7de2cb7 | |||
| bd41b3f939 | |||
| b1d0e36aa3 | |||
| d20dca34ab | |||
| f60fe4b808 | |||
| 076df6dd5c | |||
| 204117cb59 | |||
| 8ce70396d1 | |||
| 2bcc723e10 |
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
[submodule "vendor/unity"]
|
|
||||||
path = vendor/unity
|
|
||||||
url = https://github.com/throwtheswitch/unity.git
|
|
||||||
branch = master
|
|
||||||
[submodule "vendor/c_exception"]
|
[submodule "vendor/c_exception"]
|
||||||
path = vendor/c_exception
|
path = vendor/c_exception
|
||||||
url = https://github.com/throwtheswitch/cexception.git
|
url = https://github.com/throwtheswitch/cexception.git
|
||||||
branch = master
|
branch = master
|
||||||
|
[submodule "vendor/unity"]
|
||||||
|
path = vendor/unity
|
||||||
|
url = https://github.com/throwtheswitch/unity.git
|
||||||
|
branch = master
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
|
|||||||
+113
-13
@@ -1,13 +1,13 @@
|
|||||||
CMock: A Summary
|
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*
|
*This documentation is released under a Creative Commons 3.0 Attribution Share-Alike License*
|
||||||
|
|
||||||
- [Known Issues](docs/CMockKnownIssues.md)
|
- [Known Issues](CMockKnownIssues.md)
|
||||||
- [Change Log](docs/CMockChangeLog.md)
|
- [Change Log](CMockChangeLog.md)
|
||||||
- [How Does CMock Validate Arguments](docs/CMock_ArgumentValidation.md)
|
- [How Does CMock Validate Arguments](CMock_ArgumentValidation.md)
|
||||||
|
|
||||||
What Exactly Are We Talking About Here?
|
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
|
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 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.
|
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
|
then this assertion can also be used to directly compare the pointers to verify
|
||||||
that they are pointing to the same memory address.
|
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(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)`
|
* `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:
|
Ignore:
|
||||||
-------
|
-------
|
||||||
@@ -357,6 +378,23 @@ generate a skeleton instead:
|
|||||||
ruby cmock.rb --skeleton ../create/c/for/this.h
|
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:
|
Config Options:
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
@@ -420,6 +458,27 @@ from the defaults. We've tried to specify what the defaults are below.
|
|||||||
|
|
||||||
* default: *nil*
|
* 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`:
|
* `:enforce_strict_ordering`:
|
||||||
CMock always enforces the order that you call a particular function,
|
CMock always enforces the order that you call a particular function,
|
||||||
so if you expect GrabNabber(int size) to be called three times, it
|
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
|
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 old header with inline functions, the build system has to add
|
||||||
the mock folder to the include paths.
|
the mock folder to the include paths.
|
||||||
|
|
||||||
Furthermore, we need to keep the order of include paths in mind. We
|
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
|
have to set the mock folder before the other includes to avoid the
|
||||||
test code including the original header instead of the newly
|
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)`
|
* `void GoBananas(Banana * bananas, int num_bananas)`
|
||||||
* `int write_data(int fd, const uint8_t * data, uint32_t size)`
|
* `int write_data(int fd, const uint8_t * data, uint32_t size)`
|
||||||
|
* `void store_data(int buf_size, uint8_t * buf)`
|
||||||
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".
|
|
||||||
|
|
||||||
`:array_size_type` is a list of additional types (besides `int` and `size_t`)
|
`: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
|
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_'
|
cfg[:array_size_name] = 'size|len|num_'
|
||||||
|
|
||||||
Parameters must match *both* `:array_size_type` and `:array_size_name` (and
|
A parameter must match *both* `:array_size_type` and `:array_size_name` to be
|
||||||
must come right after a pointer parameter) to be treated as an array size.
|
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`
|
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
|
calls that work more like `_ExpectWithArray`, and compare an array of objects
|
||||||
@@ -804,6 +881,29 @@ based on other settings, particularly Unity's settings.
|
|||||||
This needs to be something big enough to point anywhere in Cmock's
|
This needs to be something big enough to point anywhere in Cmock's
|
||||||
memory space... usually it's a size_t.
|
memory space... usually it's a size_t.
|
||||||
|
|
||||||
|
* `CMOCK_MEMCPY`
|
||||||
|
The memory-copy function used by CMock's internals and the generated mocks.
|
||||||
|
It defaults to `memcpy` from `<string.h>`. Override alongside `CMOCK_MEMSET`
|
||||||
|
to supply a custom implementation on targets where the standard library is
|
||||||
|
unavailable or undesirable:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define CMOCK_MEMCPY(dst, src, size) my_memcpy(dst, src, size)
|
||||||
|
```
|
||||||
|
|
||||||
|
* `CMOCK_MEMSET`
|
||||||
|
The memory-set function used by CMock's internals to zero-initialize
|
||||||
|
allocated blocks. It defaults to `memset` from `<string.h>`. Override
|
||||||
|
alongside `CMOCK_MEMCPY` to keep CMock fully independent of the standard
|
||||||
|
library:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define CMOCK_MEMSET(dst, val, size) my_memset(dst, val, size)
|
||||||
|
```
|
||||||
|
|
||||||
|
If both `CMOCK_MEMCPY` and `CMOCK_MEMSET` are defined before including
|
||||||
|
`cmock.h`, CMock will not pull in `<string.h>` at all.
|
||||||
|
|
||||||
Other Tips
|
Other Tips
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ all: setup test ${BUILD_DIR}/main run
|
|||||||
setup:
|
setup:
|
||||||
mkdir -p ${BUILD_DIR}
|
mkdir -p ${BUILD_DIR}
|
||||||
mkdir -p ${OBJ}
|
mkdir -p ${OBJ}
|
||||||
ruby ../../scripts/create_makefile.rb --silent
|
ruby ../../scripts/create_makefile.rb
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf ${BUILD_DIR}
|
rm -rf ${BUILD_DIR}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
#include "mock_foo.h"
|
#include "Mockfoo.h"
|
||||||
|
|
||||||
void setUp(void)
|
void setUp(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ REQUIRED_DIRS.each do |v|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Load default configuration, for now
|
# Load default configuration, for now
|
||||||
DEFAULT_CONFIG_FILE = 'gcc.yml'.freeze
|
DEFAULT_CONFIG_FILE = 'gcc_64.yml'.freeze
|
||||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||||
|
|
||||||
task :unit do
|
task :unit do
|
||||||
@@ -39,8 +39,8 @@ task :ci => [:default]
|
|||||||
task :cruise => [:default]
|
task :cruise => [:default]
|
||||||
|
|
||||||
desc 'Load configuration'
|
desc 'Load configuration'
|
||||||
task :config, :config_file do |_t, args|
|
task :config, [:config_file, :cmock_overlay] do |_t, args|
|
||||||
configure_toolchain(args[:config_file])
|
configure_toolchain(args[:config_file], args[:cmock_overlay])
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Return error on Failures'
|
desc 'Return error on Failures'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -22,32 +22,81 @@ module RakefileHelpers
|
|||||||
YAML.load(yaml_string)
|
YAML.load(yaml_string)
|
||||||
end
|
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_file = config_file
|
||||||
$cfg = load_yaml(File.read("./targets/#{$cfg_file}"))
|
$proj = load_yaml(File.read('./project.yml'))
|
||||||
$colour_output = false unless $cfg['colour']
|
|
||||||
|
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
|
end
|
||||||
|
|
||||||
def configure_clean
|
def configure_clean
|
||||||
CLEAN.include("#{$cfg['compiler']['build_path']}*.*") unless $cfg['compiler']['build_path'].nil?
|
CLEAN.include("#{$proj[:project][:build_root]}*.*")
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE)
|
def configure_toolchain(config_file = DEFAULT_CONFIG_FILE, cmock_overlay = nil)
|
||||||
config_file += '.yml' unless config_file =~ /\.yml$/
|
config_file ||= DEFAULT_CONFIG_FILE
|
||||||
load_configuration(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
|
configure_clean
|
||||||
end
|
end
|
||||||
|
|
||||||
def unit_test_files
|
def unit_test_files
|
||||||
path = $cfg['compiler']['unit_tests_path'] + "Test*#{C_EXTENSION}"
|
path = $proj[:paths][:test] + "Test*#{C_EXTENSION}"
|
||||||
path.tr!('\\', '/')
|
path.tr!('\\', '/')
|
||||||
FileList.new(path)
|
FileList.new(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def local_include_dirs
|
def local_include_dirs
|
||||||
include_dirs = $cfg['compiler']['includes']['items'].dup
|
$proj[:paths][:include].reject { |dir| dir.is_a?(Array) }
|
||||||
include_dirs.delete_if { |dir| dir.is_a?(Array) }
|
|
||||||
include_dirs
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def extract_headers(filename)
|
def extract_headers(filename)
|
||||||
@@ -55,9 +104,7 @@ module RakefileHelpers
|
|||||||
lines = File.readlines(filename)
|
lines = File.readlines(filename)
|
||||||
lines.each do |line|
|
lines.each do |line|
|
||||||
m = line.match(/^\s*#include\s+"\s*(.+\.[hH])\s*"/)
|
m = line.match(/^\s*#include\s+"\s*(.+\.[hH])\s*"/)
|
||||||
unless m.nil?
|
includes << m[1] unless m.nil?
|
||||||
includes << m[1]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
includes
|
includes
|
||||||
end
|
end
|
||||||
@@ -65,9 +112,7 @@ module RakefileHelpers
|
|||||||
def find_source_file(header, paths)
|
def find_source_file(header, paths)
|
||||||
paths.each do |dir|
|
paths.each do |dir|
|
||||||
src_file = dir + header.ext(C_EXTENSION)
|
src_file = dir + header.ext(C_EXTENSION)
|
||||||
if File.exist?(src_file)
|
return src_file if File.exist?(src_file)
|
||||||
return src_file
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
@@ -85,79 +130,96 @@ module RakefileHelpers
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def squash(prefix, items)
|
# All defines: project common + Unity target + CMock overlay + any extras
|
||||||
result = ''
|
def all_defines(extra = [])
|
||||||
items.each { |item| result += " #{prefix}#{tackit(item)}" }
|
(($proj[:defines][:test] || []) +
|
||||||
result
|
($unity_cfg[:defines][:test] || []) +
|
||||||
|
(($cmock_cfg[:defines] || {})[:test] || []) +
|
||||||
|
extra).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_compiler_fields
|
# Toolchain-specific include paths: Array items in Unity's :paths: :test:
|
||||||
command = tackit($cfg['compiler']['path'])
|
def toolchain_include_paths
|
||||||
defines = if $cfg['compiler']['defines']['items'].nil?
|
if $unity_cfg[:paths] && $unity_cfg[:paths][:test]
|
||||||
''
|
$unity_cfg[:paths][:test]
|
||||||
else
|
else
|
||||||
squash($cfg['compiler']['defines']['prefix'], $cfg['compiler']['defines']['items'])
|
[]
|
||||||
end
|
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 }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(file, _defines = [])
|
# Resolve argument template tokens into a flat argument string.
|
||||||
compiler = build_compiler_fields
|
# Supports Ceedling-style positional tokens and legacy Unity COLLECTION_* tokens.
|
||||||
cmd_str = "#{compiler[:command]}#{compiler[:defines]}#{compiler[:options]}#{compiler[:includes]} #{file} " \
|
# ${5} → expands to one arg per include path (toolchain paths + project paths combined)
|
||||||
"#{$cfg['compiler']['object_files']['prefix']}#{$cfg['compiler']['object_files']['destination']}"
|
# ${6} → expands to one arg per define
|
||||||
obj_file = "#{File.basename(file, C_EXTENSION)}#{$cfg['compiler']['object_files']['extension']}"
|
# ${1} → input file(s)
|
||||||
execute(cmd_str + obj_file)
|
# ${2} → output file
|
||||||
obj_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
|
end
|
||||||
|
|
||||||
def build_linker_fields
|
def compile(file, extra_defines = [])
|
||||||
command = tackit($cfg['linker']['path'])
|
tool = $unity_cfg[:tools][:test_compiler]
|
||||||
options = if $cfg['linker']['options'].nil?
|
ext = $unity_cfg[:extension][:object] || '.o'
|
||||||
''
|
build_root = $proj[:project][:build_root] || 'build/'
|
||||||
else
|
obj_file = build_root + File.basename(file, C_EXTENSION) + ext
|
||||||
squash('', $cfg['linker']['options'])
|
|
||||||
end
|
cmd_str = "#{tackit(tool[:executable])} #{
|
||||||
includes = if $cfg['linker']['includes'].nil? || $cfg['linker']['includes']['items'].nil?
|
build_argument_list(tool[:arguments],
|
||||||
''
|
toolchain_include_paths,
|
||||||
else
|
$proj[:paths][:include],
|
||||||
squash($cfg['linker']['includes']['prefix'], $cfg['linker']['includes']['items'])
|
all_defines(extra_defines),
|
||||||
end
|
file, obj_file)}"
|
||||||
includes = includes.gsub(/\\ /, ' ').gsub(/\\"/, '"').gsub(/\\$/, '') # Remove trailing slashes (for IAR)
|
execute(cmd_str)
|
||||||
{ :command => command, :options => options, :includes => includes }
|
File.basename(obj_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_it(exe_name, obj_list)
|
def link_it(exe_name, obj_list)
|
||||||
linker = build_linker_fields
|
tool = $unity_cfg[:tools][:test_linker]
|
||||||
cmd_str = "#{linker[:command]}#{linker[:includes]} " \
|
ext = $unity_cfg[:extension][:executable] || ''
|
||||||
"#{(obj_list.map { |obj| "#{$cfg['linker']['object_files']['path']}#{obj} " }).join}" \
|
build_root = $proj[:project][:build_root] || 'build/'
|
||||||
"#{$cfg['linker']['bin_files']['prefix']} " \
|
|
||||||
"#{$cfg['linker']['bin_files']['destination']}" \
|
input_files = obj_list.uniq.map { |obj| build_root + obj }.join(' ')
|
||||||
"#{exe_name}#{$cfg['linker']['bin_files']['extension']} #{linker[:options]}"
|
output_file = build_root + exe_name + ext
|
||||||
|
|
||||||
|
cmd_str = "#{tackit(tool[:executable])} #{build_argument_list(tool[:arguments], [], [], [], input_files, output_file)}"
|
||||||
execute(cmd_str)
|
execute(cmd_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_simulator_fields
|
def build_simulator_fields
|
||||||
return nil if $cfg['simulator'].nil?
|
return nil unless $unity_cfg[:tools][:test_fixture]
|
||||||
|
|
||||||
command = if $cfg['simulator']['path'].nil?
|
tool = $unity_cfg[:tools][:test_fixture]
|
||||||
''
|
executable = tackit(tool[:executable])
|
||||||
else
|
raw_args = tool[:arguments] || []
|
||||||
"#{tackit($cfg['simulator']['path'])} "
|
idx = raw_args.index('${1}')
|
||||||
end
|
if idx
|
||||||
pre_support = if $cfg['simulator']['pre_support'].nil?
|
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
|
else
|
||||||
squash('', $cfg['simulator']['pre_support'])
|
pre = ''
|
||||||
end
|
post = raw_args.map { |a| a.is_a?(Array) ? a.join : a }.join(' ')
|
||||||
post_support = if $cfg['simulator']['post_support'].nil?
|
end
|
||||||
''
|
{ command: "#{executable} ", pre_support: pre, post_support: post }
|
||||||
else
|
|
||||||
squash('', $cfg['simulator']['post_support'])
|
|
||||||
end
|
|
||||||
{ :command => command, :pre_support => pre_support, :post_support => post_support }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(command_string, verbose = true, ok_to_fail = false)
|
def execute(command_string, verbose = true, ok_to_fail = false)
|
||||||
@@ -174,7 +236,7 @@ module RakefileHelpers
|
|||||||
def report_summary
|
def report_summary
|
||||||
summary = UnityTestSummary.new
|
summary = UnityTestSummary.new
|
||||||
summary.root = HERE
|
summary.root = HERE
|
||||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
results_glob = "#{$proj[:project][:build_root]}*.test*"
|
||||||
results_glob.tr!('\\', '/')
|
results_glob.tr!('\\', '/')
|
||||||
results = Dir[results_glob]
|
results = Dir[results_glob]
|
||||||
summary.targets = results
|
summary.targets = results
|
||||||
@@ -185,71 +247,56 @@ module RakefileHelpers
|
|||||||
def run_tests(test_files)
|
def run_tests(test_files)
|
||||||
report 'Running system tests...'
|
report 'Running system tests...'
|
||||||
|
|
||||||
# Tack on TEST define for compiling unit tests
|
|
||||||
load_configuration($cfg_file)
|
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
|
include_dirs = local_include_dirs
|
||||||
|
|
||||||
# Build and execute each unit test
|
# Build and execute each unit test
|
||||||
test_files.each do |test|
|
test_files.each do |test|
|
||||||
# Detect dependencies and build required required modules
|
# Detect dependencies and build required modules
|
||||||
header_list = (extract_headers(test) + ['cmock.h'] + [$cfg[:cmock][:unity_helper_path]]).compact.uniq
|
header_list = (extract_headers(test) + ['cmock.h'] + [($proj[:cmock] || {})[:unity_helper_path]]).compact.uniq
|
||||||
header_list.each do |header|
|
header_list.each do |header|
|
||||||
# create mocks if needed
|
# create mocks if needed
|
||||||
next unless header =~ /Mock/
|
next unless header =~ /Mock/
|
||||||
|
|
||||||
require '../../lib/cmock'
|
require '../../lib/cmock'
|
||||||
@cmock ||= CMock.new(".//targets//#{$cfg_file}")
|
@cmock ||= CMock.new($proj[:cmock])
|
||||||
@cmock.setup_mocks([$cfg['compiler']['source_path'] + header.gsub('Mock', '')])
|
@cmock.setup_mocks([$proj[:paths][:source].first + header.gsub('Mock', '')])
|
||||||
end
|
end
|
||||||
|
|
||||||
# compile all mocks
|
# compile all mocks and dependencies
|
||||||
obj_list = []
|
obj_list = []
|
||||||
header_list.each do |header|
|
header_list.each do |header|
|
||||||
# compile source file header if it exists
|
|
||||||
src_file = find_source_file(header, include_dirs)
|
src_file = find_source_file(header, include_dirs)
|
||||||
unless src_file.nil?
|
obj_list << compile(src_file, ['TEST']) unless src_file.nil?
|
||||||
obj_list << compile(src_file, test_defines)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build the test runner (generate if configured to do so)
|
# Build the test runner
|
||||||
test_base = File.basename(test, C_EXTENSION)
|
test_base = File.basename(test, C_EXTENSION)
|
||||||
runner_name = "#{test_base}_Runner.c"
|
runner_name = "#{test_base}_Runner.c"
|
||||||
if $cfg['compiler']['runner_path'].nil?
|
runner_path = "#{$proj[:project][:build_root]}#{runner_name}"
|
||||||
runner_path = "#{$cfg['compiler']['build_path']}#{runner_name}"
|
UnityTestRunnerGenerator.new({}).run(test, runner_path)
|
||||||
test_gen = UnityTestRunnerGenerator.new(".//targets//#{$cfg_file}")
|
|
||||||
test_gen.run(test, runner_path)
|
|
||||||
else
|
|
||||||
runner_path = $cfg['compiler']['runner_path'] + runner_name
|
|
||||||
end
|
|
||||||
|
|
||||||
obj_list << compile(runner_path, test_defines)
|
obj_list << compile(runner_path, ['TEST'])
|
||||||
|
|
||||||
# Build the test module
|
# Build the test module
|
||||||
obj_list << compile(test, test_defines)
|
obj_list << compile(test, ['TEST'])
|
||||||
|
|
||||||
# Link the test executable
|
# Link the test executable
|
||||||
link_it(test_base, obj_list)
|
link_it(test_base, obj_list)
|
||||||
|
|
||||||
# Execute unit test and generate results file
|
# Execute unit test and generate results file
|
||||||
simulator = build_simulator_fields
|
simulator = build_simulator_fields
|
||||||
executable = $cfg['linker']['bin_files']['destination'] + test_base + $cfg['linker']['bin_files']['extension']
|
build_root = $proj[:project][:build_root]
|
||||||
|
executable = build_root + test_base + ($unity_cfg[:extension][:executable] || '')
|
||||||
cmd_str = if simulator.nil?
|
cmd_str = if simulator.nil?
|
||||||
executable
|
executable
|
||||||
else
|
else
|
||||||
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
"#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||||
end
|
end
|
||||||
output = execute(cmd_str, true)
|
output = execute(cmd_str, true)
|
||||||
test_results = $cfg['compiler']['build_path'] + test_base
|
test_results = build_root + test_base
|
||||||
test_results += if output.match(/OK$/m).nil?
|
test_results += output.match(/OK$/m).nil? ? '.testfail' : '.testpass'
|
||||||
'.testfail'
|
|
||||||
else
|
|
||||||
'.testpass'
|
|
||||||
end
|
|
||||||
File.open(test_results, 'w') { |f| f.print output }
|
File.open(test_results, 'w') { |f| f.print output }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -258,23 +305,20 @@ module RakefileHelpers
|
|||||||
report 'Building application...'
|
report 'Building application...'
|
||||||
|
|
||||||
obj_list = []
|
obj_list = []
|
||||||
load_configuration(".//targets//#{$cfg_file}")
|
load_configuration($cfg_file)
|
||||||
main_path = $cfg['compiler']['source_path'] + main + C_EXTENSION
|
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
|
include_dirs = local_include_dirs
|
||||||
extract_headers(main_path).each do |header|
|
extract_headers(main_path).each do |header|
|
||||||
src_file = find_source_file(header, include_dirs)
|
src_file = find_source_file(header, include_dirs)
|
||||||
unless src_file.nil?
|
obj_list << compile(src_file) unless src_file.nil?
|
||||||
obj_list << compile(src_file)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Build the main source file
|
# Build the main source file
|
||||||
main_base = File.basename(main_path, C_EXTENSION)
|
|
||||||
obj_list << compile(main_path)
|
obj_list << compile(main_path)
|
||||||
|
|
||||||
# Create the executable
|
# Create the executable
|
||||||
link_it(main_base, obj_list)
|
link_it(File.basename(main_path, C_EXTENSION), obj_list)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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.
|
|
||||||
@@ -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,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ void tearDown(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void testShouldInitializeTemeratureToInvalidValue(void)
|
void testShouldInitializeTemperatureToInvalidValue(void)
|
||||||
{
|
{
|
||||||
TemperatureFilter_Init();
|
TemperatureFilter_Init();
|
||||||
TEST_ASSERT_FLOAT_WITHIN(0.0001f, -INFINITY, TemperatureFilter_GetTemperatureInCelcius());
|
TEST_ASSERT_FLOAT_WITHIN(0.0001f, -INFINITY, TemperatureFilter_GetTemperatureInCelcius());
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
CMock - Automatic Mock Generation for C
|
CMock - Automatic Mock Generation for C
|
||||||
ThrowTheSwitch.org
|
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
|
SPDX-License-Identifier: MIT
|
||||||
========================================================================= */
|
========================================================================= */
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ class CMockConfig
|
|||||||
:array_size_name => 'size|len',
|
:array_size_name => 'size|len',
|
||||||
:skeleton => false,
|
:skeleton => false,
|
||||||
:exclude_setjmp_h => false,
|
:exclude_setjmp_h => false,
|
||||||
|
:create_error_stubs => true,
|
||||||
|
|
||||||
# Format to look for inline functions.
|
# Format to look for inline functions.
|
||||||
# This is a combination of "static" and "inline" keywords ("static inline", "inline static", "inline", "static")
|
# This is a combination of "static" and "inline" keywords ("static inline", "inline static", "inline", "static")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -16,6 +16,17 @@ class CMockFileWriter
|
|||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
FileUtils.mkdir_p "#{@config.mock_path}/" unless Dir.exist?("#{@config.mock_path}/")
|
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}")
|
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
|
end
|
||||||
|
|
||||||
def create_file(filename, subdir)
|
def create_file(filename, subdir)
|
||||||
@@ -27,6 +38,27 @@ class CMockFileWriter
|
|||||||
yield(file, filename)
|
yield(file, filename)
|
||||||
end
|
end
|
||||||
update_file(full_file_name_done, full_file_name_temp)
|
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
|
end
|
||||||
|
|
||||||
def append_file(filename, subdir)
|
def append_file(filename, subdir)
|
||||||
@@ -40,6 +72,11 @@ class CMockFileWriter
|
|||||||
|
|
||||||
private ###################################
|
private ###################################
|
||||||
|
|
||||||
|
def effective_skeleton_path
|
||||||
|
path = @config.skeleton_path
|
||||||
|
path.nil? || path.empty? ? @config.mock_path : path
|
||||||
|
end
|
||||||
|
|
||||||
def update_file(dest, src)
|
def update_file(dest, src)
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
FileUtils.rm(dest, :force => true)
|
FileUtils.rm(dest, :force => true)
|
||||||
|
|||||||
+42
-27
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ class CMockGenerator
|
|||||||
:skeleton => true
|
:skeleton => true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@file_writer.create_skeleton_subdir(@subdir)
|
||||||
create_skeleton_source_file(mock_project)
|
create_skeleton_source_file(mock_project)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -133,9 +134,9 @@ class CMockGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_skeleton_source_file(mock_project)
|
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) : ''
|
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 = mock_project.clone
|
||||||
blank_project[:parsed_stuff] = { :functions => [] }
|
blank_project[:parsed_stuff] = { :functions => [] }
|
||||||
if existing.empty?
|
if existing.empty?
|
||||||
@@ -210,24 +211,30 @@ class CMockGenerator
|
|||||||
|
|
||||||
def create_source_header_section(file, filename, mock_project)
|
def create_source_header_section(file, filename, mock_project)
|
||||||
header_file = (mock_project[:folder] || '') + filename.sub(/.*\K\.c/, mock_project[:module_ext])
|
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?
|
if mock_project[:skeleton]
|
||||||
file << "#include <string.h>\n"
|
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
|
||||||
file << "#include <stdlib.h>\n"
|
file << "#include \"#{header_file}\"\n"
|
||||||
unless @exclude_setjmp_h
|
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
|
||||||
file << "#include <setjmp.h>\n"
|
else
|
||||||
end
|
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n" unless mock_project[:parsed_stuff][:functions].empty?
|
||||||
file << "#include \"cmock.h\"\n"
|
file << "#include <string.h>\n"
|
||||||
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
|
file << "#include <stdlib.h>\n"
|
||||||
file << "#include \"#{header_file}\"\n"
|
unless @exclude_setjmp_h
|
||||||
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
|
file << "#include <setjmp.h>\n"
|
||||||
file << "\n"
|
end
|
||||||
strs = []
|
file << "#include \"cmock.h\"\n"
|
||||||
mock_project[:parsed_stuff][:functions].each do |func|
|
@includes_c_pre_header.each { |inc| file << "#include #{inc}\n" }
|
||||||
strs << func[:name]
|
file << "#include \"#{header_file}\"\n"
|
||||||
func[:args].each { |arg| strs << arg[:name] }
|
@includes_c_post_header.each { |inc| file << "#include #{inc}\n" }
|
||||||
end
|
file << "\n"
|
||||||
strs.uniq.sort.each do |str|
|
strs = []
|
||||||
file << "static const char* CMockString_#{str} = \"#{str}\";\n"
|
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
|
end
|
||||||
file << "\n"
|
file << "\n"
|
||||||
end
|
end
|
||||||
@@ -296,11 +303,20 @@ class CMockGenerator
|
|||||||
file << "}\n\n"
|
file << "}\n\n"
|
||||||
end
|
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)
|
def create_mock_implementation(file, function)
|
||||||
# prepare return value and arguments
|
# prepare return value and arguments
|
||||||
function_mod_and_rettype = (function[:modifier].empty? ? '' : "#{function[:modifier]} ") +
|
function_mod_and_rettype = function_return_type(function)
|
||||||
(function[:return][:type]) +
|
|
||||||
(function[:c_calling_convention] ? " #{function[:c_calling_convention]}" : '')
|
|
||||||
args_string = function[:args_string]
|
args_string = function[:args_string]
|
||||||
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
|
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
|
||||||
|
|
||||||
@@ -330,6 +346,7 @@ class CMockGenerator
|
|||||||
file << " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n"
|
file << " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n"
|
||||||
file << " cmock_call_instance = (CMOCK_#{function[:name]}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.#{function[:name]}_CallInstance);\n"
|
file << " cmock_call_instance = (CMOCK_#{function[:name]}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(Mock.#{function[:name]}_CallInstance);\n"
|
||||||
file << " Mock.#{function[:name]}_CallInstance = CMock_Guts_MemNext(Mock.#{function[:name]}_CallInstance);\n"
|
file << " Mock.#{function[:name]}_CallInstance = CMock_Guts_MemNext(Mock.#{function[:name]}_CallInstance);\n"
|
||||||
|
file << @plugins.run(:mock_precheck_return_thru_ptr, function)
|
||||||
file << @plugins.run(:mock_implementation_precheck, function)
|
file << @plugins.run(:mock_implementation_precheck, function)
|
||||||
file << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n"
|
file << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n"
|
||||||
file << " cmock_line = cmock_call_instance->LineNumber;\n"
|
file << " cmock_line = cmock_call_instance->LineNumber;\n"
|
||||||
@@ -359,9 +376,7 @@ class CMockGenerator
|
|||||||
|
|
||||||
def create_function_skeleton(file, function, existing)
|
def create_function_skeleton(file, function, existing)
|
||||||
# prepare return value and arguments
|
# prepare return value and arguments
|
||||||
function_mod_and_rettype = (function[:modifier].empty? ? '' : "#{function[:modifier]} ") +
|
function_mod_and_rettype = function_return_type(function)
|
||||||
(function[:return][:type]) +
|
|
||||||
(function[:c_calling_convention] ? " #{function[:c_calling_convention]}" : '')
|
|
||||||
args_string = function[:args_string]
|
args_string = function[:args_string]
|
||||||
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
|
args_string += ", #{function[:var_arg]}" unless function[:var_arg].nil?
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@ class CMockGeneratorPluginArray
|
|||||||
@config = config
|
@config = config
|
||||||
@ptr_handling = @config.when_ptr
|
@ptr_handling = @config.when_ptr
|
||||||
@ordered = @config.enforce_strict_ordering
|
@ordered = @config.enforce_strict_ordering
|
||||||
|
@error_stubs = @config.create_error_stubs
|
||||||
@utils = utils
|
@utils = utils
|
||||||
@unity_helper = @utils.helpers[:unity_helper]
|
@unity_helper = @utils.helpers[:unity_helper]
|
||||||
@priority = 8
|
@priority = 8
|
||||||
@@ -20,28 +21,68 @@ class CMockGeneratorPluginArray
|
|||||||
|
|
||||||
def instance_typedefs(function)
|
def instance_typedefs(function)
|
||||||
function[:args].inject('') do |all, arg|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_function_declarations(function)
|
def mock_function_declarations(function)
|
||||||
return nil unless function[:contains_ptr?]
|
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(', ')
|
func_name = function[:name]
|
||||||
args_call_o = function[:args].map { |m| m[:ptr?] ? "#{m[:name]}, (#{m[:name]}_Depth)" : (m[:name]).to_s }.join(', ')
|
|
||||||
|
# C function signature: always explicit depth for every pointer/string arg
|
||||||
args_string = function[:args].map do |m|
|
args_string = function[:args].map do |m|
|
||||||
type = @utils.arg_type_with_const(m)
|
m[:ptr?] || m[:string?] ? "#{@utils.arg_declaration(m)}, int #{m[:name]}_Depth" : @utils.arg_declaration(m)
|
||||||
m[:ptr?] ? "#{type} #{m[:name]}, int #{m[:name]}_Depth" : "#{type} #{m[:name]}"
|
|
||||||
end.join(', ')
|
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?]
|
if function[:return][:void?]
|
||||||
"#define #{function[:name]}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) TEST_FAIL_MESSAGE(\"#{function[:name]} requires _ExpectWithArray (not AndReturn)\");\n" \
|
if @error_stubs
|
||||||
"#define #{function[:name]}_ExpectWithArray(#{args_call_i}) #{function[:name]}_CMockExpectWithArray(__LINE__, #{args_call_o})\n" \
|
lines << "#define #{func_name}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArray (not AndReturn)\");\n"
|
||||||
"void #{function[:name]}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string});\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
|
else
|
||||||
"#define #{function[:name]}_ExpectWithArray(#{args_call_i}) TEST_FAIL_MESSAGE(\"#{function[:name]} requires _ExpectWithArrayAndReturn\");\n" \
|
if @error_stubs
|
||||||
"#define #{function[:name]}_ExpectWithArrayAndReturn(#{args_call_i}, cmock_retval) #{function[:name]}_CMockExpectWithArrayAndReturn(__LINE__, #{args_call_o}, cmock_retval)\n" \
|
lines << "#define #{func_name}_ExpectWithArray(#{args_call_i}) TEST_FAIL_MESSAGE(\"#{func_name} requires _ExpectWithArrayAndReturn\");\n"
|
||||||
"void #{function[:name]}_CMockExpectWithArrayAndReturn(UNITY_LINE_TYPE cmock_line, #{args_string}, #{function[:return][:str]});\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
|
end
|
||||||
|
lines
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_interfaces(function)
|
def mock_interfaces(function)
|
||||||
@@ -49,11 +90,18 @@ class CMockGeneratorPluginArray
|
|||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
func_name = function[:name]
|
func_name = function[:name]
|
||||||
|
|
||||||
|
# C function: always explicit depth for every pointer/string arg
|
||||||
args_string = function[:args].map do |m|
|
args_string = function[:args].map do |m|
|
||||||
type = @utils.arg_type_with_const(m)
|
m[:ptr?] || m[:string?] ? "#{@utils.arg_declaration(m)}, int #{m[:name]}_Depth" : @utils.arg_declaration(m)
|
||||||
m[:ptr?] ? "#{type} #{m[:name]}, int #{m[:name]}_Depth" : "#{type} #{m[:name]}"
|
|
||||||
end.join(', ')
|
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?]
|
lines << if function[:return][:void?]
|
||||||
"void #{func_name}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string})\n"
|
"void #{func_name}_CMockExpectWithArray(UNITY_LINE_TYPE cmock_line, #{args_string})\n"
|
||||||
else
|
else
|
||||||
@@ -62,6 +110,11 @@ class CMockGeneratorPluginArray
|
|||||||
lines << "{\n"
|
lines << "{\n"
|
||||||
lines << @utils.code_add_base_expectation(func_name)
|
lines << @utils.code_add_base_expectation(func_name)
|
||||||
lines << " CMockExpectParameters_#{func_name}(cmock_call_instance, #{call_string});\n"
|
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 << " cmock_call_instance->ReturnVal = cmock_to_return;\n" unless function[:return][:void?]
|
||||||
lines << "}\n\n"
|
lines << "}\n\n"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# =========================================================================
|
# =========================================================================
|
||||||
# CMock - Automatic Mock Generation for C
|
# CMock - Automatic Mock Generation for C
|
||||||
# ThrowTheSwitch.org
|
# 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
|
# SPDX-License-Identifier: MIT
|
||||||
# =========================================================================
|
# =========================================================================
|
||||||
|
|
||||||
@@ -43,7 +43,8 @@ class CMockGeneratorPluginCallback
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mock_implementation(function)
|
def mock_implementation(function)
|
||||||
" if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" +
|
" if (Mock.#{function[:name]}_CallbackFunctionPointer != NULL)\n {\n" \
|
||||||
|
" UNITY_SET_DETAIL(CMockString_#{function[:name]});\n" +
|
||||||
if function[:return][:void?]
|
if function[:return][:void?]
|
||||||
" #{generate_call(function)};\n }\n"
|
" #{generate_call(function)};\n }\n"
|
||||||
else
|
else
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user