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

Add mutator unittests #31

Merged
merged 3 commits into from Feb 7, 2020
Merged

Conversation

@gerph
Copy link
Contributor

gerph commented Jan 12, 2020

This PR requires PR #26,. #27, #28, #29 and #30 to be merged first.

This change adds unit tests for some of the mutators, and addresses some issues that were found when the mutators were being tested.

The mutators are tested with the 'unittest' level of testing, meaning that they only invoke the unit of the module, and should not be affected by anything outside that module. As such they're very limited. Although they test only a couple of cases for each mutator they have found problems because the operation they were expected to perform hasn't worked.

This PR comprises 3 changes:

  • Adding the unit tests, and fixing a few issues found along the way.
  • Updating the Makefile to use these unit tests.
  • Adding an annotation to each of the testing files to describe where they fit into the testing of the product.

The latter of these could be independant, or dropped; it has been useful to me.

@yevgenypats
Copy link
Contributor

yevgenypats commented Jan 18, 2020

I think this PR can be moved from draft status as this the dependent PR were merged

@gerph
Copy link
Contributor Author

gerph commented Jan 18, 2020

The mutators that this tests are only in PR#26, which you just closed.
Sorry, I failed to mention that in the PR description.

@yevgenypats yevgenypats marked this pull request as ready for review Jan 19, 2020
@yevgenypats
Copy link
Contributor

yevgenypats commented Jan 19, 2020

I merged PR #26. but there are some conflicts now. can you please fix those? thx!

gerph added 3 commits Jan 11, 2020
The mutators weren't being tested so we only had to assume that they
were doing the right thing. In my own tests I saw a lot of input that
had NUL bytes in it, so I'm pretty sure that some of the mutations were
not doing the right thing. With these tests, the copy method was found
to have poorly named parameters.

The pattern it's using is copy(a, b, posa, posb, lena, lenb) (where lena
and lenb can be omitted). The 'a' parameter is where the update will
take place, and the 'b' parameter is where the copy originates. However,
the first parameter was called 'src' and the second parameter 'dst',
which is the precise opposite of the expectation. The naming of the
parameters was kept consistent (a named as src, despite being the
destination) with the other named parameters and within the function.

This has been corrected, and with the correct naming, it became obvious
that the insert, remove and duplicate functions were not working as
intended.

It is unclear what the difference is intended to be for Duplicate and
Copy bytes - I have 'fixed' Duplicate, but this means that it now works
identically to Copy, so it's not clear to me what's meant to be done
there.
Now that we have unit tests, these can be invoked by the Makefile.
The test files have now been updated to include annotations, in the
file prologue comment, which describe the test and its place in the
testing environment.

These are just a convention that I've used previously, but they help
to focus anyone doing testing on describing where they fit into the
testing of the system. Such descriptions make it obvious when reviewed
where there are gaps in testing.
@gerph gerph force-pushed the gerph:add-mutator-unittests branch from b1d06fb to 410fa8a Jan 19, 2020
@gerph
Copy link
Contributor Author

gerph commented Jan 19, 2020

Done, making this quite a small PR.

@gerph gerph changed the title WIP Add mutator unittests Add mutator unittests Jan 19, 2020
@yevgenypats yevgenypats merged commit 98fd2fd into fuzzitdev:master Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.