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

'write_to_file' added to every test even it's not about IO #499

Closed
tyuldashev opened this issue Oct 18, 2022 · 1 comment · Fixed by #524
Closed

'write_to_file' added to every test even it's not about IO #499

tyuldashev opened this issue Oct 18, 2022 · 1 comment · Fixed by #524
Assignees
Labels
bug Something isn't working regression Regression verified Bug fix is verified

Comments

@tyuldashev
Copy link
Collaborator

Description
Even function under test doesn't perform any operations on files UTBot still adds test input initialization to the tests

To Reproduce
Generate test for something simple like:

int div(int a, int b) {
  return a / b;
}

Expected behavior
Generated tests does not involve interactions with file system

Actual behavior
Generated tests contain section which initialize file as test input:

TEST(regression, div_test_1)
{
    write_to_file("../../../tests/src/A", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
    write_to_file("../../../tests/src/B", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");
    write_to_file("../../../tests/src/C", "\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0""\0");

    int actual = div2(0, 1);
    EXPECT_EQ(0, actual);
}

Additional information
UTBot always create three file no matter how many is actually needed. In case we implement logic that count number of parameters of FILE type and create only required number of files then it should resolve problem described above and issue with writing more files than actually required.

@tyuldashev tyuldashev added bug Something isn't working regression Regression labels Oct 18, 2022
@tyuldashev tyuldashev moved this to Todo in UTBot C/C++ Oct 18, 2022
@sava-cska sava-cska linked a pull request Nov 3, 2022 that will close this issue
Repository owner moved this from Todo to Done in UTBot C/C++ Nov 28, 2022
@tyuldashev
Copy link
Collaborator Author

Tested with 2022.11.307

@tyuldashev tyuldashev added the verified Bug fix is verified label Nov 29, 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 regression Regression verified Bug fix is verified
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants