UnitTestBot / UTBotCpp

Tool that generates unit test by C/C++ source code, trying to reach all branches and maximize code coverage
Apache License 2.0
158 stars 27 forks source link

Trying to extern variables from wrapper files without linking with them #613

Closed IDKWNTCMF closed 1 year ago

IDKWNTCMF commented 1 year ago

Description Generated test headers extern wrapped functions and variables from generated wrapper files. However when Use stubs option is selected, sometimes we do not link with the corresponding wrapper file, so this results in error: undefined reference to {wrapper_name}.

To Reproduce Steps to reproduce the behavior:

  1. Generate tests for curl project (file lib\timediff.c) with selected option Use stubs and curl target
  2. Try to run generated tests

Expected behavior Tests are supposed to be executed successfully.

Actual behavior An error test is generated with information about errors.

Visual proofs (screenshots, logs)

/home/utbot/curl/utbot_tests/makefiles/lib/../../../utbot_tests/lib/timediff_dot_c_test.h:687: error: undefined reference to 'curlx_mstotv_lib_timediff_c'
/home/utbot/curl/utbot_tests/makefiles/lib/../../../utbot_tests/lib/timediff_dot_c_test.h:691: error: undefined reference to 'curlx_tvtoms_lib_timediff_c'
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)