Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linking issue in the example project #117

Open
ivankvolik opened this issue Sep 8, 2022 · 1 comment
Open

Linking issue in the example project #117

ivankvolik opened this issue Sep 8, 2022 · 1 comment

Comments

@ivankvolik
Copy link

ivankvolik commented Sep 8, 2022

Hello people,

I've tried expanding the example project to play a bit with it, but i am getting a linking error, which i am not able to solve.

What have i added?

In the hardware_abstraction.h I've added the function declaration with this signature:
uint8_t IO_READ_CHARS(uint8_t* chars_array, uint8_t number_of_chars);

In driver.c I've added following function:

uint8_t testonia() {
    uint8_t buffer[100] = {0};
    uint8_t charNum = 0;
    uint8_t sumReturn  = HARDWARE_REV_A;

    sumReturn = IO_READ_CHARS(buffer, HARDWARE_REV_A);

    return buffer[3];
}

In driver.test.fff.cpp added the fake value func like so:
FAKE_VALUE_FUNC(uint8_t, IO_READ_CHARS, uint8_t*, uint8_t);

declared a custom fake function:

uint8_t cust_fake(uint8_t* chars, uint8_t number) {
    chars[0] = 1u;
    chars[1] = 2u;
    chars[2] = 5u;
    chars[3] = 100u;

    return 3u;
}

And my test is in the following listing:

TEST_F(DriverTestFFF, Some_fake_test) {
    uint8_t ret = 0;
    IO_READ_CHARS_fake.custom_fake = cust_fake;

    IO_READ_CHARS_fake.return_val = 1;

    ret = testonia();

    ASSERT_EQ(ret, 100u);
}

The error I get on linking is that there is an undefined reference to IO_READ_CHARS.

FAILED: examples/driver_testing/driver_test 
: && /usr/bin/c++   examples/driver_testing/CMakeFiles/driver_test.dir/src/driver.c.o examples/driver_testing/CMakeFiles/driver_test.dir/src/driver.test.cpp.o -o examples/driver_testing/driver_test  gtest/libgtest.a  -lpthread  -static-libstdc++ && :
/usr/bin/ld: examples/driver_testing/CMakeFiles/driver_test.dir/src/driver.c.o: in function `testonia':
driver.c:(.text+0xcf): undefined reference to `IO_READ_CHARS'

Can somebody please tell me what did i do wrong?

@ivankvolik
Copy link
Author

UPDATE: When I comment this line in testonia function, the linking passes and everything is executed. So I might have screwed something up in naming, or forgot to link the function somewhere.

sumReturn = IO_READ_CHARS(buffer, HARDWARE_REV_A);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant