Code Monkey home page Code Monkey logo

Comments (7)

tlawork avatar tlawork commented on May 10, 2024

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.

meekrosoft avatar meekrosoft commented on May 10, 2024

Hi Todd,
Could you send me a cut down way to reproduce so I can investigate?
Thanks,
Mike

from fff.

tlawork avatar tlawork commented on May 10, 2024

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.

tlawork avatar tlawork commented on May 10, 2024

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.

meekrosoft avatar meekrosoft commented on May 10, 2024

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.

tlawork avatar tlawork commented on May 10, 2024

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.

wulfgarpro avatar wulfgarpro commented on May 10, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.