1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 00:15:59 +01:00

75 Commits

Author SHA1 Message Date
Daniel King
a9cb716818 Fix unreachable return statements. (#109)
* Fixed some return statements that were generated unconditionally,
  leading to unreachable return statements in some cases.
* Regenerated fff.h
2023-05-20 09:43:17 +10:00
Yuval Peress
2cce6b0fc8 Add support for custom_fake function signatures
Update the generator to include a check for CUSTOM_FFF_FUNCTION_TEMPLATE.
If not present it will default to the C style function pointer.
Alternatively, developers may define their own version of the template to
leverage std::function or pw:Function (from the embedded Pigweed library).

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-28 09:11:40 -06:00
Yuval Peress
2eb067e5a1 Migrate build to CMake and standard github workflows
Replace makefiles with CMakeLists.txt. This will allow for IDE and
platform agnostic builds of FFF.

Update the CI for FFF to use github workflows which don't depend on MS VC.
The workflow added will verify the pull requests sent to master buy
running 'buildandtest' which mirrors the developer workflow.

Signed-off-by: Yuval Peress <peress@google.com>
2022-08-05 11:48:54 -06:00
Henning Rehn
b9f11dcd8a Handle return value history for custom fakes 2019-08-21 12:37:58 +02:00
James Fraser
0b9e9f5064 Squashed commit of the following:
commit e5a5749971eb9274679699020a54c91d4053ed79
Author: James Fraser <wulfgar.pro@gmail.com>
Date:   Sun Feb 3 19:57:31 2019 +1100

    PR #47: Minor review fixes to tests files.

commit e9f11b9ec8de8f8d1f0de7b6959c575e15894526
Author: James Fraser <wulfgar.pro@gmail.com>
Date:   Sun Feb 3 19:57:04 2019 +1100

    PR #47: Minor review fixes.

commit 0a7fbeceec
Author: Pauli Salmenrinne <pauli.salmenrinne@pexraytech.com>
Date:   Tue Jan 22 15:11:10 2019 +0200

    Add example for the weak linking

commit 647737304d
Author: susundberg <susundberg@gmail.com>
Date:   Wed Mar 21 13:14:05 2018 +0200

    Add "FFF_FUNCTION_ATTRIBUTES" definition that can be used to declare attributes for functions. More specifically, allow __weak__ attribute.
2019-02-03 20:23:52 +11:00
James Fraser
fe54d15393 Merge branch 'no_extern_c' of https://github.com/zrax/fff into zrax-no_extern_c 2018-12-14 19:56:22 +11:00
Alain
b76c7c7168 Custom return value delegate sequences for variadic functions (#63)
* Custom return value delegate sequences for variadic functions
* Added unit tests for variadic functions custom return value delegate sequences
* Fixes in code style
* Variadic functions custom delegates also tested in C++
* Fixed some compilation warnings
* Added test for variadic function custom delegates sequence reset
* Updated documentation with variadic functions custom delegate sequences
* Update README.md
* Minor style changes.

Thank you very much @oliviera9!
2018-12-05 23:36:32 +11:00
James Fraser
1c981604a1 Fixed erroneous change. 2018-11-16 20:25:10 +11:00
James Fraser
d0a214c584 Fixed indentation style. 2018-11-16 20:14:22 +11:00
James Fraser
a31a9ee38c Added support for specifying calling conventions. 2018-11-16 02:01:11 +11:00
Kate Hart
86c5e44614 Clear fff.call_history when calling FFF_RESET_HISTORY 2018-10-11 21:31:27 -07:00
Michael Hansen
b8f9e65387 Remove extern "C" from fake declarations.
Assuming your C interfaces are appropriately wrapped for C++, it is
unnecessary to force the fakes to be declared extern "C", and doing so
causes any functions declared with C++ linkage to be impossible to fake
due to the conflicting linkage declarations.
2018-05-09 13:26:44 -07:00
usr42
d9082e8d17 Merge remote-tracking branch 'original/master' into refactorings 2018-01-30 21:10:17 +01:00
Mike Long
953ff07a7d Merge pull request #35 from alvarez86/return_val_history
Return val history
2018-01-28 17:36:18 +00:00
Mike Long
ffde0537d8 Merge pull request #20 from usr42/master
Fix for issue 13: Add function prototype to DECLARE_* macro
2018-01-28 17:35:58 +00:00
Mike Long
2c28c14e83 Merge branch 'master' into return_val_history 2018-01-28 17:24:54 +00:00
usr42
15408ba2a4 Merge remote-tracking branch 'original/master' into refactorings 2018-01-10 08:38:53 +01:00
snak3xe
eca3ccbe6c Fix fakegen.rb C header generator for M macro compatibility. 2017-12-14 22:52:27 +01:00
Paulo Antonio Alvarez
89ea0e10d8 Return values saved in history
On some contexts, we need to call one function to free some resource
allocated by another function based on the return value of the second
function. For example, every time pthread_mutex_trylock suceeds, you
need to unlock it, and only in those cases. While this could be done
with the return value sequence, it does not really work for a sequence
of custom fakes. Now we save the return values in the member
return_val_history, which works pretty much like arg_history, only
for the return values.
2017-08-15 23:36:49 -03:00
usr42
3ec2c2b326 Merge remote-tracking branch 'upstream/master' into refactorings 2017-02-04 12:44:38 +01:00
usr42
248c7906b4 Merge remote-tracking branch 'upstream/master' 2017-02-04 12:34:55 +01:00
Mike Long
74c07a8f66 Merge pull request #27 from usr42/issue26
Fix issue 26: Use void as parameter when no parameter exists
2017-02-03 21:02:49 +01:00
usr42
88e6ac34d1 Use void as parameter for FUNCNAME##_reset
FUNCNAME##_reset(void) instead of FUNCNAME##_reset()
2017-01-30 15:03:39 +01:00
usr42
3d0919b6e0 Rename putdml to putd_backslash 2017-01-26 20:47:06 +01:00
usr42
4ccfd2681e Remove dead code 2017-01-26 20:43:12 +01:00
usr42
7888b6e9c8 Use void as parameter when no parameter exists 2017-01-26 17:35:11 +01:00
usr42
91e796a784 Remove brackets when calling putdml 2017-01-26 17:15:07 +01:00
usr42
985fbe374e Replace empty putd with puts 2017-01-26 16:43:54 +01:00
usr42
49c814ff34 Add putdml
putdml is a multiline putd which adds a \ at the end of the generated macro
2017-01-26 16:40:08 +01:00
usr42
f6fd3cf5dc indent funct with block instead of pushd and popd 2017-01-26 15:47:16 +01:00
usr42
03f61f8e9f Use function pointer for call_history 2017-01-24 21:03:09 +01:00
usr42
d2992fef8f Fix issue13: Add function prototype to DECLARE_* 2017-01-21 20:06:27 +01:00
usr42
190fa67039 Fix FAKE_VALUE_FUNC with 20 parameters 2017-01-16 12:00:24 +01:00
usr42
0ec5f99ef8 Refactor output_macro_counting_shortcuts 2017-01-14 23:23:07 +01:00
mj
0cf75a229e Added auto counting of parameters for declaration and definition of fake functions for global use. Adjusted unit tests of global functions 2016-12-18 15:03:15 +01:00
mj
daff1fb430 added helper for generating argument sequences 2016-12-18 11:25:11 +01:00
Mike Long
ff40273dba Merge pull request #16 from CiderMan/master
Fix for issue 8
2016-09-25 19:32:47 +01:00
Steve Hill
df0dc5deea Added missing #include, built and tested 2016-09-23 19:25:30 +01:00
Paulo Antonio Alvarez
845a8e2549 Support for custom fake function sequences (non-variadic functions)
This makes it possible to set a sequence of custom fakes for a function
using the macro SET_CUSTOM_FAKE_SEQ. Very useful for functions with out
parameters. Now we don't have to count the number of calls to implement
different behaviours on custom fakes.
2016-09-14 01:33:16 -03:00
Rubio R. C. Terra
8c7bd6912f Added macro counting shortcuts for variadic fakes 2016-06-07 10:01:31 -03:00
Rubio R. C. Terra
fa15147055 Added custom fake support for variadic functions
Custom fake support for variadic functions was limited. The variable
parameters were not passed to the custom fake.

Now a va_list is passed to the custom fake, so it is possible to access
all the arguments. For instance, a custom fake for fprintf() could call
the real fprintf() like this:

int fprintf_custom(FILE *stream, const char *format, va_list ap) {
  if (fprintf0_fake.return_val < 0) // should we fail?
    return fprintf0_fake.return_val;
  return vfprintf(stream, format, ap);
}
2016-06-07 10:01:26 -03:00
Steve Hill
63fe49c960 Change (END_)EXTERN_C to have FFF_ prefix 2016-04-08 12:21:01 +01:00
Steve Hill
701e5c45fa Changed comment style to give strict C89 compatibility 2016-04-08 12:16:15 +01:00
Mike Long
c38a1343a4 Add support for up to 20 arguments 2013-06-26 07:43:25 +08:00
Mike Long
0f9f1d939d Merged varargs support with const support 2013-06-23 22:22:34 +08:00
Micha Hoiting
ef62856fc3 Implement minimal support for varargs 2012-11-09 01:33:10 +01:00
Micha Hoiting
3cf610ea97 Add support for const parameters in fakes (C only) 2012-11-08 23:14:02 +01:00
Micha Hoiting
cacd5f5459 Add vararg support (Work In Progress) 2012-11-07 23:14:04 +01:00
Mike Long
4edb01b8f9 Add support to return the return value from custom fakes when it is a non-void function 2012-07-06 01:36:52 +08:00
Mike Long
480c88e1af Added helper macro to generate fake reset function 2012-05-29 08:33:23 +08:00