1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-10-30 23:58:09 +02:00

test: fuzz

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2025-09-23 16:38:12 -03:00
parent 9c71861a6e
commit 295cda7af7
4 changed files with 35 additions and 7 deletions

View File

@@ -47,10 +47,15 @@ tasks:
cmds:
- scripts/fuzz.sh ./internal/tmpl 30s
fuzz:artifact:
cmds:
- scripts/fuzz.sh ./internal/artifact 30s
fuzz:
desc: Run fuzz tests
cmds:
- task: fuzz:tmpl
- task: fuzz:artifact
test:golden:update:
desc: Run all tests that write goldne files, updating the files.

View File

@@ -4,7 +4,6 @@ import (
"crypto/rand"
"os"
"path/filepath"
"strings"
"testing"
)
@@ -36,11 +35,9 @@ func FuzzChecksum(f *testing.F) {
"blake2s": true,
"sha224": true,
"sha384": true,
"sha3-256": true,
"sha3-512": true,
"sha3-224": true,
"sha3-384": true,
"sha3-256": true,
"sha3-384": true,
"sha3-512": true,
}
@@ -81,6 +78,28 @@ func FuzzChecksumLargeData(f *testing.F) {
t.Skip()
}
// Skip invalid algorithms
validAlgorithms := map[string]bool{
"sha256": true,
"md5": true,
"sha1": true,
"crc32": true,
"sha512": true,
"blake2b": true,
"blake2s": true,
"sha224": true,
"sha384": true,
"sha3-224": true,
"sha3-256": true,
"sha3-384": true,
"sha3-512": true,
}
// Only test with valid algorithms to avoid expected errors
if !validAlgorithms[algorithm] {
t.Skip()
}
// Generate random data of specified size
data := make([]byte, size)
if _, err := rand.Read(data); err != nil {

View File

@@ -0,0 +1,3 @@
go test fuzz v1
string("0")
int(50000)

View File

@@ -1,10 +1,11 @@
#!/bin/bash
pkg="$1"
timeout="$1"
timeout="$2"
grep "func Fuzz" "$pkg" |
cut -f1 -d'(' |
grep "func Fuzz" "$pkg"/*.go |
cut -f2 -d' ' |
cut -f1 -d'(' |
while read -r f; do
go test -fuzztime="$timeout" -fuzz="$f" "$pkg"/...
done
go test "$pkg"/...