mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-23 14:00:33 +00:00
Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6e03886f25 | |||
| 50adf82ed4 | |||
| f2ea4284a6 | |||
| fb96bb3033 | |||
| 9a44444f8b | |||
| 725641409b | |||
| c4cd7d54a9 | |||
| aed11e6d0d | |||
| 51b327042f | |||
| ef04f4ab7f | |||
| 27c5a9cff5 | |||
| 43fa31380d | |||
| 413c803543 | |||
| ee45a7b1e7 | |||
| 699563e503 | |||
| 454fcfb7a3 | |||
| 4b441eafea | |||
| a04e3f160c | |||
| df7c67c445 | |||
| 9c9f08c48b | |||
| 55462aef40 | |||
| 42dab4836d | |||
| 693c658780 | |||
| 7eb7e14fbc | |||
| 846423768b | |||
| 9e69cfb9b1 | |||
| 53d6a7c0e4 | |||
| a604fb71a4 | |||
| 46f609efee | |||
| 5ee669ecc0 | |||
| 02aeab8fef | |||
| 9e33ff32cf | |||
| 295fe3be4e | |||
| 73a6aa003b | |||
| 725bfd93a0 | |||
| 0b303dba29 | |||
| c61a35d2a5 | |||
| 1ffba4383c | |||
| 08b255868a | |||
| f0a9b5930e | |||
| 33dabf8338 | |||
| 7cd25b07a1 | |||
| b58f15d0be | |||
| 58971b15db | |||
| 4bda2b21d4 | |||
| 14ba424b02 | |||
| 677d02e43e | |||
| 6dff24ecda | |||
| 4bd12aaaf6 | |||
| 168da7c418 | |||
| fbcffe65a3 | |||
| f1789ba633 | |||
| 392a5537d9 | |||
| bfdfe944b9 | |||
| 07d6714fe2 | |||
| 2af7c7de43 | |||
| abd526d585 | |||
| dfc1955c51 | |||
| 1939bbe666 | |||
| dcd6fe44af | |||
| 8b73bf3835 | |||
| 648f3960ff | |||
| f4f149792f | |||
| b666bf05c1 | |||
| a139775672 | |||
| 660c342fc6 | |||
| 1bb97ff2a8 | |||
| d2fc813b51 | |||
| a182e33a9a | |||
| dd791fe407 | |||
| 06b9f23054 | |||
| 9be03c215a | |||
| ebf4ae274a | |||
| a55efdba19 | |||
| 42a937a097 | |||
| 9e49bace32 | |||
| eddfb75d59 | |||
| 39e99e9803 | |||
| 30064aa63c | |||
| c719dff1ad | |||
| dda0351471 | |||
| 29541c1e46 | |||
| 8c8c2a2292 | |||
| 29c1d07f25 | |||
| be70af1297 | |||
| cfe52ba90f | |||
| b0264f68f4 | |||
| 242fd73d3e | |||
| d59ec41c52 | |||
| 52e89e9507 |
+23
-2
@@ -1,8 +1,29 @@
|
||||
language: ruby
|
||||
|
||||
os:
|
||||
- osx
|
||||
- linux
|
||||
|
||||
rvm:
|
||||
- "1.9.3"
|
||||
- "2.0.0"
|
||||
- "2.2.2"
|
||||
|
||||
before_install:
|
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then rvm install 2.1 && rvm use 2.1 && ruby -v; fi
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install --assume-yes --quiet gcc-multilib; fi
|
||||
|
||||
install:
|
||||
- bundle install
|
||||
- gem install rspec
|
||||
- gem install rubocop
|
||||
|
||||
script:
|
||||
- bundle exec rake ci
|
||||
- cd test && rake ci
|
||||
- cd ..
|
||||
- cd examples && cd make_example
|
||||
- make clean
|
||||
- make setup
|
||||
- make test
|
||||
- cd ..
|
||||
- cd temp_sensor
|
||||
- rake ci
|
||||
|
||||
@@ -6,10 +6,19 @@ CMock - Mock/stub generator for C
|
||||
Getting Started
|
||||
================
|
||||
|
||||
If you're using Ceedling, there is no need to install CMock. It will handle it for you.
|
||||
For everyone else, the simplest way is to grab it off github. You can also download it
|
||||
as a zip if you prefer. The Github method looks something like this:
|
||||
|
||||
> git clone --recursive https://github.com/throwtheswitch/cmock.git
|
||||
> cd cmock
|
||||
> bundle install # Ensures you have all RubyGems needed
|
||||
> bundle exec rake # Run all CMock library tests
|
||||
|
||||
If you plan to help with the development of CMock (or just want to verify that it can
|
||||
perform its self tests on your system) then you can enter the test directory and then
|
||||
ask it to test:
|
||||
|
||||
> rake # Run all CMock self tests
|
||||
|
||||
API Documentation
|
||||
=================
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
# CMock Project - Automatic Mock Generation for C
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
# ==========================================
|
||||
|
||||
# Setup our load path:
|
||||
[
|
||||
'lib',
|
||||
'vendor/behaviors/lib',
|
||||
'vendor/hardmock/lib',
|
||||
'vendor/unity/auto/',
|
||||
'test/system/'
|
||||
[
|
||||
'./lib',
|
||||
'./vendor/behaviors/lib',
|
||||
'./vendor/hardmock/lib',
|
||||
'./vendor/unity/auto/',
|
||||
'./test/system/'
|
||||
].each do |dir|
|
||||
$LOAD_PATH.unshift( File.join( File.expand_path(File.dirname(__FILE__) + "/../"), dir) )
|
||||
end
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+331
-119
@@ -1,15 +1,16 @@
|
||||
[All code is copyright © 2007-2014 Cmock Project
|
||||
by Mike Karlesky, Mark VanderVoord, and Greg Williams.
|
||||
CMock: A Summary
|
||||
================
|
||||
|
||||
This Documentation Is Released Under a Creative Commons 3.0
|
||||
Attribution Share-Alike License]
|
||||
*[ThrowTheSwitch.org](http://throwtheswitch.org)*
|
||||
|
||||
*This documentation is released under a Creative Commons 3.0 Attribution Share-Alike License*
|
||||
|
||||
|
||||
What the What?
|
||||
==============
|
||||
What Exactly Are We Talking About Here?
|
||||
---------------------------------------
|
||||
|
||||
CMock is a nice little tool which takes your header files and creates
|
||||
a Mock interface for it so that you can more easily Unit test modules
|
||||
a Mock interface for it so that you can more easily unit test modules
|
||||
that touch other modules. For each function prototype in your
|
||||
header, like this one:
|
||||
|
||||
@@ -60,7 +61,29 @@ call DoesSomething enough, or too much, or with the wrong arguments,
|
||||
or in the wrong order.
|
||||
|
||||
CMock is based on Unity, which it uses for all internal testing.
|
||||
It uses Ruby to do all the main work (versions 1.8.6 through 1.9.2).
|
||||
It uses Ruby to do all the main work (versions 2.0.0 and above).
|
||||
|
||||
|
||||
Installing
|
||||
==========
|
||||
|
||||
The first thing you need to do to install CMock is to get yourself
|
||||
a copy of Ruby. If you're on linux or osx, you probably already
|
||||
have it. You can prove it by typing the following:
|
||||
|
||||
ruby --version
|
||||
|
||||
|
||||
If it replied in a way that implies ignorance, then you're going to
|
||||
need to install it. You can go to [ruby-lang](https://ruby-lang.org)
|
||||
to get the latest version. You're also going to need to do that if it
|
||||
replied with a version that is older than 2.0.0. Go ahead. We'll wait.
|
||||
|
||||
Once you have Ruby, you have three options:
|
||||
|
||||
* Clone the latest [CMock repo on github](https://github.com/ThrowTheSwitch/CMock/)
|
||||
* Download the latest [CMock zip from github](https://github.com/ThrowTheSwitch/CMock/)
|
||||
* Install Ceedling (which has it built in!) through your commandline using `gem install ceedling`.
|
||||
|
||||
|
||||
Generated Mock Module Summary
|
||||
@@ -76,7 +99,11 @@ Expect:
|
||||
-------
|
||||
|
||||
Your basic staple Expects which will be used for most of your day
|
||||
to day CMock work.
|
||||
to day CMock work. By calling this, you are telling CMock that you
|
||||
expect that function to be called during your test. It also specifies
|
||||
which arguments you expect it to be called with, and what return
|
||||
value you want returned when that happens. You can call this function
|
||||
multiple times back to back in order to queue up multiple calls.
|
||||
|
||||
* `void func(void)` => `void func_Expect(void)`
|
||||
* `void func(params)` => `void func_Expect(expected_params)`
|
||||
@@ -84,10 +111,30 @@ to day CMock work.
|
||||
* `retval func(params)` => `void func_ExpectAndReturn(expected_params, retval_to_return)`
|
||||
|
||||
|
||||
ExpectAnyArgs:
|
||||
--------------
|
||||
|
||||
This behaves just like the Expects calls, except that it doesn't really
|
||||
care what the arguments are that the mock gets called with. It still counts
|
||||
the number of times the mock is called and it still handles return values
|
||||
if there are some.
|
||||
|
||||
* `void func(void)` => `void func_ExpectAnyArgs(void)`
|
||||
* `void func(params)` => `void func_ExpectAnyArgs(void)`
|
||||
* `retval func(void)` => `void func_ExpectAnyArgsAndReturn(retval_to_return)`
|
||||
* `retval func(params)` => `void func_ExpectAnyArgsAndReturn(retval_to_return)`
|
||||
|
||||
|
||||
Array:
|
||||
------
|
||||
|
||||
An ExpectWithArray will check as many elements as you specify.
|
||||
An ExpectWithArray is another variant of Expect. Like expect, it cares about
|
||||
the number of times a mock is called, the arguments it is called with, and the
|
||||
values it is to return. This variant has another feature, though. For anything
|
||||
that resembles a pointer or array, it breaks the argument into TWO arguments.
|
||||
The first is the original pointer. The second specify the number of elements
|
||||
it is to verify of that array. If you specify 1, it'll check one object. If 2,
|
||||
it'll assume your pointer is pointing at the first of two elements in an array.
|
||||
If you specify zero elements, it will check just the pointer if
|
||||
`:smart` mode is configured or fail if `:compare_data` is set.
|
||||
|
||||
@@ -97,14 +144,59 @@ If you specify zero elements, it will check just the pointer if
|
||||
* `retval func(other, ptr* param)` => `void func_ExpectWithArrayAndReturn(other, ptr* param, int param_depth, retval_to_return)`
|
||||
|
||||
|
||||
Ignore:
|
||||
-------
|
||||
|
||||
Maybe you don't care about the number of times a particular function is called or
|
||||
the actual arguments it is called with. In that case, you want to use Ignore. Ignore
|
||||
only needs to be called once per test. It will then ignore any further calls to that
|
||||
particular mock. The IgnoreAndReturn works similarly, except that it has the added
|
||||
benefit of knowing what to return when that call happens. If the mock is called more
|
||||
times than IgnoreAndReturn was called, it will keep returning the last value without
|
||||
complaint. If it's called less times, it will also ignore that. You SAID you didn't
|
||||
care how many times it was called, right?
|
||||
|
||||
* `void func(void)` => `void func_Ignore(void)`
|
||||
* `void func(params)` => `void func_Ignore(void)`
|
||||
* `retval func(void)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
* `retval func(params)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
|
||||
|
||||
Ignore Arg:
|
||||
------------
|
||||
|
||||
Maybe you overall want to use Expect and its similar variations, but you don't care
|
||||
what is passed to a particular argument. This is particularly useful when that argument
|
||||
is a pointer to a value that is supposed to be filled in by the function. You don't want
|
||||
to use ExpectAnyArgs, because you still care about the other arguments. Instead, before
|
||||
any of your Expect calls are made, you can call this function. It tells CMock to ignore
|
||||
a particular argument for the rest of this test, for this mock function.
|
||||
|
||||
* `void func(params)` => `void func_IgnoreArg_paramName(void)`
|
||||
|
||||
|
||||
ReturnThruPtr:
|
||||
--------------
|
||||
|
||||
Another option which operates on a particular argument of a function is the ReturnThruPtr
|
||||
plugin. For every argument that resembles a pointer or reference, CMock generates an
|
||||
instance of this function. Just as the AndReturn functions support injecting one or more
|
||||
return values into a queue, this function lets you specify one or more return values which
|
||||
are queued up and copied into the space being pointed at each time the mock is called.
|
||||
|
||||
* `void func(param1)` => `void func_ReturnThruPtr_paramName(val_to_return)`
|
||||
* => `void func_ReturnArrayThruPtr_paramName(cal_to_return, len)`
|
||||
* => `void func_ReturnMemThruPtr_paramName(val_to_return, size)`
|
||||
|
||||
|
||||
Callback:
|
||||
---------
|
||||
|
||||
As soon as you stub a callback in a test, it will call the callback
|
||||
whenever the mock is encountered and return the retval returned
|
||||
from the callback (if any) instead of performing the usual expect
|
||||
checks. It can be configured to check the arguments first (like
|
||||
expects) or just jump directly to the callback.
|
||||
If all those other options don't work, and you really need to do something custom, you
|
||||
still have a choice. As soon as you stub a callback in a test, it will call the callback
|
||||
whenever the mock is encountered and return the retval returned from the callback (if any)
|
||||
instead of performing the usual expect checks. It can be configured to check the arguments
|
||||
first (like expects) or just jump directly to the callback.
|
||||
|
||||
* `void func(void)` => `void func_StubWithCallback(CMOCK_func_CALLBACK callback)`
|
||||
where `CMOCK_func_CALLBACK` looks like: `void func(int NumCalls)`
|
||||
@@ -119,10 +211,9 @@ where `CMOCK_func_CALLBACK` looks like: `retval func(params, int NumCalls)`
|
||||
Cexception:
|
||||
-----------
|
||||
|
||||
If you are using Cexception for error handling, you can use this
|
||||
to throw errors from inside mocks. Like Expects, it remembers
|
||||
which call was supposed to throw the error, and it still checks
|
||||
parameters.
|
||||
Finally, if you are using Cexception for error handling, you can use this to throw errors
|
||||
from inside mocks. Like Expects, it remembers which call was supposed to throw the error,
|
||||
and it still checks parameters first.
|
||||
|
||||
* `void func(void)` => `void func_ExpectAndThrow(value_to_throw)`
|
||||
* `void func(params)` => `void func_ExpectAndThrow(expected_params, value_to_throw)`
|
||||
@@ -130,43 +221,6 @@ parameters.
|
||||
* `retval func(params)` => `void func_ExpectAndThrow(expected_params, value_to_throw)`
|
||||
|
||||
|
||||
Ignore:
|
||||
-------
|
||||
|
||||
This plugin supports two modes. You can use it to force CMock to
|
||||
ignore calls to specific functions or to just ignore the arguments
|
||||
passed to those functions. Either way you can specify multiple
|
||||
returns or a single value to always return, whichever you prefer.
|
||||
|
||||
* `void func(void)` => `void func_Ignore(void)`
|
||||
* `void func(params)` => `void func_Ignore(void)`
|
||||
* `retval func(void)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
* `retval func(params)` => `void func_IgnoreAndReturn(retval_to_return)`
|
||||
|
||||
|
||||
Ignore Args:
|
||||
------------
|
||||
|
||||
This plugin adds the ability to specify specifc arguments to ignore
|
||||
for a function, instead of ignoring all the arguments or the entire
|
||||
function call, as the Ignore plugin supports. This will create a function
|
||||
for each argument and each function.
|
||||
|
||||
* `void func(params)` => `void func_IgnoreArg_paramName(void)`
|
||||
|
||||
|
||||
ReturnThruPtr:
|
||||
--------------
|
||||
|
||||
This plugin adds a number of options for returning data through arguments
|
||||
that are pointers. This is fled separately from the Expect/Ignore call, so
|
||||
you will want to issue one of those calls each time as well. This will only
|
||||
create an extra call for arguments that are pointers. It will create one per
|
||||
pointer argument.
|
||||
|
||||
* `void func(param1)` => `void func_ReturnThruPtr_paramName(val_to_return)`
|
||||
* => `void func_ReturnArrayThruPtr_paramName(cal_to_return, len)`
|
||||
* => `void func_ReturnMemThruPtr_paramName(val_to_return, size)`
|
||||
|
||||
Running CMock
|
||||
=============
|
||||
@@ -174,10 +228,11 @@ Running CMock
|
||||
CMock is a Ruby script and class. You can therefore use it directly
|
||||
from the command line, or include it in your own scripts or rakefiles.
|
||||
|
||||
|
||||
Mocking from the Command Line
|
||||
-----------------------------
|
||||
|
||||
After unpacking CMock, you will find CMock.rb in the 'lib' directory.
|
||||
After unpacking CMock, you will find cmock.rb in the 'lib' directory.
|
||||
This is the file that you want to run. It takes a list of header files
|
||||
to be mocked, as well as an optional yaml file for a more detailed
|
||||
configuration (see config options below).
|
||||
@@ -191,6 +246,7 @@ And this will create two mocks using the default configuration:
|
||||
|
||||
ruby cmock.rb ../mocking/stuff/is/fun.h ../try/it/yourself.h
|
||||
|
||||
|
||||
Mocking From Scripts or Rake
|
||||
----------------------------
|
||||
|
||||
@@ -201,6 +257,7 @@ three ways.
|
||||
|
||||
You may specify nothing, allowing it to run with default settings:
|
||||
|
||||
require 'cmock.rb'
|
||||
cmock = CMock.new
|
||||
|
||||
You may specify a YAML file containing the configuration options
|
||||
@@ -212,7 +269,9 @@ You may specify the options explicitly:
|
||||
|
||||
cmock = Cmock.new(:plugins => [:cexception, :ignore], :mock_path => 'my/mocks/')
|
||||
|
||||
|
||||
Config Options:
|
||||
---------------
|
||||
|
||||
The following configuration options can be specified in the
|
||||
yaml file or directly when instantiating.
|
||||
@@ -229,16 +288,35 @@ Defined in the yaml file, they look more like this:
|
||||
- __intrinsic
|
||||
:when_ptr: :compare
|
||||
|
||||
In all cases, you can just include the things that you want to override
|
||||
from the defaults. We've tried to specify what the defaults are below.
|
||||
|
||||
* `:attributes`:
|
||||
These are attributes that CMock should ignore for you for testing
|
||||
purposes. Custom compiler extensions and externs are handy things to
|
||||
put here.
|
||||
put here. If your compiler is choking on some extended syntax, this
|
||||
is often a good place to look.
|
||||
|
||||
* defaults: ['__ramfunc', '__irq', '__fiq', 'register', 'extern']
|
||||
* **note:** this option will reinsert these attributes onto the mock's calls.
|
||||
If that isn't what you are looking for, check out :strippables.
|
||||
|
||||
* `:c_calling_conventions`:
|
||||
Similarly, CMock may need to understand which C calling conventions
|
||||
might show up in your codebase. If it encounters something it doesn't
|
||||
recognize, it's not going to mock it. We have the most common covered,
|
||||
but there are many compilers out there, and therefore many other options.
|
||||
|
||||
* defaults: ['__stdcall', '__cdecl', '__fastcall']
|
||||
* **note:** this option will reinsert these attributes onto the mock's calls.
|
||||
If that isn't what you are looking for, check out :strippables.
|
||||
|
||||
* `:callback_after_arg_check`:
|
||||
Tell `:callback` plugin to do the normal argument checking before it
|
||||
calls the callback function. This defaults to false, where the
|
||||
callback function is called instead of the argument verification.
|
||||
Tell `:callback` plugin to do the normal argument checking **before** it
|
||||
calls the callback function by setting this to true. When false, the
|
||||
callback function is called **instead** of the argument verification.
|
||||
|
||||
* default: false
|
||||
|
||||
* `:callback_include_count`:
|
||||
Tell `:callback` plugin to include an extra parameter to specify the
|
||||
@@ -246,64 +324,105 @@ Defined in the yaml file, they look more like this:
|
||||
callback has the same interface as the mocked function. This can be
|
||||
handy when you're wanting to use callback as a stub.
|
||||
|
||||
* default: true
|
||||
|
||||
* `:cexception_include`:
|
||||
Tell `:cexception` plugin where to find CException.h... only need to
|
||||
define if it's not in your build path already.
|
||||
Tell `:cexception` plugin where to find CException.h... You only need to
|
||||
define this if it's not in your build path already... which it usually
|
||||
will be for the purpose of your builds.
|
||||
|
||||
* default: *nil*
|
||||
|
||||
* `:enforce_strict_ordering`:
|
||||
CMock always enforces the order that you call a particular function,
|
||||
so if you expect GrabNabber(int size) to be called three times, it
|
||||
will verify that the sizes are in the order you specified. You might
|
||||
also want to make sure that all different functions are called in a
|
||||
*also* want to make sure that all different functions are called in a
|
||||
particular order. If so, set this to true.
|
||||
|
||||
* default: false
|
||||
|
||||
* `:framework`:
|
||||
Currently the only option is `:unity.` Eventually if we support other
|
||||
unity test frameworks (or if you write one for us), they'll get added
|
||||
here.
|
||||
|
||||
: default: :unity
|
||||
|
||||
* `:includes`:
|
||||
An array of additional include files which should be added to the
|
||||
mocks. Useful for global types and definitions used in your project.
|
||||
There are more specific versions if you care WHERE in the mock files
|
||||
the includes get placed. You can define any or all of
|
||||
`:includes_h_pre_orig_header,` `:includes_h_post_orig_header, `
|
||||
`:includes_c_pre_header,` `:includes_c_post_header
|
||||
the includes get placed. You can define any or all of these options.
|
||||
|
||||
* `:includes`
|
||||
* `:includes_h_pre_orig_header`
|
||||
* `:includes_h_post_orig_header`
|
||||
* `:includes_c_pre_header`
|
||||
* `:includes_c_post_header`
|
||||
* default: nil #for all 5 options
|
||||
|
||||
* `:memcmp_if_unknown`:
|
||||
This is true by default. When true, CMock will just do a memory
|
||||
comparison of types that it doesn't recognize (not standard types, not
|
||||
in `:treat_as,` and not in a unity helper). If you instead want it to
|
||||
throw an error, just set this to false.
|
||||
C developers create a lot of types, either through typedef or preprocessor
|
||||
macros. CMock isn't going to automatically know what you were thinking all
|
||||
the time (though it tries its best). If it comes across a type it doesn't
|
||||
recognize, you have a choice on how you want it to handle it. It can either
|
||||
perform a raw memory comparison and report any differences, or it can fail
|
||||
with a meaningful message. Either way, this feature will only happen after
|
||||
all other mechanisms have failed (The thing encountered isn't a standard
|
||||
type. It isn't in the :treat_as list. It isn't in a custom unity_helper).
|
||||
|
||||
* default: true
|
||||
|
||||
* `:mock_path`:
|
||||
The directory where you would like the mock files generated to be
|
||||
placed.
|
||||
|
||||
* default: mocks
|
||||
|
||||
* `:mock_prefix`:
|
||||
The prefix to append to your mock files. Defaults to “Mock”, so a file
|
||||
“USART.h” will get a mock called “MockUSART.c”
|
||||
The prefix to prepend to your mock files. For example, if it's “Mock”, a file
|
||||
“USART.h” will get a mock called “MockUSART.c”. This CAN be used with a suffix
|
||||
at the same time.
|
||||
|
||||
* default: Mock
|
||||
|
||||
* `:mock_suffix`:
|
||||
The suffix to append to your mock files. Defaults to “”.
|
||||
The suffix to append to your mock files. For example, it it's "_Mock", a file
|
||||
"USART.h" will get a mock called "USART_Mock.h". This CAN be used with a prefix
|
||||
at the same time.
|
||||
|
||||
* `:weak`:
|
||||
When set to some value, the generated mocks are defined as weak symbols using the configured format. Defaults to ''.
|
||||
Set to '__attribute ((weak))' for weak mocks when using GCC. Set to any non-empty string for weak mocks when using IAR.
|
||||
|
||||
* `:subdir`:
|
||||
Relative subdir for your mocks. Set this to e.g. "sys" in order to
|
||||
create mock for `sys/types.h` in `:mock_path`/sys/
|
||||
* default: ""
|
||||
|
||||
* `:plugins`:
|
||||
An array of which plugins to enable. 'expect' is always active. Also
|
||||
available currently are `:ignore,` `:ignore_arg,` `:array,`
|
||||
`:cexception,` `:callback,` and `:return_thru_ptr`
|
||||
An array of which plugins to enable. ':expect' is always active. Also
|
||||
available currently:
|
||||
|
||||
* `:ignore`
|
||||
* `:ignore_arg`
|
||||
* `:expect_any_args`
|
||||
* `:array`
|
||||
* `:cexception`
|
||||
* `:callback`
|
||||
* `:return_thru_ptr`
|
||||
|
||||
* `:strippables`:
|
||||
An array containing a list of items to remove from the mocked header.
|
||||
For example, use `:strippables: ['(?:functionName\s*\(+.*?\)+)']`
|
||||
to prevent a function from being mocked.
|
||||
An array containing a list of items to remove from the header
|
||||
before deciding what should be mocked. This can be something simple
|
||||
like a compiler extension CMock wouldn't recognize, or could be a
|
||||
regex to reject certain function name patterns. This is a great way to
|
||||
get rid of compiler extensions when your test compiler doesn't support
|
||||
them. For example, use `:strippables: ['(?:functionName\s*\(+.*?\)+)']`
|
||||
to prevent a function `functionName` from being mocked. By default, it
|
||||
is ignoring all gcc attribute extensions.
|
||||
|
||||
* default: ['(?:__attribute__\s*\(+.*?\)+)']
|
||||
|
||||
* `:subdir`:
|
||||
This is a relative subdirectory for your mocks. Set this to e.g. "sys" in
|
||||
order to create a mock for `sys/types.h` in `(:mock_path)/sys/`.
|
||||
|
||||
* default: ""
|
||||
|
||||
* `:treat_as`:
|
||||
The `:treat_as` list is a shortcut for when you have created typedefs
|
||||
@@ -314,35 +433,104 @@ Defined in the yaml file, they look more like this:
|
||||
array of unsigned characters? No problem, just add 'UINT8_T*' =>
|
||||
'HEX8*'
|
||||
|
||||
* NOTE: unlike the other options, your specifications MERGE with the
|
||||
default list. Therefore, if you want to override something, you must
|
||||
reassign it to something else (or to *nil* if you don't want it)
|
||||
|
||||
* default:
|
||||
* 'int': 'INT'
|
||||
* 'char': 'INT8'
|
||||
* 'short': 'INT16'
|
||||
* 'long': 'INT'
|
||||
* 'int8': 'INT8'
|
||||
* 'int16': 'INT16'
|
||||
* 'int32': 'INT'
|
||||
* 'int8_t': 'INT8'
|
||||
* 'int16_t': 'INT16'
|
||||
* 'int32_t': 'INT'
|
||||
* 'INT8_T': 'INT8'
|
||||
* 'INT16_T': 'INT16'
|
||||
* 'INT32_T': 'INT'
|
||||
* 'bool': 'INT'
|
||||
* 'bool_t': 'INT'
|
||||
* 'BOOL': 'INT'
|
||||
* 'BOOL_T': 'INT'
|
||||
* 'unsigned int': 'HEX32'
|
||||
* 'unsigned long': 'HEX32'
|
||||
* 'uint32': 'HEX32'
|
||||
* 'uint32_t': 'HEX32'
|
||||
* 'UINT32': 'HEX32'
|
||||
* 'UINT32_T': 'HEX32'
|
||||
* 'void*': 'HEX8_ARRAY'
|
||||
* 'unsigned short': 'HEX16'
|
||||
* 'uint16': 'HEX16'
|
||||
* 'uint16_t': 'HEX16'
|
||||
* 'UINT16': 'HEX16'
|
||||
* 'UINT16_T': 'HEX16'
|
||||
* 'unsigned char': 'HEX8'
|
||||
* 'uint8': 'HEX8'
|
||||
* 'uint8_t': 'HEX8'
|
||||
* 'UINT8': 'HEX8'
|
||||
* 'UINT8_T': 'HEX8'
|
||||
* 'char*': 'STRING'
|
||||
* 'pCHAR': 'STRING'
|
||||
* 'cstring': 'STRING'
|
||||
* 'CSTRING': 'STRING'
|
||||
* 'float': 'FLOAT'
|
||||
* 'double': 'FLOAT'
|
||||
|
||||
* `:treat_as_void`:
|
||||
We've seen "fun" legacy systems typedef 'void' with a custom type,
|
||||
like MY_VOID. Add any instances of those to this list to help CMock
|
||||
understand how to deal with your code.
|
||||
|
||||
* default: []
|
||||
|
||||
* `:treat_externs`:
|
||||
Set to `:include` to mock externed functions or `:exclude` to ignore
|
||||
them (the default).
|
||||
This specifies how you want CMock to handle functions that have been
|
||||
marked as extern in the header file. Should it mock them?
|
||||
|
||||
* `:include` will mock externed functions
|
||||
* `:exclude` will ignore externed functions (default).
|
||||
|
||||
* `:unity_helper_path`:
|
||||
If you have created a header with your own extensions to unity to
|
||||
handle your own types, you can set this argument to that path. CMock
|
||||
will then automagically pull in your helpers and use them. The only
|
||||
trick is that you make sure you follow the naming convention:
|
||||
UNITY_TEST_ASSERT_EQUAL_YourType
|
||||
`UNITY_TEST_ASSERT_EQUAL_YourType`. If it finds macros of the right
|
||||
shape that match that pattern, it'll use them.
|
||||
|
||||
* default: []
|
||||
|
||||
* `:verbosity`:
|
||||
0 for errors only. 1 for errors and warnings. 2 for normal. 3 for
|
||||
verbose
|
||||
How loud should CMock be?
|
||||
|
||||
* 0 for errors only
|
||||
* 1 for errors and warnings
|
||||
* 2 for normal (default)
|
||||
* 3 for verbose
|
||||
|
||||
* `:weak`:
|
||||
When set this to some value, the generated mocks are defined as weak
|
||||
symbols using the configured format. This allows them to be overridden
|
||||
in particular tests.
|
||||
|
||||
* Set to '__attribute ((weak))' for weak mocks when using GCC.
|
||||
* Set to any non-empty string for weak mocks when using IAR.
|
||||
* default: ""
|
||||
|
||||
* `:when_no_prototypes`:
|
||||
When you give CMock a header file and ask it to create a mock out of
|
||||
it, it usually contains function prototypes (otherwise what was the
|
||||
point?). You can control what happens when this isn't true. You can
|
||||
set this to `:warn,` `:ignore,` or `:error
|
||||
set this to `:warn,` `:ignore,` or `:error`
|
||||
|
||||
* default: :warn
|
||||
|
||||
* `:when_ptr`:
|
||||
You can customize how CMock deals with pointers (c strings result in
|
||||
string comparisons... we're talking about other pointers here). Your
|
||||
string comparisons... we're talking about **other** pointers here). Your
|
||||
options are `:compare_ptr` to just verify the pointers are the same,
|
||||
`:compare_data` or `:smart` to verify that the data is the same.
|
||||
`:compare_data` and `:smart` behaviors will change slightly based on
|
||||
@@ -351,41 +539,65 @@ Defined in the yaml file, they look more like this:
|
||||
to a struct called ORGAN_T, it will compare one ORGAN_T (whatever that
|
||||
is).
|
||||
|
||||
* default: :smart
|
||||
|
||||
* `:fail_on_unexpected_calls`:
|
||||
By default, CMock will fail a test if a mock is called without _Expect and _Ignore
|
||||
called first. While this forces test writers to be more explicit in their expectations,
|
||||
it can clutter tests with _Expect or _Ignore calls for functions which are not the focus
|
||||
of the test. While this is a good indicator that this module should be refactored, some
|
||||
users are not fans of the additional noise.
|
||||
|
||||
Therefore, :fail_on_unexpected_calls can be set to false to force all mocks to start with
|
||||
the assumption that they are operating as _Ignore unless otherwise specified.
|
||||
|
||||
* default: true
|
||||
* **note:**
|
||||
If this option is disabled, the mocked functions will return
|
||||
a default value (0) when called (and only if they have to return something of course).
|
||||
|
||||
|
||||
Compiled Options:
|
||||
-----------------
|
||||
|
||||
A number of #defines also exist for customizing the cmock experience.
|
||||
Feel free to pass these into your compiler or whatever is most
|
||||
convenient. CMock will otherwise do its best to guess what you want
|
||||
based on other settings, particularly Unity's settings.
|
||||
|
||||
CMOCK_MEM_STATIC or CMOCK_MEM_DYNAMIC
|
||||
* `CMOCK_MEM_STATIC` or `CMOCK_MEM_DYNAMIC`
|
||||
Define one of these to determine if you want to dynamically add
|
||||
memory during tests as required from the heap. If static, you
|
||||
can control the total footprint of Cmock. If dynamic, you will
|
||||
need to make sure you make some heap space available for Cmock.
|
||||
|
||||
Define one of these to determine if you want to dynamically add
|
||||
memory during tests as required from the heap. If static, you
|
||||
can control the total footprint of Cmock. If dynamic, you will
|
||||
need to make sure you make some heap space available for Cmock.
|
||||
* `CMOCK_MEM_SIZE`
|
||||
In static mode this is the total amount of memory you are allocating
|
||||
to Cmock. In Dynamic mode this is the size of each chunk allocated
|
||||
at once (larger numbers grab more memory but require less mallocs).
|
||||
|
||||
CMOCK_MEM_SIZE
|
||||
* `CMOCK_MEM_ALIGN`
|
||||
The way to align your data to. Not everything is as flexible as
|
||||
a PC, as most embedded designers know. This defaults to 2, meaning
|
||||
align to the closest 2^2 -> 4 bytes (32 bits). You can turn off alignment
|
||||
by setting 0, force alignment to the closest uint16 with 1 or even
|
||||
to the closest uint64 with 3.
|
||||
|
||||
In static mode this is the total amount of memory you are allocating
|
||||
to Cmock. In Dynamic mode this is the size of each chunk allocated
|
||||
at once (larger numbers grab more memory but require less mallocs).
|
||||
* `CMOCK_MEM_PTR_AS_INT`
|
||||
This is used internally to hold pointers... it needs to be big
|
||||
enough. On most processors a pointer is the same as an unsigned
|
||||
long... but maybe that's not true for yours?
|
||||
|
||||
CMOCK_MEM_ALIGN
|
||||
* `CMOCK_MEM_INDEX_TYPE`
|
||||
This needs to be something big enough to point anywhere in Cmock's
|
||||
memory space... usually it's an unsigned int.
|
||||
|
||||
The way to align your data to. Not everything is as flexible as
|
||||
a PC, as most embedded designers know. This defaults to 2, meaning
|
||||
align to the closest 2^2 -> 4 bytes (32 bits). You can turn off alignment
|
||||
by setting 0, force alignment to the closest uint16 with 1 or even
|
||||
to the closest uint64 with 3.
|
||||
Examples
|
||||
========
|
||||
|
||||
CMOCK_MEM_PTR_AS_INT
|
||||
|
||||
This is used internally to hold pointers... it needs to be big
|
||||
enough. On most processors a pointer is the same as an unsigned
|
||||
long... but maybe that's not true for yours?
|
||||
|
||||
CMOCK_MEM_INDEX_TYPE
|
||||
|
||||
This needs to be something big enough to point anywhere in Cmock's
|
||||
memory space... usually it's an unsigned int.
|
||||
You can look in the [examples directory](/examples/) for a couple of examples on how
|
||||
you might tool CMock into your build process. You may also want to consider
|
||||
using [Ceedling](https://throwtheswitch.org/Ceedling). Please note that
|
||||
these examples are meant to show how the build process works. They have
|
||||
failing tests ON PURPOSE to show what that would look like. Don't be alarmed. ;)
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
# ThrowTheSwitch.org Coding Standard
|
||||
|
||||
Hi. Welcome to the coding standard for ThrowTheSwitch.org. For the most part,
|
||||
we try to follow these standards to unify our contributors' code into a cohesive
|
||||
unit (puns intended). You might find places where these standards aren't
|
||||
followed. We're not perfect. Please be polite where you notice these discrepancies
|
||||
and we'll try to be polite when we notice yours.
|
||||
|
||||
;)
|
||||
|
||||
|
||||
## Why Have A Coding Standard?
|
||||
|
||||
Being consistent makes code easier to understand. We've made an attempt to keep
|
||||
our standard simple because we also believe that we can only expect someone to
|
||||
follow something that is understandable. Please do your best.
|
||||
|
||||
|
||||
## Our Philosophy
|
||||
|
||||
Before we get into details on syntax, let's take a moment to talk about our
|
||||
vision for these tools. We're C developers and embedded software developers.
|
||||
These tools are great to test any C code, but catering to embedded software has
|
||||
made us more tolerant of compiler quirks. There are a LOT of quirky compilers
|
||||
out there. By quirky I mean "doesn't follow standards because they feel like
|
||||
they have a license to do as they wish."
|
||||
|
||||
Our philosophy is "support every compiler we can". Most often, this means that
|
||||
we aim for writing C code that is standards compliant (often C89... that seems
|
||||
to be a sweet spot that is almost always compatible). But it also means these
|
||||
tools are tolerant of things that aren't common. Some that aren't even
|
||||
compliant. There are configuration options to override the size of standard
|
||||
types. There are configuration options to force Unity to not use certain
|
||||
standard library functions. A lot of Unity is configurable and we have worked
|
||||
hard to make it not TOO ugly in the process.
|
||||
|
||||
Similarly, our tools that parse C do their best. They aren't full C parsers
|
||||
(yet) and, even if they were, they would still have to accept non-standard
|
||||
additions like gcc extensions or specifying `@0x1000` to force a variable to
|
||||
compile to a particular location. It's just what we do, because we like
|
||||
everything to Just Work™.
|
||||
|
||||
Speaking of having things Just Work™, that's our second philosophy. By that, we
|
||||
mean that we do our best to have EVERY configuration option have a logical
|
||||
default. We believe that if you're working with a simple compiler and target,
|
||||
you shouldn't need to configure very much... we try to make the tools guess as
|
||||
much as they can, but give the user the power to override it when it's wrong.
|
||||
|
||||
|
||||
## Naming Things
|
||||
|
||||
Let's talk about naming things. Programming is all about naming things. We name
|
||||
files, functions, variables, and so much more. While we're not always going to
|
||||
find the best name for something, we actually put quite a bit of effort into
|
||||
finding *What Something WANTS to be Called*™.
|
||||
|
||||
When naming things, we more or less follow this hierarchy, the first being the
|
||||
most important to us (but we do all four whenever possible):
|
||||
1. Readable
|
||||
2. Descriptive
|
||||
3. Consistent
|
||||
4. Memorable
|
||||
|
||||
|
||||
#### Readable
|
||||
|
||||
We want to read our code. This means we like names and flow that are more
|
||||
naturally read. We try to avoid double negatives. We try to avoid cryptic
|
||||
abbreviations (sticking to ones we feel are common).
|
||||
|
||||
|
||||
#### Descriptive
|
||||
|
||||
We like descriptive names for things, especially functions and variables.
|
||||
Finding the right name for something is an important endeavor. You might notice
|
||||
from poking around our code that this often results in names that are a little
|
||||
longer than the average. Guilty. We're okay with a tiny bit more typing if it
|
||||
means our code is easier to understand.
|
||||
|
||||
There are two exceptions to this rule that we also stick to as religiously as
|
||||
possible:
|
||||
|
||||
First, while we realize hungarian notation (and similar systems for encoding
|
||||
type information into variable names) is providing a more descriptive name, we
|
||||
feel that (for the average developer) it takes away from readability and
|
||||
therefore is to be avoided.
|
||||
|
||||
Second, loop counters and other local throw-away variables often have a purpose
|
||||
which is obvious. There's no need, therefore, to get carried away with complex
|
||||
naming. We find i, j, and k are better loop counters than loopCounterVar or
|
||||
whatnot. We only break this rule when we see that more description could improve
|
||||
understanding of an algorithm.
|
||||
|
||||
|
||||
#### Consistent
|
||||
|
||||
We like consistency, but we're not really obsessed with it. We try to name our
|
||||
configuration macros in a consistent fashion... you'll notice a repeated use of
|
||||
UNITY_EXCLUDE_BLAH or UNITY_USES_BLAH macros. This helps users avoid having to
|
||||
remember each macro's details.
|
||||
|
||||
|
||||
#### Memorable
|
||||
|
||||
Where ever it doesn't violate the above principles, we try to apply memorable
|
||||
names. Sometimes this means using something that is simply descriptive, but
|
||||
often we strive for descriptive AND unique... we like quirky names that stand
|
||||
out in our memory and are easier to search for. Take a look through the file
|
||||
names in Ceedling and you'll get a good idea of what we are talking about here.
|
||||
Why use preprocess when you can use preprocessinator? Or what better describes a
|
||||
module in charge of invoking tasks during releases than release_invoker? Don't
|
||||
get carried away. The names are still descriptive and fulfill the above
|
||||
requirements, but they don't feel stale.
|
||||
|
||||
|
||||
## C and C++ Details
|
||||
|
||||
We don't really want to add to the style battles out there. Tabs or spaces?
|
||||
How many spaces? Where do the braces go? These are age-old questions that will
|
||||
never be answered... or at least not answered in a way that will make everyone
|
||||
happy.
|
||||
|
||||
We've decided on our own style preferences. If you'd like to contribute to these
|
||||
projects (and we hope that you do), then we ask if you do your best to follow
|
||||
the same. It will only hurt a little. We promise.
|
||||
|
||||
|
||||
#### Whitespace
|
||||
|
||||
Our C-style is to use spaces and to use 4 of them per indent level. It's a nice
|
||||
power-of-2 number that looks decent on a wide screen. We have no more reason
|
||||
than that. We break that rule when we have lines that wrap (macros or function
|
||||
arguments or whatnot). When that happens, we like to indent further to line
|
||||
things up in nice tidy columns.
|
||||
|
||||
```C
|
||||
if (stuff_happened)
|
||||
{
|
||||
do_something();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Case
|
||||
|
||||
- Files - all lower case with underscores.
|
||||
- Variables - all lower case with underscores
|
||||
- Macros - all caps with underscores.
|
||||
- Typedefs - all caps with underscores. (also ends with _T).
|
||||
- Functions - camel cased. Usually named ModuleName_FuncName
|
||||
- Constants and Globals - camel cased.
|
||||
|
||||
|
||||
#### Braces
|
||||
|
||||
The left brace is on the next line after the declaration. The right brace is
|
||||
directly below that. Everything in between in indented one level. If you're
|
||||
catching an error and you have a one-line, go ahead and to it on the same line.
|
||||
|
||||
```C
|
||||
while (blah)
|
||||
{
|
||||
//Like so. Even if only one line, we use braces.
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Comments
|
||||
|
||||
Do you know what we hate? Old-school C block comments. BUT, we're using them
|
||||
anyway. As we mentioned, our goal is to support every compiler we can,
|
||||
especially embedded compilers. There are STILL C compilers out there that only
|
||||
support old-school block comments. So that is what we're using. We apologize. We
|
||||
think they are ugly too.
|
||||
|
||||
|
||||
## Ruby Details
|
||||
|
||||
Is there really such thing as a Ruby coding standard? Ruby is such a free form
|
||||
language, it seems almost sacrilegious to suggest that people should comply to
|
||||
one method! We'll keep it really brief!
|
||||
|
||||
|
||||
#### Whitespace
|
||||
|
||||
Our Ruby style is to use spaces and to use 2 of them per indent level. It's a
|
||||
nice power-of-2 number that really grooves with Ruby's compact style. We have no
|
||||
more reason than that. We break that rule when we have lines that wrap. When
|
||||
that happens, we like to indent further to line things up in nice tidy columns.
|
||||
|
||||
|
||||
#### Case
|
||||
|
||||
- Files - all lower case with underscores.
|
||||
- Variables - all lower case with underscores
|
||||
- Classes, Modules, etc - Camel cased.
|
||||
- Functions - all lower case with underscores
|
||||
- Constants - all upper case with underscores
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
Egad. Really? We use markdown and we like pdf files because they can be made to
|
||||
look nice while still being portable. Good enough?
|
||||
|
||||
|
||||
*Find The Latest of This And More at [ThrowTheSwitch.org](https://throwtheswitch.org)*
|
||||
@@ -14,7 +14,7 @@ all: setup test ${BUILD_DIR}/main run
|
||||
setup:
|
||||
mkdir -p ${BUILD_DIR}
|
||||
mkdir -p ${OBJ}
|
||||
ruby ../../scripts/create_makefile.rb
|
||||
ruby ../../scripts/create_makefile.rb --silent
|
||||
|
||||
clean:
|
||||
rm -rf ${BUILD_DIR}
|
||||
@@ -23,7 +23,7 @@ ${BUILD_DIR}/main: ${SRC_DIR}/main.c ${SRC_DIR}/foo.c
|
||||
${CC} $< -o $@
|
||||
|
||||
run:
|
||||
./build/main
|
||||
./build/main || true
|
||||
|
||||
test: setup
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ compiler:
|
||||
prefix: '-I'
|
||||
items:
|
||||
- 'src/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/unity/examples/example_3/helper/'
|
||||
- 'mocks/'
|
||||
- '../../src/'
|
||||
- '../../vendor/unity/src/'
|
||||
- '../../vendor/unity/examples/example_3/helper/'
|
||||
- './build/mocks/'
|
||||
- *unit_tests_path
|
||||
defines:
|
||||
prefix: '-D'
|
||||
@@ -39,5 +39,6 @@ linker:
|
||||
:plugins: []
|
||||
:includes:
|
||||
- Types.h
|
||||
:mock_path: ./build/mocks
|
||||
|
||||
colour: true
|
||||
|
||||
@@ -30,10 +30,10 @@ compiler:
|
||||
prefix: '-I'
|
||||
items:
|
||||
- 'src/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/unity/examples/example_3/helper/'
|
||||
- 'mocks/'
|
||||
- '../../src/'
|
||||
- '../../vendor/unity/src/'
|
||||
- '../../vendor/unity/examples/example_3/helper/'
|
||||
- './build/mocks/'
|
||||
- [*tools_root, 'arm\inc\']
|
||||
- *unit_tests_path
|
||||
defines:
|
||||
@@ -88,4 +88,5 @@ simulator:
|
||||
:plugins: []
|
||||
:includes:
|
||||
- Types.h
|
||||
:mock_path: ./build/mocks
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ compiler:
|
||||
prefix: '-I'
|
||||
items:
|
||||
- 'src/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/unity/examples/example_3/helper/'
|
||||
- 'mocks/'
|
||||
- '../../src/'
|
||||
- '../../vendor/unity/src/'
|
||||
- '../../vendor/unity/examples/example_3/helper/'
|
||||
- './build/mocks/'
|
||||
- [*tools_root, 'arm\inc\']
|
||||
- *unit_tests_path
|
||||
defines:
|
||||
@@ -77,4 +77,5 @@ simulator:
|
||||
:plugins: []
|
||||
:includes:
|
||||
- Types.h
|
||||
:mock_path: ./build/mocks
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@ require './rakefile_helper'
|
||||
|
||||
include RakefileHelpers
|
||||
|
||||
REQUIRED_DIRS = [ './build', './build/mocks' ]
|
||||
REQUIRED_DIRS.each do |v|
|
||||
directory v
|
||||
end
|
||||
|
||||
# Load default configuration, for now
|
||||
DEFAULT_CONFIG_FILE = 'gcc.yml'
|
||||
configure_toolchain(DEFAULT_CONFIG_FILE)
|
||||
@@ -22,7 +27,7 @@ end
|
||||
|
||||
desc "Build and test Unity"
|
||||
task :all => [:clean, :unit, :summary]
|
||||
task :default => [:clobber, :all]
|
||||
task :default => REQUIRED_DIRS + [:clobber, :all]
|
||||
task :ci => [:default]
|
||||
task :cruise => [:default]
|
||||
|
||||
@@ -30,3 +35,8 @@ desc "Load configuration"
|
||||
task :config, :config_file do |t, args|
|
||||
configure_toolchain(args[:config_file])
|
||||
end
|
||||
|
||||
desc "Return error on Failures"
|
||||
task :strict do
|
||||
$return_error_on_failures = true
|
||||
end
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
require '../vendor/unity/auto/unity_test_summary'
|
||||
require '../vendor/unity/auto/generate_test_runner'
|
||||
require '../vendor/unity/auto/colour_reporter'
|
||||
require '../../vendor/unity/auto/unity_test_summary'
|
||||
require '../../vendor/unity/auto/generate_test_runner'
|
||||
require '../../vendor/unity/auto/colour_reporter'
|
||||
|
||||
module RakefileHelpers
|
||||
|
||||
$return_error_on_failures = false
|
||||
|
||||
C_EXTENSION = '.c'
|
||||
|
||||
def load_configuration(config_file)
|
||||
@@ -145,11 +147,11 @@ module RakefileHelpers
|
||||
return {:command => command, :pre_support => pre_support, :post_support => post_support}
|
||||
end
|
||||
|
||||
def execute(command_string, verbose=true)
|
||||
def execute(command_string, verbose=true, ok_to_fail=false)
|
||||
report command_string
|
||||
output = `#{command_string}`.chomp
|
||||
report(output) if (verbose && !output.nil? && (output.length > 0))
|
||||
if $?.exitstatus != 0
|
||||
unless $?.exitstatus.zero? || ok_to_fail
|
||||
raise "Command failed. (Returned #{$?.exitstatus})"
|
||||
end
|
||||
return output
|
||||
@@ -157,13 +159,13 @@ module RakefileHelpers
|
||||
|
||||
def report_summary
|
||||
summary = UnityTestSummary.new
|
||||
summary.set_root_path(HERE)
|
||||
summary.root = HERE
|
||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||
results_glob.gsub!(/\\/, '/')
|
||||
results = Dir[results_glob]
|
||||
summary.set_targets(results)
|
||||
summary.targets = results
|
||||
report summary.run
|
||||
raise "There were failures" if (summary.failures > 0)
|
||||
raise "There were failures" if (summary.failures > 0) && $return_error_on_failures
|
||||
end
|
||||
|
||||
def run_tests(test_files)
|
||||
@@ -188,7 +190,7 @@ module RakefileHelpers
|
||||
|
||||
#create mocks if needed
|
||||
if (header =~ /Mock/)
|
||||
require "../lib/cmock.rb"
|
||||
require "../../lib/cmock.rb"
|
||||
@cmock ||= CMock.new($cfg_file)
|
||||
@cmock.setup_mocks([$cfg['compiler']['source_path']+header.gsub('Mock','')])
|
||||
end
|
||||
@@ -231,7 +233,7 @@ module RakefileHelpers
|
||||
else
|
||||
cmd_str = "#{simulator[:command]} #{simulator[:pre_support]} #{executable} #{simulator[:post_support]}"
|
||||
end
|
||||
output = execute(cmd_str)
|
||||
output = execute(cmd_str, true, true)
|
||||
test_results = $cfg['compiler']['build_path'] + test_base
|
||||
if output.match(/OK$/m).nil?
|
||||
test_results += '.testfail'
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
"cmock_generator_utils",
|
||||
"cmock_unityhelper_parser"].each {|req| require "#{File.expand_path(File.dirname(__FILE__))}/#{req}"}
|
||||
|
||||
|
||||
$QUICK_RUBY_VERSION = RUBY_VERSION.split('.').inject(0){|vv,v| vv * 100 + v.to_i }
|
||||
|
||||
class CMock
|
||||
|
||||
def initialize(options=nil)
|
||||
|
||||
@@ -19,6 +19,7 @@ class CMockConfig
|
||||
:attributes => ['__ramfunc', '__irq', '__fiq', 'register', 'extern'],
|
||||
:c_calling_conventions => ['__stdcall', '__cdecl', '__fastcall'],
|
||||
:enforce_strict_ordering => false,
|
||||
:fail_on_unexpected_calls => true,
|
||||
:unity_helper_path => false,
|
||||
:treat_as => {},
|
||||
:treat_as_void => [],
|
||||
|
||||
+15
-2
@@ -18,6 +18,7 @@ class CMockGenerator
|
||||
@weak = @config.weak
|
||||
@ordered = @config.enforce_strict_ordering
|
||||
@framework = @config.framework.to_s
|
||||
@fail_on_unexpected_calls = @config.fail_on_unexpected_calls
|
||||
|
||||
@subdir = @config.subdir
|
||||
|
||||
@@ -102,6 +103,7 @@ class CMockGenerator
|
||||
file << "\n"
|
||||
file << "/* Ignore the following warnings, since we are copying code */\n"
|
||||
file << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
|
||||
file << "#pragma GCC diagnostic push\n"
|
||||
file << "#if !defined(__clang__)\n"
|
||||
file << "#pragma GCC diagnostic ignored \"-Wpragmas\"\n"
|
||||
file << "#endif\n"
|
||||
@@ -124,7 +126,12 @@ class CMockGenerator
|
||||
end
|
||||
|
||||
def create_mock_header_footer(header)
|
||||
header << "\n#endif\n"
|
||||
header << "\n"
|
||||
header << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
|
||||
header << "#pragma GCC diagnostic pop\n"
|
||||
header << "#endif\n"
|
||||
header << "\n"
|
||||
header << "#endif\n"
|
||||
end
|
||||
|
||||
def create_source_header_section(file, filename, functions)
|
||||
@@ -196,6 +203,11 @@ class CMockGenerator
|
||||
file << " CMock_Guts_MemFreeAll();\n"
|
||||
file << " memset(&Mock, 0, sizeof(Mock));\n"
|
||||
file << functions.collect {|function| @plugins.run(:mock_destroy, function)}.join
|
||||
|
||||
unless (@fail_on_unexpected_calls)
|
||||
file << functions.collect {|function| @plugins.run(:mock_ignore, function)}.join
|
||||
end
|
||||
|
||||
if (@ordered)
|
||||
file << " GlobalExpectCount = 0;\n"
|
||||
file << " GlobalVerifyOrder = 0;\n"
|
||||
@@ -222,8 +234,9 @@ class CMockGenerator
|
||||
file << "#{function_mod_and_rettype} #{function[:name]}(#{args_string})\n"
|
||||
file << "{\n"
|
||||
file << " UNITY_LINE_TYPE cmock_line = TEST_LINE_NUM;\n"
|
||||
file << " CMOCK_#{function[:name]}_CALL_INSTANCE* cmock_call_instance;\n"
|
||||
file << " UNITY_SET_DETAIL(CMockString_#{function[:name]});\n"
|
||||
file << " CMOCK_#{function[:name]}_CALL_INSTANCE* 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 << @plugins.run(:mock_implementation_precheck, function)
|
||||
file << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringCalledMore);\n"
|
||||
|
||||
@@ -79,8 +79,12 @@ class CMockGeneratorPluginCallback
|
||||
|
||||
def mock_interfaces(function)
|
||||
func_name = function[:name]
|
||||
"void #{func_name}_StubWithCallback(CMOCK_#{func_name}_CALLBACK Callback)\n{\n" +
|
||||
" Mock.#{func_name}_CallbackFunctionPointer = Callback;\n}\n\n"
|
||||
lines = ""
|
||||
lines << "void #{func_name}_StubWithCallback(CMOCK_#{func_name}_CALLBACK Callback)\n{\n"
|
||||
if @config.plugins.include? :ignore
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n"
|
||||
end
|
||||
lines << " Mock.#{func_name}_CallbackFunctionPointer = Callback;\n}\n\n"
|
||||
end
|
||||
|
||||
def mock_destroy(function)
|
||||
|
||||
@@ -68,7 +68,7 @@ class CMockGeneratorPluginExpect
|
||||
function[:args].each do |arg|
|
||||
lines << @utils.code_verify_an_arg_expectation(function, arg)
|
||||
end
|
||||
lines << "\n }\n"
|
||||
lines << " }\n"
|
||||
lines
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
end
|
||||
|
||||
def mock_function_declarations(function)
|
||||
|
||||
if (function[:return][:void?])
|
||||
return "#define #{function[:name]}_ExpectAnyArgs() #{function[:name]}_CMockExpectAnyArgs(__LINE__)\n" +
|
||||
"void #{function[:name]}_CMockExpectAnyArgs(UNITY_LINE_TYPE cmock_line);\n"
|
||||
@@ -38,19 +37,6 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
end
|
||||
end
|
||||
|
||||
# def mock_implementation(function)
|
||||
# lines = " if (cmock_call_instance->IgnoreMode == CMOCK_ARG_NONE)\n {\n"
|
||||
# if (function[:return][:void?])
|
||||
# lines << " return;\n }\n"
|
||||
# else
|
||||
# retval = function[:return].merge( { :name => "cmock_call_instance->ReturnVal"} )
|
||||
# lines << " " + @utils.code_assign_argument_quickly("Mock.#{function[:name]}_FinalReturn", retval) unless (retval[:void?])
|
||||
# return_type = function[:return][:const?] ? "(const #{function[:return][:type]})" : ((function[:return][:type] =~ /cmock/) ? "(#{function[:return][:type]})" : '')
|
||||
# lines << " return #{return_type}cmock_call_instance->ReturnVal;\n }\n"
|
||||
# end
|
||||
# lines
|
||||
# end
|
||||
|
||||
def mock_interfaces(function)
|
||||
lines = ""
|
||||
if (function[:return][:void?])
|
||||
|
||||
@@ -65,6 +65,10 @@ class CMockGeneratorPluginIgnore
|
||||
lines << "}\n\n"
|
||||
end
|
||||
|
||||
def mock_ignore(function)
|
||||
" Mock.#{function[:name]}_IgnoreBool = (int) 1;\n"
|
||||
end
|
||||
|
||||
def mock_verify(function)
|
||||
func_name = function[:name]
|
||||
" if (Mock.#{func_name}_IgnoreBool)\n Mock.#{func_name}_CallInstance = CMOCK_GUTS_NONE;\n"
|
||||
|
||||
@@ -64,7 +64,8 @@ class CMockGeneratorPluginReturnThruPtr
|
||||
if (@utils.ptr_or_str?(arg[:type]) and not arg[:const?])
|
||||
lines << " if (cmock_call_instance->ReturnThruPtr_#{arg_name}_Used)\n"
|
||||
lines << " {\n"
|
||||
lines << " memcpy(#{arg_name}, cmock_call_instance->ReturnThruPtr_#{arg_name}_Val,\n"
|
||||
lines << " UNITY_TEST_ASSERT_NOT_NULL(#{arg_name}, cmock_line, CMockStringPtrIsNULL);\n"
|
||||
lines << " memcpy((void*)#{arg_name}, (void*)cmock_call_instance->ReturnThruPtr_#{arg_name}_Val,\n"
|
||||
lines << " cmock_call_instance->ReturnThruPtr_#{arg_name}_Size);\n"
|
||||
lines << " }\n"
|
||||
end
|
||||
|
||||
@@ -112,12 +112,11 @@ class CMockGeneratorUtils
|
||||
else
|
||||
(@helpers.nil? or @helpers[:unity_helper].nil?) ? ["UNITY_TEST_ASSERT_EQUAL",''] : @helpers[:unity_helper].get_helper(c_type)
|
||||
end
|
||||
unity_msg = "Function '#{function[:name]}' called with unexpected value for argument '#{arg_name}'."
|
||||
return c_type, arg_name, expected, ignore, unity_func[0], unity_func[1], unity_msg
|
||||
return c_type, arg_name, expected, ignore, unity_func[0], unity_func[1]
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_no_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
lines << " {\n"
|
||||
@@ -152,7 +151,7 @@ class CMockGeneratorUtils
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_normal_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
depth_name = (arg[:ptr?]) ? "cmock_call_instance->Expected_#{arg_name}_Depth" : 1
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
@@ -188,7 +187,7 @@ class CMockGeneratorUtils
|
||||
end
|
||||
|
||||
def code_verify_an_arg_expectation_with_smart_arrays(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre, unity_msg = lookup_expect_type(function, arg)
|
||||
c_type, arg_name, expected, ignore, unity_func, pre = lookup_expect_type(function, arg)
|
||||
depth_name = (arg[:ptr?]) ? "cmock_call_instance->Expected_#{arg_name}_Depth" : 1
|
||||
lines = ""
|
||||
lines << " if (!#{ignore})\n" if @ignore_arg
|
||||
|
||||
+42
-36
@@ -6,12 +6,13 @@
|
||||
|
||||
class CMockHeaderParser
|
||||
|
||||
attr_accessor :funcs, :c_attributes, :treat_as_void, :treat_externs
|
||||
attr_accessor :funcs, :c_attr_noconst, :c_attributes, :treat_as_void, :treat_externs
|
||||
|
||||
def initialize(cfg)
|
||||
@funcs = []
|
||||
@c_strippables = cfg.strippables
|
||||
@c_attributes = (['const'] + cfg.attributes).uniq
|
||||
@c_attr_noconst = cfg.attributes.uniq - ['const']
|
||||
@c_attributes = ['const'] + c_attr_noconst
|
||||
@c_calling_conventions = cfg.c_calling_conventions.uniq
|
||||
@treat_as_void = (['void'] + cfg.treat_as_void).uniq
|
||||
@declaration_parse_matcher = /([\d\w\s\*\(\),\[\]]+??)\(([\d\w\s\*\(\),\.\[\]+-]*)\)$/m
|
||||
@@ -48,7 +49,7 @@ class CMockHeaderParser
|
||||
def import_source(source)
|
||||
|
||||
# let's clean up the encoding in case they've done anything weird with the characters we might find
|
||||
source = source.force_encoding("ISO-8859-1").encode("utf-8", :replace => nil) if ($QUICK_RUBY_VERSION > 10900)
|
||||
source = source.force_encoding("ISO-8859-1").encode("utf-8", :replace => nil)
|
||||
|
||||
# void must be void for cmock _ExpectAndReturn calls to process properly, not some weird typedef which equates to void
|
||||
# to a certain extent, this action assumes we're chewing on pre-processed header files, otherwise we'll most likely just get stuff from @treat_as_void
|
||||
@@ -79,7 +80,7 @@ class CMockHeaderParser
|
||||
# enums, unions, structs, and typedefs can all contain things (e.g. function pointers) that parse like function prototypes, so yank them
|
||||
# forward declared structs are removed before struct definitions so they don't mess up real thing later. we leave structs keywords in function prototypes
|
||||
source.gsub!(/^[\w\s]*struct[^;\{\}\(\)]+;/m, '') # remove forward declared structs
|
||||
source.gsub!(/^[\w\s]*(enum|union|struct|typepdef)[\w\s]*\{[^\}]+\}[\w\s\*\,]*;/m, '') # remove struct, union, and enum definitions and typedefs with braces
|
||||
source.gsub!(/^[\w\s]*(enum|union|struct|typedef)[\w\s]*\{[^\}]+\}[\w\s\*\,]*;/m, '') # remove struct, union, and enum definitions and typedefs with braces
|
||||
source.gsub!(/(\W)(?:register|auto|static|restrict)(\W)/, '\1\2') # remove problem keywords
|
||||
source.gsub!(/\s*=\s*['"a-zA-Z0-9_\.]+\s*/, '') # remove default value statements from argument lists
|
||||
source.gsub!(/^(?:[\w\s]*\W)?typedef\W[^;]*/m, '') # remove typedef statements
|
||||
@@ -94,7 +95,13 @@ class CMockHeaderParser
|
||||
end
|
||||
|
||||
# remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection)
|
||||
while source.gsub!(/\{[^\{\}]*\{[^\{\}]*\}[^\{\}]*\}/m, '{ }')
|
||||
if (RUBY_VERSION.split('.')[0].to_i > 1)
|
||||
#we assign a string first because (no joke) if Ruby 1.9.3 sees this line as a regex, it will crash.
|
||||
r = "\\{([^\\{\\}]*|\\g<0>)*\\}"
|
||||
source.gsub!(/#{r}/m, '{ }')
|
||||
else
|
||||
while source.gsub!(/\{[^\{\}]*\{[^\{\}]*\}[^\{\}]*\}/m, '{ }')
|
||||
end
|
||||
end
|
||||
|
||||
# remove function definitions by stripping off the arguments right now
|
||||
@@ -138,46 +145,45 @@ class CMockHeaderParser
|
||||
arg_list.split(',').each do |arg|
|
||||
arg.strip!
|
||||
return args if (arg =~ /^\s*((\.\.\.)|(void))\s*$/) # we're done if we reach void by itself or ...
|
||||
|
||||
# Split up words and remove known attributes, but in case of pointer args, don't remove any
|
||||
# 'const' from the type that it points to, since that may change the underlying assembly-code
|
||||
# pointer type on some embedded platforms, making it point to RAM instead of ROM. (I.e. For
|
||||
# pointer args, remove 'const' only when it applies to the pointer itself. For non-pointer
|
||||
# args, remove 'const' regardless.)
|
||||
#
|
||||
arg_array = arg.split
|
||||
arg_elements = arg_array - @c_attributes # split up words and remove known attributes
|
||||
args << { :type => (arg_type = arg_elements[0..-2].join(' ')),
|
||||
ptr_const_info = divine_ptr_and_const(arg)
|
||||
arg_elements = arg_array - (arg.include?('*') ? @c_attr_noconst : @c_attributes)
|
||||
args << { :type => arg_elements[0..(ptr_const_info[:const_ptr?] ? -3 : -2)].join(' '),
|
||||
:name => arg_elements[-1]
|
||||
}.merge(divine_ptr_and_const(arg))
|
||||
}.merge(ptr_const_info)
|
||||
end
|
||||
return args
|
||||
end
|
||||
|
||||
def divine_ptr(arg_type)
|
||||
return false unless arg_type.include? '*'
|
||||
return false if arg_type.gsub(/(const|char|\*|\s)+/,'').empty?
|
||||
def divine_ptr(arg)
|
||||
return false unless arg.include? '*'
|
||||
# treat "const char *" and similar as a string, not a pointer
|
||||
return false if /(^|\s)(const\s+)?char(\s+const)?\s*\*(?!.*\*)/ =~ arg
|
||||
return true
|
||||
end
|
||||
|
||||
def divine_const(arg)
|
||||
return false if !(/(?:^|\s|\*)const(?:\*|\s|$)/ =~ arg) # check for const as part of a larger word
|
||||
return true if (/const(?:\w|\s)*\*/ =~ arg) # check const comes before * indicating const data
|
||||
return false if (/\*\s*const/ =~ arg) # check const comes after * indicating const ptr
|
||||
return true
|
||||
# a non-pointer arg containing "const" is a constant
|
||||
# an arg containing "const" before the last * is a pointer to a constant
|
||||
return ( arg.include?('*') ? (/(^|\s|\*)const(\s(\w|\s)*)?\*(?!.*\*)/ =~ arg)
|
||||
: (/(^|\s)const(\s|$)/ =~ arg) ) ? true : false
|
||||
end
|
||||
|
||||
def divine_ptr_and_const(arg)
|
||||
divination = { :ptr? => false, :const? => false, :const_ptr? => false }
|
||||
divination = {}
|
||||
|
||||
#first check if there is a pointer present and that it's not part of a C string or function definition
|
||||
#divination[:ptr?] = (arg.split[0..-2].join.include?('*') && !arg.gsub(/(const|char|\*|\s)+/,'').empty?)
|
||||
divination[:ptr?] = (arg.include?('*') && !arg.gsub(/(const|char|\*|\s)+/,'').empty?)
|
||||
divination[:ptr?] = divine_ptr(arg)
|
||||
divination[:const?] = divine_const(arg)
|
||||
|
||||
#if there isn't a const that isn't part of a larger word, we're done
|
||||
return divination if !(/(?:^|\s|\*)const(?:\*|\s|$)/ =~ arg)
|
||||
divination[:const?] = true
|
||||
|
||||
# check const comes after * indicating const ptr
|
||||
if (/\*\s*const/ =~ arg)
|
||||
divination[:const_ptr?] = true
|
||||
|
||||
#check const comes before * indicating also const data
|
||||
divination[:const?] = (/const(?:\w|\s)*\*/ =~ arg) ? true : false
|
||||
end
|
||||
# an arg containing "const" after the last * is a constant pointer
|
||||
divination[:const_ptr?] = (/\*(?!.*\*)\s*const(\s|$)/ =~ arg) ? true : false
|
||||
|
||||
return divination
|
||||
end
|
||||
@@ -187,9 +193,9 @@ class CMockHeaderParser
|
||||
return 'void'
|
||||
else
|
||||
c=0
|
||||
arg_list.gsub!(/(\w+)(?:\s*\[[\s\d\w+-]*\])+/,'*\1') # magically turn brackets into asterisks
|
||||
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])+/,'*\1') # magically turn brackets into asterisks, also match for parentheses that come from macros
|
||||
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
|
||||
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
|
||||
|
||||
#scan argument list for function pointers and replace them with custom types
|
||||
arg_list.gsub!(/([\w\s\*]+)\(+\s*\*[\*\s]*([\w\s]*)\s*\)+\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |m|
|
||||
@@ -231,8 +237,8 @@ class CMockHeaderParser
|
||||
|
||||
#process function attributes, return type, and name
|
||||
descriptors = regex_match[1]
|
||||
descriptors.gsub!(/\s+\*/,'*') #remove space to place asterisks with return type (where they belong)
|
||||
descriptors.gsub!(/\*(\w)/,'* \1') #pull asterisks away from function name to place asterisks with return type (where they belong)
|
||||
descriptors.gsub!(/(\w)\*/,'\1 *') #pull asterisks away from preceding word
|
||||
descriptors.gsub!(/\*(\w)/,'* \1') #pull asterisks away from following word
|
||||
descriptors = descriptors.split #array of all descriptor strings
|
||||
|
||||
#grab name
|
||||
@@ -252,7 +258,7 @@ class CMockHeaderParser
|
||||
end
|
||||
end
|
||||
decl[:modifier] = decl[:modifier].join(' ')
|
||||
rettype = rettype.join(' ')
|
||||
rettype = rettype.join(' ').gsub(/\s+\*/,'*') #remove space before asterisks
|
||||
rettype = 'void' if (@local_as_void.include?(rettype.strip))
|
||||
decl[:return] = { :type => rettype,
|
||||
:name => 'cmock_to_return',
|
||||
|
||||
+27
-12
@@ -2,30 +2,25 @@
|
||||
# CMock Project - Automatic Mock Generation for C
|
||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==========================================
|
||||
# ==========================================
|
||||
|
||||
require 'thread'
|
||||
|
||||
class CMockPluginManager
|
||||
|
||||
attr_accessor :plugins
|
||||
|
||||
|
||||
def initialize(config, utils)
|
||||
@plugins = []
|
||||
plugins_to_load = [:expect, config.plugins].flatten.uniq.compact
|
||||
plugins_to_load.each do |plugin|
|
||||
plugin_name = plugin.to_s
|
||||
object_name = "CMockGeneratorPlugin" + camelize(plugin_name)
|
||||
begin
|
||||
unless (Object.const_defined? object_name)
|
||||
require "#{File.expand_path(File.dirname(__FILE__))}/cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
end
|
||||
@plugins << eval("#{object_name}.new(config, utils)")
|
||||
rescue
|
||||
raise "ERROR: CMock unable to load plugin '#{plugin_name}'"
|
||||
end
|
||||
self.class.plugin_require_mutex.synchronize { load_plugin(plugin_name, object_name, config, utils) }
|
||||
end
|
||||
@plugins.sort! {|a,b| a.priority <=> b.priority }
|
||||
end
|
||||
|
||||
|
||||
def run(method, args=nil)
|
||||
if args.nil?
|
||||
return @plugins.collect{ |plugin| plugin.send(method) if plugin.respond_to?(method) }.flatten.join
|
||||
@@ -33,8 +28,28 @@ class CMockPluginManager
|
||||
return @plugins.collect{ |plugin| plugin.send(method, args) if plugin.respond_to?(method) }.flatten.join
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def camelize(lower_case_and_underscored_word)
|
||||
lower_case_and_underscored_word.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.plugin_require_mutex
|
||||
@mutex ||= Mutex.new
|
||||
end
|
||||
|
||||
def load_plugin(plugin_name, object_name, config, utils)
|
||||
begin
|
||||
unless (Object.const_defined? object_name)
|
||||
file_name = "#{File.expand_path(File.dirname(__FILE__))}/cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
require file_name
|
||||
end
|
||||
class_name = Object.const_get(object_name)
|
||||
@plugins << class_name.new(config, utils)
|
||||
rescue
|
||||
file_name = "#{File.expand_path(File.dirname(__FILE__))}/cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
||||
raise "ERROR: CMock unable to load plugin '#{plugin_name}' '#{object_name}' #{file_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
215
|
||||
216
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
2.4.3
|
||||
2.4.5
|
||||
|
||||
|
||||
+46
-19
@@ -18,8 +18,9 @@ RUNNERS_DIR = File.join(TEST_BUILD_DIR, 'runners')
|
||||
MOCKS_DIR = File.join(TEST_BUILD_DIR, 'mocks')
|
||||
TEST_BIN_DIR = TEST_BUILD_DIR
|
||||
MOCK_PREFIX = ENV.fetch('TEST_MOCK_PREFIX', 'mock_')
|
||||
MOCK_SUFFIX = ENV.fetch('TEST_MOCK_SUFFIX', '')
|
||||
TEST_MAKEFILE = ENV.fetch('TEST_MAKEFILE', File.join(TEST_BUILD_DIR, 'MakefileTestSupport'))
|
||||
MOCK_MATCHER = /#{MOCK_PREFIX}[A-Za-z_][A-Za-z0-9_\-\.]+/
|
||||
MOCK_MATCHER = /#{MOCK_PREFIX}[A-Za-z_][A-Za-z0-9_\-\.]+#{MOCK_SUFFIX}/
|
||||
|
||||
[TEST_BUILD_DIR, OBJ_DIR, RUNNERS_DIR, MOCKS_DIR, TEST_BIN_DIR].each do |dir|
|
||||
FileUtils.mkdir_p dir
|
||||
@@ -27,6 +28,8 @@ end
|
||||
|
||||
all_headers_to_mock = []
|
||||
|
||||
suppress_error = !ARGV.nil? && !ARGV.empty? && (ARGV[0].upcase == "--SILENT")
|
||||
|
||||
File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
|
||||
# Define make variables
|
||||
@@ -56,7 +59,8 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
test_sources = Dir["#{TEST_DIR}/**/test_*.c"]
|
||||
test_targets = []
|
||||
generator = UnityTestRunnerGenerator.new
|
||||
all_headers = Dir["#{SRC_DIR}/**/*.h"]
|
||||
all_headers = Dir["#{SRC_DIR}/**/{[!#{MOCK_PREFIX}]}*{[!#{MOCK_SUFFIX}]}.h"] #headers that begin with prefix or end with suffix are not included
|
||||
makefile_targets = []
|
||||
|
||||
test_sources.each do |test|
|
||||
module_name = File.basename(test, '.c')
|
||||
@@ -65,14 +69,39 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
runner_source = File.join(RUNNERS_DIR, "runner_#{module_name}.c")
|
||||
runner_obj = File.join(OBJ_DIR, "runner_#{module_name}.o")
|
||||
test_bin = File.join(TEST_BIN_DIR, module_name)
|
||||
test_results = File.join(TEST_BIN_DIR, module_name + '.result')
|
||||
test_results = File.join(TEST_BIN_DIR, module_name + '.testresult')
|
||||
|
||||
cfg = {
|
||||
src: test,
|
||||
includes: generator.find_includes(File.readlines(test).join(''))
|
||||
}
|
||||
|
||||
# Build main project modules, with TEST defined
|
||||
module_src = File.join(SRC_DIR, "#{src_module_name}.c")
|
||||
module_obj = File.join(OBJ_DIR, "#{src_module_name}.o")
|
||||
mkfile.puts "#{module_obj}: #{module_src}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< -DTEST -I #{SRC_DIR}"
|
||||
mkfile.puts ""
|
||||
if not makefile_targets.include? module_obj
|
||||
makefile_targets.push(module_obj)
|
||||
mkfile.puts "#{module_obj}: #{module_src}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} ${INCLUDE_PATH}"
|
||||
mkfile.puts ""
|
||||
end
|
||||
|
||||
# process link-only files
|
||||
linkonly = cfg[:includes][:linkonly]
|
||||
linkonly_objs = []
|
||||
linkonly.each do |linkonlyfile|
|
||||
linkonlybase = File.basename(linkonlyfile)
|
||||
linkonlymodule_src = File.join(SRC_DIR, "#{linkonlyfile}.c")
|
||||
linkonlymodule_obj = File.join(OBJ_DIR, "#{linkonlybase}.o")
|
||||
linkonly_objs.push(linkonlymodule_obj)
|
||||
#only create the target if we didn't already
|
||||
if not makefile_targets.include? linkonlymodule_obj
|
||||
makefile_targets.push(linkonlymodule_obj)
|
||||
mkfile.puts "#{linkonlymodule_obj}: #{linkonlymodule_src}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} ${INCLUDE_PATH}"
|
||||
mkfile.puts ""
|
||||
end
|
||||
end
|
||||
|
||||
# Create runners
|
||||
mkfile.puts "#{runner_source}: #{test}"
|
||||
@@ -81,17 +110,14 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
|
||||
# Build runner
|
||||
mkfile.puts "#{runner_obj}: #{runner_source}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} -I #{MOCKS_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} -I #{MOCKS_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC} ${INCLUDE_PATH}"
|
||||
mkfile.puts ""
|
||||
|
||||
# Collect mocks to generate
|
||||
cfg = {
|
||||
src: test,
|
||||
includes: generator.find_includes(File.readlines(test).join(''))
|
||||
}
|
||||
system_mocks = cfg[:includes][:system].select{|name| name =~ MOCK_MATCHER}
|
||||
raise "Mocking of system headers is not yet supported!" if !system_mocks.empty?
|
||||
local_mocks = cfg[:includes][:local].select{|name| name =~ MOCK_MATCHER}
|
||||
|
||||
module_names_to_mock = local_mocks.map{|name| "#{name.sub(/#{MOCK_PREFIX}/,'')}.h"}
|
||||
headers_to_mock = []
|
||||
module_names_to_mock.each do |name|
|
||||
@@ -103,8 +129,9 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
end
|
||||
end
|
||||
raise "Module header '#{name}' not found to mock!" unless header_to_mock
|
||||
headers_to_mock << header_to_mock
|
||||
headers_to_mock << header_to_mock
|
||||
end
|
||||
|
||||
all_headers_to_mock += headers_to_mock
|
||||
mock_objs = headers_to_mock.map do |hdr|
|
||||
mock_name = MOCK_PREFIX + File.basename(hdr, '.h')
|
||||
@@ -114,18 +141,18 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
|
||||
# Build test suite
|
||||
mkfile.puts "#{test_obj}: #{test} #{module_obj} #{mock_objs.join(' ')}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC} -I #{MOCKS_DIR}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{SRC_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC} -I #{MOCKS_DIR} ${INCLUDE_PATH}"
|
||||
mkfile.puts ""
|
||||
|
||||
# Build test suite executable
|
||||
test_objs = "#{test_obj} #{runner_obj} #{module_obj} #{mock_objs.join(' ')} #{UNITY_OBJ} #{CMOCK_OBJ}"
|
||||
test_objs = "#{test_obj} #{runner_obj} #{module_obj} #{mock_objs.join(' ')} #{linkonly_objs.join(' ')} #{UNITY_OBJ} #{CMOCK_OBJ}"
|
||||
mkfile.puts "#{test_bin}: #{test_objs}"
|
||||
mkfile.puts "\t${CC} -o $@ #{test_objs}"
|
||||
mkfile.puts "\t${CC} -o $@ ${LDFLAGS} #{test_objs}"
|
||||
mkfile.puts ""
|
||||
|
||||
# Run test suite and generate report
|
||||
mkfile.puts "#{test_results}: #{test_bin}"
|
||||
mkfile.puts "\t-#{test_bin} &> #{test_results}"
|
||||
mkfile.puts "\t-#{test_bin} > #{test_results} 2>&1"
|
||||
mkfile.puts ""
|
||||
|
||||
test_targets << test_bin
|
||||
@@ -143,19 +170,19 @@ File.open(TEST_MAKEFILE, "w") do |mkfile|
|
||||
mkfile.puts ""
|
||||
|
||||
mkfile.puts "#{mock_obj}: #{mock_src} #{mock_header}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{MOCKS_DIR} -I #{SRC_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC}"
|
||||
mkfile.puts "\t${CC} -o $@ -c $< ${TEST_CFLAGS} -I #{MOCKS_DIR} -I #{SRC_DIR} -I #{UNITY_SRC} -I #{CMOCK_SRC} ${INCLUDE_PATH}"
|
||||
mkfile.puts ""
|
||||
end
|
||||
|
||||
# Create test summary task
|
||||
mkfile.puts "test_summary:"
|
||||
mkfile.puts "\t@UNITY_DIR=${UNITY_DIR} ruby ${CMOCK_DIR}/scripts/test_summary.rb"
|
||||
mkfile.puts "\t@UNITY_DIR=${UNITY_DIR} ruby ${CMOCK_DIR}/scripts/test_summary.rb #{suppress_error ? '--silent' : ''}"
|
||||
mkfile.puts ""
|
||||
mkfile.puts ".PHONY: test_summary"
|
||||
mkfile.puts ""
|
||||
|
||||
# Create target to run all tests
|
||||
mkfile.puts "test: #{test_targets.map{|t| t + '.result'}.join(' ')} test_summary"
|
||||
mkfile.puts "test: #{test_targets.map{|t| t + '.testresult'}.join(' ')} test_summary"
|
||||
mkfile.puts ""
|
||||
|
||||
end
|
||||
|
||||
+17
-9
@@ -1,11 +1,19 @@
|
||||
require "#{ENV['UNITY_DIR']}/auto/unity_test_summary.rb"
|
||||
|
||||
build_dir = ENV.fetch('BUILD_DIR', './build')
|
||||
test_build_dir = ENV.fetch('TEST_BUILD_DIR', File.join(build_dir, 'test'))
|
||||
suppress_error = !ARGV.nil? && !ARGV.empty? && (ARGV[0].upcase == "--SILENT")
|
||||
|
||||
results = Dir["#{test_build_dir}/*.result"]
|
||||
parser = UnityTestSummary.new
|
||||
parser.set_targets(results)
|
||||
parser.run
|
||||
puts parser.report
|
||||
exit(parser.failures)
|
||||
begin
|
||||
require "#{ENV['UNITY_DIR']}/auto/unity_test_summary.rb"
|
||||
|
||||
build_dir = ENV.fetch('BUILD_DIR', './build')
|
||||
test_build_dir = ENV.fetch('TEST_BUILD_DIR', File.join(build_dir, 'test'))
|
||||
|
||||
results = Dir["#{test_build_dir}/*.testresult"]
|
||||
parser = UnityTestSummary.new
|
||||
parser.targets = results
|
||||
parser.run
|
||||
puts parser.report
|
||||
rescue StandardError => e
|
||||
raise e unless suppress_error
|
||||
end
|
||||
|
||||
exit(parser.failures) unless suppress_error
|
||||
|
||||
@@ -16,6 +16,7 @@ const char* CMockStringCalledLate = "Called later than expected.";
|
||||
const char* CMockStringCallOrder = "Called out of order.";
|
||||
const char* CMockStringIgnPreExp = "IgnoreArg called before Expect.";
|
||||
const char* CMockStringPtrPreExp = "ReturnThruPtr called before Expect.";
|
||||
const char* CMockStringPtrIsNULL = "Pointer is NULL.";
|
||||
const char* CMockStringExpNULL = "Expected NULL.";
|
||||
const char* CMockStringMismatch = "Function called with unexpected argument value.";
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
|
||||
#define CMOCK_ARG_MODE CMOCK_MEM_INDEX_TYPE
|
||||
#define CMOCK_ARG_ALL 0
|
||||
#define CMOCK_ARG_NONE ((CMOCK_MEM_INDEX_TYPE)(~0))
|
||||
#define CMOCK_ARG_NONE ((CMOCK_MEM_INDEX_TYPE)(~0U))
|
||||
|
||||
//-------------------------------------------------------
|
||||
// Memory API
|
||||
|
||||
+14
-1
@@ -16,6 +16,7 @@ extern const char* CMockStringCalledLate;
|
||||
extern const char* CMockStringCallOrder;
|
||||
extern const char* CMockStringIgnPreExp;
|
||||
extern const char* CMockStringPtrPreExp;
|
||||
extern const char* CMockStringPtrIsNULL;
|
||||
extern const char* CMockStringExpNULL;
|
||||
extern const char* CMockStringMismatch;
|
||||
|
||||
@@ -59,7 +60,19 @@ extern const char* CMockStringMismatch;
|
||||
|
||||
//0 for no alignment, 1 for 16-bit, 2 for 32-bit, 3 for 64-bit
|
||||
#ifndef CMOCK_MEM_ALIGN
|
||||
#define CMOCK_MEM_ALIGN (2)
|
||||
#ifdef UNITY_LONG_WIDTH
|
||||
#if (UNITY_LONG_WIDTH == 16)
|
||||
#define CMOCK_MEM_ALIGN (1)
|
||||
#elif (UNITY_LONG_WIDTH == 32)
|
||||
#define CMOCK_MEM_ALIGN (2)
|
||||
#elif (UNITY_LONG_WIDTH == 64)
|
||||
#define CMOCK_MEM_ALIGN (3)
|
||||
#else
|
||||
#define CMOCK_MEM_ALIGN (2)
|
||||
#endif
|
||||
#else
|
||||
#define CMOCK_MEM_ALIGN (2)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//amount of memory to allow cmock to use in its internal heap
|
||||
|
||||
+1
-1
@@ -179,7 +179,7 @@ void test_ThatCMockStopsReturningMoreDataWhenItRunsOutOfMemory(void)
|
||||
}
|
||||
|
||||
//there aren't any after that
|
||||
TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, (_UU32)next);
|
||||
TEST_ASSERT_EQUAL_HEX(CMOCK_GUTS_NONE, (UNITY_UINT32)next);
|
||||
}
|
||||
|
||||
void test_ThatCMockStopsReturningMoreDataWhenAskForMoreThanItHasLeftEvenIfNotAtExactEnd(void)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
:files:
|
||||
- 'src/cmock.c'
|
||||
- 'test/c/TestCMockC.c'
|
||||
- 'test/c/TestCMockC_Runner.c'
|
||||
- 'vendor/unity/src/unity.c'
|
||||
- '../src/cmock.c'
|
||||
- './c/TestCMockC.c'
|
||||
- './c/TestCMockC_Runner.c'
|
||||
- '../vendor/unity/src/unity.c'
|
||||
:options:
|
||||
- 'TEST'
|
||||
- 'CMOCK_MEM_STATIC'
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
:files:
|
||||
- 'src/cmock.c'
|
||||
- 'test/c/TestCMockCDynamic.c'
|
||||
- 'test/c/TestCMockCDynamic_Runner.c'
|
||||
- 'vendor/unity/src/unity.c'
|
||||
- '../src/cmock.c'
|
||||
- './c/TestCMockCDynamic.c'
|
||||
- './c/TestCMockCDynamic_Runner.c'
|
||||
- '../vendor/unity/src/unity.c'
|
||||
:options:
|
||||
- 'TEST'
|
||||
- 'CMOCK_MEM_DYNAMIC'
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# [Released under MIT License. Please refer to license.txt for details]
|
||||
# ==============================================================================
|
||||
|
||||
require './config/test_environment'
|
||||
require '../config/test_environment'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
@@ -13,11 +13,11 @@ require './rakefile_helper'
|
||||
include RakefileHelpers
|
||||
|
||||
DEFAULT_CONFIG_FILE = 'gcc.yml'
|
||||
CMOCK_ROOT = File.expand_path(File.dirname(__FILE__))
|
||||
CMOCK_TEST_ROOT = File.expand_path(File.dirname(__FILE__))
|
||||
|
||||
SYSTEM_TEST_SUPPORT_DIRS = [
|
||||
File.join(CMOCK_ROOT, 'test/system/generated'),
|
||||
File.join(CMOCK_ROOT, 'test/system/build')
|
||||
File.join(CMOCK_TEST_ROOT, 'system/generated'),
|
||||
File.join(CMOCK_TEST_ROOT, 'system/build')
|
||||
]
|
||||
|
||||
SYSTEM_TEST_SUPPORT_DIRS.each do |dir|
|
||||
@@ -48,12 +48,12 @@ task :test => [:clobber, :prep_system_tests, 'test:units', 'test:c', 'test:syste
|
||||
namespace :test do
|
||||
desc "Run Unit Tests"
|
||||
Rake::TestTask.new('units') do |t|
|
||||
t.pattern = 'test/unit/*_test.rb'
|
||||
t.pattern = 'unit/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
#individual unit tests
|
||||
FileList['test/unit/*_test.rb'].each do |test|
|
||||
FileList['unit/*_test.rb'].each do |test|
|
||||
Rake::TestTask.new(File.basename(test,'.*').sub('_test','')) do |t|
|
||||
t.pattern = test
|
||||
t.verbose = true
|
||||
@@ -70,8 +70,8 @@ namespace :test do
|
||||
desc "Run System Tests"
|
||||
task :system => [:clobber, :prep_system_tests] do
|
||||
#get a list of all system tests, removing unsupported tests for this compiler
|
||||
sys_unsupported = $cfg['unsupported'].map {|a| 'test/system/test_interactions/'+a+'.yml'}
|
||||
sys_tests_to_run = FileList['test/system/test_interactions/*.yml'] - sys_unsupported
|
||||
sys_unsupported = $cfg['unsupported'].map {|a| 'system/test_interactions/'+a+'.yml'}
|
||||
sys_tests_to_run = FileList['system/test_interactions/*.yml'] - sys_unsupported
|
||||
compile_unsupported = $cfg['unsupported'].map {|a| SYSTEST_COMPILE_MOCKABLES_PATH+a+'.h'}
|
||||
compile_tests_to_run = FileList[SYSTEST_COMPILE_MOCKABLES_PATH + '*.h'] - compile_unsupported
|
||||
unless (sys_unsupported.empty? and compile_unsupported.empty?)
|
||||
@@ -87,7 +87,7 @@ namespace :test do
|
||||
end
|
||||
|
||||
#individual system tests
|
||||
FileList['test/system/test_interactions/*.yml'].each do |test|
|
||||
FileList['system/test_interactions/*.yml'].each do |test|
|
||||
basename = File.basename(test,'.*')
|
||||
desc "Run system test #{basename}"
|
||||
task basename do
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
require './vendor/unity/auto/generate_test_runner'
|
||||
require './vendor/unity/auto/unity_test_summary'
|
||||
require './test/system/systest_generator'
|
||||
require './vendor/unity/auto/colour_reporter.rb'
|
||||
require '../vendor/unity/auto/generate_test_runner'
|
||||
require '../vendor/unity/auto/unity_test_summary'
|
||||
require '../vendor/unity/auto/colour_reporter.rb'
|
||||
require './system/systest_generator'
|
||||
|
||||
module RakefileHelpers
|
||||
|
||||
SYSTEST_GENERATED_FILES_PATH = 'test/system/generated/'
|
||||
SYSTEST_BUILD_FILES_PATH = 'test/system/build/'
|
||||
SYSTEST_COMPILE_MOCKABLES_PATH = 'test/system/test_compilation/'
|
||||
SYSTEST_GENERATED_FILES_PATH = './system/generated/'
|
||||
SYSTEST_BUILD_FILES_PATH = './system/build/'
|
||||
SYSTEST_COMPILE_MOCKABLES_PATH = './system/test_compilation/'
|
||||
C_EXTENSION = '.c'
|
||||
RESULT_EXTENSION = '.result'
|
||||
|
||||
@@ -162,17 +162,17 @@ module RakefileHelpers
|
||||
|
||||
def report_summary
|
||||
summary = UnityTestSummary.new
|
||||
summary.set_root_path(File.expand_path(File.dirname(__FILE__)) + '/')
|
||||
summary.root = File.expand_path(File.dirname(__FILE__)) + '/'
|
||||
results_glob = "#{$cfg['compiler']['build_path']}*.test*"
|
||||
results_glob.gsub!(/\\/, '/')
|
||||
results = Dir[results_glob]
|
||||
summary.set_targets(results)
|
||||
summary.targets = results
|
||||
summary.run
|
||||
fail_out "FAIL: There were failures" if (summary.failures > 0)
|
||||
end
|
||||
|
||||
def run_system_test_interactions(test_case_files)
|
||||
load './lib/cmock.rb'
|
||||
load '../lib/cmock.rb'
|
||||
|
||||
SystemTestGenerator.new.generate_files(test_case_files)
|
||||
test_files = FileList.new(SYSTEST_GENERATED_FILES_PATH + 'test*.c')
|
||||
@@ -308,7 +308,7 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def run_system_test_compilations(mockables)
|
||||
load './lib/cmock.rb'
|
||||
load '../lib/cmock.rb'
|
||||
|
||||
load_configuration($cfg_file)
|
||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||
@@ -326,7 +326,7 @@ module RakefileHelpers
|
||||
end
|
||||
|
||||
def run_system_test_profiles(mockables)
|
||||
load './lib/cmock.rb'
|
||||
load '../lib/cmock.rb'
|
||||
|
||||
load_configuration($cfg_file)
|
||||
$cfg['compiler']['defines']['items'] = [] if $cfg['compiler']['defines']['items'].nil?
|
||||
@@ -353,7 +353,7 @@ module RakefileHelpers
|
||||
report "UNIT TEST C CODE\n"
|
||||
report "----------------\n"
|
||||
errors = false
|
||||
FileList.new("test/c/*.yml").each do |yaml_file|
|
||||
FileList.new("c/*.yml").each do |yaml_file|
|
||||
test = YAML.load(File.read(yaml_file))
|
||||
report "\nTesting #{yaml_file.sub('.yml','')}"
|
||||
report "(#{test[:options].join(', ')})"
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
:cmock:
|
||||
---
|
||||
:cmock:
|
||||
:plugins: []
|
||||
:includes: []
|
||||
:mock_path: test/system/generated/
|
||||
:mock_path: ./system/generated/
|
||||
:mock_prefix: mock_
|
||||
:treat_as_void:
|
||||
:treat_as_void:
|
||||
- OSEK_TASK
|
||||
- VOID_TYPE_CRAZINESS
|
||||
|
||||
@@ -159,4 +159,171 @@
|
||||
TEST_ASSERT_EQUAL(110, function(0, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'With "fail_on_unexpected_calls" enabled, Expect/Ignore/... of bar is required and test fails.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
function(1, 2, 3);
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'we can override an ignore with an expect and pass'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Ignore();
|
||||
|
||||
bar_Expect(2);
|
||||
foo_ExpectAndReturn(1, 50);
|
||||
foo_ExpectAndReturn(2, 60);
|
||||
foo_ExpectAndReturn(3, 70);
|
||||
TEST_ASSERT_EQUAL(180, function(1, 2, 3));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
bar_Expect(8);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
foo_ExpectAndReturn(9, 20);
|
||||
TEST_ASSERT_EQUAL(110, function(7, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'we can override an ignore with an expect and fail'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Ignore();
|
||||
|
||||
bar_Expect(2);
|
||||
foo_ExpectAndReturn(1, 50);
|
||||
foo_ExpectAndReturn(2, 60);
|
||||
foo_ExpectAndReturn(3, 70);
|
||||
TEST_ASSERT_EQUAL(180, function(1, 2, 3));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
bar_Expect(9);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
foo_ExpectAndReturn(9, 20);
|
||||
TEST_ASSERT_EQUAL(110, function(7, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'we can override an ignore and return with an expect and pass'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Ignore();
|
||||
foo_IgnoreAndReturn(30);
|
||||
TEST_ASSERT_EQUAL(90, function(1, 2, 3));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
bar_Expect(8);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
foo_ExpectAndReturn(9, 20);
|
||||
TEST_ASSERT_EQUAL(110, function(7, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'we can override an ignore and return with an expect and fail'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Ignore();
|
||||
foo_IgnoreAndReturn(0);
|
||||
TEST_ASSERT_EQUAL(0, function(1, 2, 3));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_ExpectAndReturn(6, 10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
bar_Expect(9);
|
||||
foo_ExpectAndReturn(7, 70);
|
||||
foo_ExpectAndReturn(8, 20);
|
||||
foo_ExpectAndReturn(9, 20);
|
||||
TEST_ASSERT_EQUAL(110, function(7, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'we can override an an expect with an ignore'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Expect(5);
|
||||
bar_Ignore();
|
||||
foo_ExpectAndReturn(1, 50);
|
||||
foo_ExpectAndReturn(2, 60);
|
||||
foo_ExpectAndReturn(3, 70);
|
||||
TEST_ASSERT_EQUAL(180, function(1, 2, 3));
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'we can override an expect with an ignore and return and pass'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Ignore();
|
||||
foo_IgnoreAndReturn(0);
|
||||
TEST_ASSERT_EQUAL(0, function(1, 2, 3));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 80);
|
||||
foo_IgnoreAndReturn(10);
|
||||
TEST_ASSERT_EQUAL(120, function(4, 5, 6));
|
||||
|
||||
bar_Ignore();
|
||||
foo_IgnoreAndReturn(60);
|
||||
TEST_ASSERT_EQUAL(180, function(7, 8, 9));
|
||||
}
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'we can override an expect with an ignore and return and fail after'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(4, 30);
|
||||
foo_ExpectAndReturn(5, 50);
|
||||
foo_IgnoreAndReturn(20);
|
||||
TEST_ASSERT_EQUAL(100, function(4, 5, 6));
|
||||
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(9, 30); //THIS ONE WILL FAIL
|
||||
foo_ExpectAndReturn(2, 80);
|
||||
foo_ExpectAndReturn(3, 60);
|
||||
TEST_ASSERT_EQUAL(170, function(1, 2, 3));
|
||||
}
|
||||
|
||||
- :pass: TRUE
|
||||
:should: 'we can override an expect with an ignore and return and the expected values are ignored'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
bar_Expect(5);
|
||||
foo_ExpectAndReturn(2, 30); //NOTE THIS WOULD NORMALLY FAIL
|
||||
foo_ExpectAndReturn(5, 50);
|
||||
foo_IgnoreAndReturn(20); //BUT WE SAID WE NO LONGER CARE
|
||||
TEST_ASSERT_EQUAL(100, function(4, 5, 6));
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
:cmock:
|
||||
:plugins:
|
||||
- 'ignore'
|
||||
:fail_on_unexpected_calls: FALSE
|
||||
|
||||
:systest:
|
||||
:types: |
|
||||
|
||||
:mockable: |
|
||||
int foo(int a);
|
||||
void bar(int b);
|
||||
|
||||
:source:
|
||||
:header: |
|
||||
int function(int a, int b, int c);
|
||||
:code: |
|
||||
int function(int a, int b, int c)
|
||||
{
|
||||
bar(b);
|
||||
return foo(a) + foo(b) + foo(c);
|
||||
}
|
||||
|
||||
:tests:
|
||||
:common: |
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
:units:
|
||||
- :pass: TRUE
|
||||
:should: 'With "fail_on_unexpected_calls" disabled, Expect/Ignore/... of bar is NOT required.'
|
||||
:code: |
|
||||
test()
|
||||
{
|
||||
function(1, 2, 3);
|
||||
}
|
||||
|
||||
...
|
||||
@@ -64,6 +64,8 @@
|
||||
|
||||
void oh_brackets1(int fudge[5]);
|
||||
void oh_brackets2(int caramel[]);
|
||||
void oh_brackets3(int toffee[(32)]);
|
||||
void oh_brackets4(int taffy[ (64) ]);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
:systest:
|
||||
:types: |
|
||||
#include "unity_internals.h"
|
||||
typedef _UU64 TEST64;
|
||||
|
||||
typedef UNITY_UINT64 TEST64;
|
||||
|
||||
:mockable: |
|
||||
TEST64 foo(TEST64 a);
|
||||
TEST64* bar(TEST64* b);
|
||||
|
||||
:source:
|
||||
:header: |
|
||||
:source:
|
||||
:header: |
|
||||
TEST64 function_a(void);
|
||||
|
||||
:code: |
|
||||
@@ -23,17 +23,17 @@
|
||||
TEST64 a = 0x1234567890123456;
|
||||
TEST64 b;
|
||||
TEST64* c;
|
||||
|
||||
|
||||
b = foo(a);
|
||||
c = bar(&b);
|
||||
return *c;
|
||||
}
|
||||
|
||||
|
||||
:tests:
|
||||
:common: |
|
||||
void setUp(void) {}
|
||||
void tearDown(void) {}
|
||||
|
||||
|
||||
:units:
|
||||
- :pass: TRUE
|
||||
:should: 'handle a straightforward 64-bit series of calls'
|
||||
@@ -44,10 +44,10 @@
|
||||
TEST64 b = 0x5a5a5a5a5a5a5a5a;
|
||||
foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543210);
|
||||
bar_ExpectAndReturn(&a, &b);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX64(b, function_a());
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle a straightforward 64-bit series of calls with a failure'
|
||||
:code: |
|
||||
@@ -57,10 +57,10 @@
|
||||
TEST64 b = 0x5a5a5a5a5a5a5a5a;
|
||||
foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543211);
|
||||
bar_ExpectAndReturn(&a, &b);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX64(b, function_a());
|
||||
}
|
||||
|
||||
|
||||
- :pass: FALSE
|
||||
:should: 'handle a straightforward 64-bit series of calls returning a failure'
|
||||
:code: |
|
||||
@@ -70,8 +70,8 @@
|
||||
TEST64 b = 0x5a5a5a5a5a5a5a5a;
|
||||
foo_ExpectAndReturn(0x1234567890123456, 0x0987654321543210);
|
||||
bar_ExpectAndReturn(&a, &b);
|
||||
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX64(b+1, function_a());
|
||||
}
|
||||
|
||||
|
||||
...
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
---
|
||||
compiler:
|
||||
path: clang
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- '-c'
|
||||
- '-Wall'
|
||||
- '-Wextra'
|
||||
- '-Werror'
|
||||
- '-Wcast-qual'
|
||||
#- '-Wcast-qual'
|
||||
- '-Wconversion'
|
||||
- '-Wtautological-compare'
|
||||
#- '-Wtautological-pointer-compare'
|
||||
@@ -41,7 +41,7 @@ compiler:
|
||||
- '-Wno-invalid-token-paste'
|
||||
- '-fms-extensions'
|
||||
- '-fno-omit-frame-pointer'
|
||||
- '-ffloat-store'
|
||||
#- '-ffloat-store'
|
||||
- '-fno-common'
|
||||
- '-fstrict-aliasing'
|
||||
- '-std=gnu99'
|
||||
@@ -53,11 +53,11 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'test/system/test_compilation/'
|
||||
- 'test/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
compiler:
|
||||
path: gcc
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- '-c'
|
||||
- '-Wall'
|
||||
@@ -21,11 +21,11 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'test/system/test_compilation/'
|
||||
- 'test/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
compiler:
|
||||
path: gcc
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- '-c'
|
||||
- '-m64'
|
||||
@@ -20,11 +20,11 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'test/system/test_compilation/'
|
||||
- 'test/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
compiler:
|
||||
path: gcc
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- '-c'
|
||||
- '-Wall'
|
||||
@@ -21,11 +21,11 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'test/system/test_compilation/'
|
||||
- 'test/'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
@@ -1,10 +1,10 @@
|
||||
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 4.0\'
|
||||
compiler:
|
||||
path: [*tools_root, 'arm\bin\iccarm.exe']
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- --dlib_config
|
||||
- [*tools_root, 'arm\lib\dl4tptinl8n.h']
|
||||
@@ -38,11 +38,11 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'test/system/test_compilation/'
|
||||
- 'test\'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
@@ -1,10 +1,10 @@
|
||||
tools_root: &tools_root 'C:\Program Files\IAR Systems\Embedded Workbench 5.3\'
|
||||
compiler:
|
||||
path: [*tools_root, 'arm\bin\iccarm.exe']
|
||||
source_path: &systest_generated_path 'test/system/generated/'
|
||||
unit_tests_path: &unit_tests_path 'examples/test/'
|
||||
mocks_path: &systest_mocks_path 'test/system/generated/'
|
||||
build_path: &systest_build_path 'test/system/build/'
|
||||
source_path: &systest_generated_path './system/generated/'
|
||||
unit_tests_path: &unit_tests_path '../examples/test/'
|
||||
mocks_path: &systest_mocks_path './system/generated/'
|
||||
build_path: &systest_build_path './system/build/'
|
||||
options:
|
||||
- --dlib_config
|
||||
- [*tools_root, 'arm\inc\DLib_Config_Normal.h']
|
||||
@@ -36,12 +36,12 @@ compiler:
|
||||
- *systest_generated_path
|
||||
- *unit_tests_path
|
||||
- *systest_mocks_path
|
||||
- 'src/'
|
||||
- 'vendor/unity/src/'
|
||||
- 'vendor/c_exception/lib/'
|
||||
- 'iar\iar_v5\incIAR\'
|
||||
- 'test\system\test_compilation\'
|
||||
- 'test\'
|
||||
- '../src/'
|
||||
- '../vendor/unity/src/'
|
||||
- '../vendor/c_exception/lib/'
|
||||
- './system/test_compilation/'
|
||||
- './'
|
||||
- '.\iar\iar_v5\incIAR\'
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
+4
-8
@@ -15,14 +15,10 @@ end
|
||||
|
||||
def create_stub(funcs)
|
||||
stub = Class.new
|
||||
#if (RUBY_VERSION.split('.')[0].to_i >= 2)
|
||||
# funcs.each_pair {|k,v| stub.define_singleton_method(k) {|*unused| return v } }
|
||||
#else
|
||||
blob = "class << stub\n"
|
||||
funcs.each_pair {|k,v| blob += "def #{k.to_s}(unused=nil)\n #{v.inspect}\nend\n" }
|
||||
blob += "end"
|
||||
eval blob
|
||||
#end
|
||||
blob = "class << stub\n"
|
||||
funcs.each_pair {|k,v| blob += "def #{k.to_s}(unused=nil)\n #{v.inspect}\nend\n" }
|
||||
blob += "end"
|
||||
eval blob
|
||||
stub
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
||||
require 'cmock_config'
|
||||
require File.expand_path(File.dirname(__FILE__)) + '/../../lib/cmock_config'
|
||||
|
||||
|
||||
describe CMockConfig, "Verify CMockConfig Module" do
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# ==========================================
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
|
||||
require 'cmock_file_writer'
|
||||
require File.expand_path(File.dirname(__FILE__)) + '/../../lib/cmock_file_writer'
|
||||
|
||||
describe CMockFileWriter, "Verify CMockFileWriter Module" do
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user