UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

`fclose()` significantly reduce code coverage

Open tyuldashev opened this issue 3 years ago • 0 comments

Description In case function opens the file and then closes it UTBot generates only one trivial test case comparing to situation when function only opens file.

To Reproduce

  • Generate tests for following code sample:
int read_first_char(char * name) {
    FILE *file = fopen(name, "r");
    if (file == NULL) return -1;
    int c = fgetc(file);
    // fclose(file);

    if (c == 'A') return 'A';
    if (c == 'B') return 'B';
    return '0';
}
  • Note that UTBot generates quite many tests, including tests with valid symbolic files: A, B. Which cover whole function with exception of last line (return 0;).
  • Uncomment line with fclose(file);
  • Generate tests again.

Expected behavior Similar set of tests are generated

Actual behavior UTBot generates only one test, which pass empty line as file name an so covers only first two lines of function.

Additional context Generated tests fail because of incorrect file name comparison, see #463 for details

tyuldashev avatar Oct 20 '22 07:10 tyuldashev