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

Engine doesn't cover branch instanceof String #957

Open
SBOne-Kenobi opened this issue Sep 19, 2022 · 2 comments · May be fixed by #964
Open

Engine doesn't cover branch instanceof String #957

SBOne-Kenobi opened this issue Sep 19, 2022 · 2 comments · May be fixed by #964
Assignees
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug

Comments

@SBOne-Kenobi
Copy link
Collaborator

SBOne-Kenobi commented Sep 19, 2022

Description

Engine generates 1 execution for this method, but doesn't cover throw statement.

public static void charSeqIsNotString(CharSequence cs) {
    if (cs instanceof String) {
        throw new IllegalStateException("CharSequence must be not String!");
    }
}

To Reproduce

Steps to reproduce the behavior:

Steps to reproduce the behavior:

  1. Create the mentioned method
  2. Make sure that fuzzing turned of (Tools -> UnitTestBot -> Code analysis, toggle must be in the rightest position)
  3. Use plugin to generate tests
  4. Open the generated test
  5. Run tests with coverage

Expected behavior

2 tests are supposed to be generated witch cover all statements.

Actual behavior

1 test generated that don't covers throw statement.

Visual proofs (screenshots, logs, images)

image

Additional context

This bug is a part of issue #820

@SBOne-Kenobi SBOne-Kenobi added ctg-bug Issue is a bug comp-symbolic-engine Issue is related to the symbolic execution engine labels Sep 19, 2022
@SBOne-Kenobi SBOne-Kenobi self-assigned this Sep 19, 2022
@SBOne-Kenobi SBOne-Kenobi linked a pull request Sep 19, 2022 that will close this issue
7 tasks
@alisevych
Copy link
Member

Now one test is generating that covers instanceOf branch.
@CaelmBleidd Can you please advise if symbolic engine should cover the case that condition is false?

@CaelmBleidd
Copy link
Member

If the engine covers only one branch where an object is of String type and doesn't cover other subtypes of CharSequence, it is OK (at least, it is known behaviour). It happens because all CharSequence are treated as strings, therefore, the negation of this makes all the branches with it unreachable.

So, we know about this behaviour, it is not what we want in the future, but it is too complicated to fix for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants