Skip to content

UTBot cannot run test for old-style declared function #495

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

Closed
tyuldashev opened this issue Oct 14, 2022 · 0 comments · Fixed by #560
Closed

UTBot cannot run test for old-style declared function #495

tyuldashev opened this issue Oct 14, 2022 · 0 comments · Fixed by #560
Assignees
Labels
bug Something isn't working wrong generation Inadequate or empty test suite generated

Comments

@tyuldashev
Copy link
Collaborator

Description
In case 'C' method used 'old-style' declaration UTBot does not properly generate '.h' file and later cannot compile it for test execution.

To Reproduce
Steps to reproduce the behavior:

  • Generate code for following method
int sum(a, b)
int a;
int b;
{
    return a + b;
}
  • The generated tests in '.cpp' file looks pretty normal
  • Try to run generated tests

Expected behavior
Tests are supposed to be executed.

Actual behavior
Execution fails with error: "1 actions failed during building and running tests." . Log contains following errors:

In file included from /home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.cpp:5:
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:63:37: error: unknown type name 'a'
extern "C" int sum_src_old_syntax_c(a, b);
                                    ^
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:63:40: error: unknown type name 'b'
extern "C" int sum_src_old_syntax_c(a, b);
                                       ^
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:64:16: error: unknown type name 'a'
static int sum(a, b) {
               ^
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:64:19: error: unknown type name 'b'
static int sum(a, b) {
                  ^
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:65:29: error: use of undeclared identifier 'a'
return sum_src_old_syntax_c(a, b);
                            ^
/home/utbot/remote/SampleDocker2/tests/makefiles/src/../../../tests/src/old_syntax_dot_c_test.h:65:32: error: use of undeclared identifier 'b'
return sum_src_old_syntax_c(a, b);
                               ^
6 errors generated.
....

That's because generated header file for test has following declaration:

extern "C" int sum_src_old_syntax_c(a, b);
static int sum(a, b) {
return sum_src_old_syntax_c(a, b);
}

Additional information
Please note that even this syntax is not widely used in modern applications it could be found in old, but still active projects. For instance I found it in zlib library (2k Forks, 3.9k Start on GitHub, 40 commits in last month). So I believe that we should not put this case on hold.

@tyuldashev tyuldashev added bug Something isn't working wrong generation Inadequate or empty test suite generated labels Oct 14, 2022
@tyuldashev tyuldashev moved this to Todo in UTBot C/C++ Oct 14, 2022
@kichunya kichunya linked a pull request Dec 2, 2022 that will close this issue
Repository owner moved this from Todo to Done in UTBot C/C++ Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wrong generation Inadequate or empty test suite generated
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants