Comments (7)
Here is more information. I added -E to the g++ compile and looked at the preprocessed output. Searching on getpid - I found the following is the FFF fake for getpid - and sure enough it is wrapped with extern "C" - yet I am running this on a CPP compiler and I made sure __cplusplus is set. So why is the fake for getpid wrapped with extern C???? or is that the design that all fakes are based on C? If so how do I make sure that the prototype declaration for the item (in this case getpid from unistd.h) is C-ized?
_extern "C"{ typedef struct getpid_Fake { unsigned int call_count; unsigned int arg_history_len; unsigned int arg_histories_dropped; pid_t return_val; int return_val_seq_len; int return_val_seq_idx; pid_t * return_val_seq; pid_t return_val_history[(50u)]; int custom_fake_seq_len; int custom_fake_seq_idx; pid_t(*custom_fake)(void); pid_t(**custom_fake_seq)(void); } getpid_Fake; extern getpid_Fake getpid_fake; void getpid_reset(void); pid_t getp ...........
from fff.
Hi Todd,
Could you send me a cut down way to reproduce so I can investigate?
Thanks,
Mike
from fff.
Sorry for the size of this - but in order to make this work for you without a lot of trouble - I precompiled, google test and the objects are left in this zip.
ciscoduplication.tgz.zip
Unzip then CD to stub.
run the makefile and it should cd to _build folder and run the c++ command that fails.
from fff.
I am not going to close the issue - but we have decided to go a different direction (this error happened when we evaluated using Meson/Ninja instead of makefiles - and it brought to light that we had a few poorly written tests - which in turn brought to light that we have not been keeping up with the latest FFF sources.) So this will be a non-issue - if you want to close the issue you can - but you can keep it open if perhaps you think this might reveal a real issue.
from fff.
Hi @tlawork - Sorry for the slow response, I'm traveling a lot these days...
Can you confirm that you can use the latest fff.h
? Or by different direction, do you mean you have found a different testing solution?
Thanks!
from fff.
by using the latest fff.h I get an error because the C++ test routine (specifically gtest) includes unistd.h as a c++ module, but FFF is faking it as a C module and the linker complains. We are trying to fake out the function getpid() which is defined in unistd.h
By different direction - we are dropping our meson/ninja investigation and it was changing the build system that prompted this error - we do not get this error when using the older version of FFF so we are simply going to stick with the older version for now - so we are still on board using FFF - its very effective.
TODDL (Cisco Systems)
from fff.
@tlawork please try the latest version of fff; a lot of the extern C mess has gone.
I managed to fake getpid
like so:
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#include "fff.h"
DEFINE_FFF_GLOBALS;
FAKE_VALUE_FUNC(pid_t, getpid);
pid_t custom_getpid()
{
return 0xdeadbeef;
}
int main(void) {
getpid_fake.custom_fake = custom_getpid;
pid_t pid = getpid();
assert(getpid_fake.call_count == 1);
assert(pid == 0xdeadbeef);
return 0;
}
from fff.
Related Issues (20)
- fatal error: 'tr1/tuple' file not found HOT 1
- SET_RETURN_SEQ should reset return_val_seq_idx HOT 1
- Can FFF be used to generate the actual fake implementation?
- Argument history storing derefenced pointers HOT 1
- warning: ISO C99 requires at least one argument for the "..." in a variadic macro HOT 1
- Is it possible to mock static functions? HOT 1
- #pragma pack(1) breaks Function Return Value Sequences HOT 1
- How to install and to use? HOT 3
- Allow support for std::function as the `custom_fake` type HOT 1
- Linking issue in the example project HOT 1
- fake.callcount is always 0 when reuse a fake across multiple test-suites HOT 5
- FFF generated reset functions have mangled names HOT 2
- C++ Support for FFF Framework HOT 1
- Question: Releases and project maintenance
- Mocking static methods of the class HOT 3
- Is there a forum or fff community page for answering questions? HOT 2
- Automatically generate mocks: fff-mock-gen HOT 1
- include fff.h once
- Alternating fff with real functions to access the hardware HOT 2
- Use of fff to mock c++ class member functions HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fff.