Skip to content

fuzz: Adds a simple fuzz testing harness #69

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

Closed
wants to merge 1 commit into from

Conversation

nathaniel-brough
Copy link

This harness attempts to find any bugs in the simd implementation of the sha256sum tooling by testing against the stdlib implementation.

This harness attempts to find any bugs in the simd
implementation of the sha256sum tooling by testing
against the stdlib implementation.
Copy link
Contributor

@klauspost klauspost left a comment

Choose a reason for hiding this comment

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

Nice test to have.

"testing"
)

func Equal(a, b []byte) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove and use bytes.Equal.

Comment on lines +29 to +31
if !Equal(stdShaWriter.Sum(nil), simdShaWriter.Sum(nil)) {
t.Fatalf("Expected equality between stdlib sha256 and simd sha256, but got different shas")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if !Equal(stdShaWriter.Sum(nil), simdShaWriter.Sum(nil)) {
t.Fatalf("Expected equality between stdlib sha256 and simd sha256, but got different shas")
}
want, got := stdShaWriter.Sum(nil), simdShaWriter.Sum(nil)
if !bytes.Equal(want, got) {
t.Fatalf("want %x, got %x", want, got)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a Reset and re-do the calculation after a reset.

@klauspost
Copy link
Contributor

Closing after 1 year.

@klauspost klauspost closed this Apr 29, 2024
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.

2 participants