Skip to content

Conversation

@Markoutte
Copy link
Collaborator

@Markoutte Markoutte commented May 27, 2022

Description

List of changes:

  • Randomize fuzzer inputs
  • Limit fuzzing attempts
  • Mutate primitive values according to comparison operations
  • Mutate string constants
  • Move fuzz-relative code out of UtBotSymbolicEngine.kt
  • Test added

Type of Change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • org.utbot.framework.plugin.api.CombinationsTest
  • org.utbot.framework.plugin.api.ModelProviderTest

Manual Scenario

  1. Disable engine.traverse() function by commenting it in UtBotTestCaseGenerator:185
  2. Build and run
  3. Create a function as listed below
  4. Run UtBot and check that it creates tests with all branches covered and the tests have names which end with word "FuzzerN"
    public String foo(int a) {
        if (a < -2.0) {
            return "-1";
        }
        if (a > 5) {
            return "-2";
        }
        if (a == 3) {
            return "-3";
        }
        if (4L < a) {
            return "-4";
        }
        return "0";
    }

Checklist:

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • Tests that prove my change is effective
  • All tests pass locally with my changes

@Markoutte Markoutte requested a review from denis-fokin May 27, 2022 08:38
@Markoutte Markoutte changed the title Fuzzer improvements: Fuzzer improvements May 27, 2022
* Randomize fuzzer inputs
* Limit fuzzing attempts
* Mutate primitive values according to comparison operations
* Mutate string constants
* Move fuzz-relative code out of UtBotSymbolicEngine.kt
* Test added
@Markoutte Markoutte linked an issue May 30, 2022 that may be closed by this pull request
return emptyList()
}

@Suppress("UNUSED_PARAMETER")
Copy link
Collaborator

@denis-fokin denis-fokin May 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add explanation why the parameters are unused, may be it is worth to introduce a default value.

import kotlin.collections.HashMap
import kotlin.reflect.KClass

open class SimpleModelProvider(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion simple is too general term. Could you pick a more specific name? And add some documentation to the class.

.iterator()
val combinations = Combinations(*lists.map { it.size }.toIntArray())
val sequence = if (random != null) {
// todo create lazy random algo for this because this method can cause OOME even we take only one value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even we -> even if we

* Rename SimpleModelProvider with more narrow name
* Use interface implementation instead of function with concrete list of parameter
* Fix typos
@Markoutte Markoutte merged commit 0d6142f into main May 31, 2022
@Markoutte Markoutte deleted the pelevin/fuzzer branch May 31, 2022 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart fuzzer for UTBot

3 participants