COVESA / vsomeip

An implementation of Scalable service-Oriented MiddlewarE over IP
Mozilla Public License 2.0
1.02k stars 651 forks source link

Compilation of tests is failing #147

Closed shubhu1006 closed 1 year ago

shubhu1006 commented 3 years ago

Hi, I am trying to compile tests in vsomeip, but it is facing few issues:-

  1. Required google test framework version 1.7.0 is not available, link specified in user guide is broken. So i downloaded version 1.10.x. Will it work?
  2. When i try to compile using version 1.10 it is not able to find the files :- vsome_error
  3. I think issue is with the path, so i tried manually to edit the path but after that i faced following issue:- vsome_error2
lutzbichler commented 3 years ago

1) Yes, it does work with gtest v1.10.0

2/3) This looks as if you did not set some requires switches when configuring. Please post your cmake call.

shubhu1006 commented 3 years ago

Here is my cmakelist file. CMakeLists.txt

lutzbichler commented 3 years ago

Please post how you call cmake or the full CMakeOutput.log.

shubhu1006 commented 3 years ago

cd vsomeip/test/ mkdir build cd build cmake ..

CMakeOutput.log

lutzbichler commented 3 years ago

This not the correct way to build the tests. Within vsomeip/build do:

export GTEST_ROOT= cmake -DTEST_IP_MASTER= -DTEST_IP_SLAVE= .. make && make build_tests

There are additional defines for specific tests (TEST_IP_SLAVE_SECOND, TEST_UID, TEST_GID).

lutzbichler commented 3 years ago

Please log what you exactly do on your console and which error messages are logged. Does your build directory have the same parent directoy than the test directory?

shubhu1006 commented 3 years ago

Hi @lutzbichler I have changed the build directory now, earlier i was compiling from /test/build now i changed i to vsomeip/build . I ran the following commands as shown in pic below:- vsome_error3 It seems it is not configured properly yet. Still i tried to build and got error related to build_tests, as in makefile it is not able to find rule for build_tests (if you see in the last) vsome_erro4

lutzbichler commented 3 years ago

It is not happy with the directory that GTEST_ROOT points to. Therefore the Makefile for the tests is no generated.

shubhu1006 commented 3 years ago

Hi @lutzbichler , I dont know whats wrong with the path because echoing results in path correctly vsome_error5

When i put hardcode path (set (GTEST_ROOT /home/shubh/googletest) ) in Cmake file it is working correct

shubhu1006 commented 3 years ago

I found issue with first if condition

if (NOT GTEST_ROOT)
    if (DEFINED ENV{GTEST_ROOT})
        set(GTEST_ROOT $ENV{GTEST_ROOT})
    else()
        set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.")
    endif()
endif()

Document says :

if(NOT condition) True if the condition is not true.

So here condition = GTEST_ROOT will be true always and hence first if will result in false and it will not execute inside if condition. After commenting this if, it is working

goncaloalmeida commented 1 year ago

@shubhu1006 this problem still occurs?

goncaloalmeida commented 1 year ago

Closing the ticket -> if the problem still occurs please reopen the ticket.

shubhu1006 commented 1 year ago

I found issue with first if condition

if (NOT GTEST_ROOT)
    if (DEFINED ENV{GTEST_ROOT})
        set(GTEST_ROOT $ENV{GTEST_ROOT})
    else()
        set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.")
    endif()
endif()

Document says :

if(NOT condition) True if the condition is not true.

So here condition = GTEST_ROOT will be true always and hence first if will result in false and it will not execute inside if condition. After commenting this if, it is working

Hi @goncaloalmeida, I have already pointed where actually issue is. It will be great if you can confirm the same.

joao-d commented 1 year ago

The first if condition, if (NOT GTEST_ROOT), will always be false because GTEST_ROOT is already defined as an empty string at this point in the CMake script.  To check whether GTEST_ROOT is not defined, it can be use the NOT DEFINED operator instead of NOT:  if (NOT DEFINED GTEST_ROOT)      if (DEFINED ENV{GTEST_ROOT})          set(GTEST_ROOT $ENV{GTEST_ROOT})      else()          set(GTEST_ROOT "n/a" CACHE STRING "Path to root folder of googletest. Must be set for building the tests.")      endif()  endif()    This will only enter the if block if GTEST_ROOT is not defined at all, whether it is an empty string or not  Do you want to create a PR to make this change?