Skip to content

Conversation

@Markoutte
Copy link
Collaborator

Description

Fuzzing platform should generate reproducible tests on each run with new seeded random object and be cancelable by coroutine context. This PR fixes these problems and adds tests for core functions of fuzzing platform.

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Regression and integration tests

New tests have been added:

  • org.utbot.fuzzing.JavaFuzzingTest
  • org.utbot.fuzzing.FuzzerSmokeTest
  • org.utbot.fuzzing.ProvidersTest

Manual Scenario

Tests now have to be reproducible. It means, that fuzzing with more time to run has all those tests that fuzzing with less time to run has. Try to run fuzzing on org.utbot.fuzzing.samples.Strings#test(String s) with different timeouts.

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
  • New tests have been added
  • All tests pass locally with my changes

Comment on lines +60 to +86
Assertions.assertEquals(1, p1.generate(description, Unit).count())
Assertions.assertEquals(1, (p1.generate(description, Unit).first() as Seed.Simple).value)

Assertions.assertEquals(1, p2.generate(description, Unit).count())
Assertions.assertEquals(2, (p2.generate(description, Unit).first() as Seed.Simple).value)

Assertions.assertEquals(1, p3.generate(description, Unit).count())
Assertions.assertEquals(3, (p3.generate(description, Unit).first() as Seed.Simple).value)

Assertions.assertEquals(1, p4.generate(description, Unit).count())
Assertions.assertEquals(4, (p4.generate(description, Unit).first() as Seed.Simple).value)

Assertions.assertEquals(2, m1.generate(description, Unit).count())
Assertions.assertEquals(1, (m1.generate(description, Unit).first() as Seed.Simple).value)
Assertions.assertEquals(2, (m1.generate(description, Unit).drop(1).first() as Seed.Simple).value)

Assertions.assertEquals(2, m2.generate(description, Unit).count())
Assertions.assertEquals(3, (m2.generate(description, Unit).first() as Seed.Simple).value)
Assertions.assertEquals(4, (m2.generate(description, Unit).drop(1).first() as Seed.Simple).value)

Assertions.assertEquals(4, m3.generate(description, Unit).count())
Assertions.assertEquals(1, (m3.generate(description, Unit).first() as Seed.Simple).value)
Assertions.assertEquals(2, (m3.generate(description, Unit).drop(1).first() as Seed.Simple).value)
Assertions.assertEquals(3, (m3.generate(description, Unit).drop(2).first() as Seed.Simple).value)
Assertions.assertEquals(4, (m3.generate(description, Unit).drop(3).first() as Seed.Simple).value)

Assertions.assertEquals(4, m4.generate(description, Unit).count())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not to import assertEquals (here and in some other files)?

Comment on lines +16 to +19
@Test
fun `string generates same values`() {
fun collect(): List<String> {
return runBlockingWithContext {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just thoughts: if we want reproducibility in many/most/all cases, maybe we should find a more general way to check it? E.g., introduce something like

fun <T> getReproducibleResults(generator: () -> T): T {
    val probe1 = generator()
    val probe2 = generator()
    assertEquals(probe1, probe2)
    return probe1
}

Then we can wrap calls to fuzzer in tests in such function and process results as usual. (Just an example, there are lots of other ways to check reproducibility more general).

@Markoutte Markoutte merged commit e0666fc into main Dec 15, 2022
@Markoutte Markoutte deleted the pelevin/fuzzing_tests branch December 15, 2022 04:29
tamarinvs19 pushed a commit that referenced this pull request Dec 21, 2022
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.

4 participants