Skip to content

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

@tyuldashev

Description

@tyuldashev

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingregressionRegressionverifiedBug fix is verified

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions