fuzz_test.go 749 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package archive
  2. import (
  3. "bytes"
  4. "testing"
  5. fuzz "github.com/AdaLogics/go-fuzz-headers"
  6. )
  7. func FuzzDecompressStream(f *testing.F) {
  8. f.Fuzz(func(t *testing.T, data []byte) {
  9. r := bytes.NewReader(data)
  10. _, _ = DecompressStream(r)
  11. })
  12. }
  13. func FuzzUntar(f *testing.F) {
  14. f.Fuzz(func(t *testing.T, data []byte) {
  15. ff := fuzz.NewConsumer(data)
  16. tarBytes, err := ff.TarBytes()
  17. if err != nil {
  18. return
  19. }
  20. options := &TarOptions{}
  21. err = ff.GenerateStruct(options)
  22. if err != nil {
  23. return
  24. }
  25. tmpDir := t.TempDir()
  26. Untar(bytes.NewReader(tarBytes), tmpDir, options)
  27. })
  28. }
  29. func FuzzApplyLayer(f *testing.F) {
  30. f.Fuzz(func(t *testing.T, data []byte) {
  31. tmpDir := t.TempDir()
  32. _, _ = ApplyLayer(tmpDir, bytes.NewReader(data))
  33. })
  34. }