From 1d7f5446dc37687f078269af3c63af7d7ebbfab4 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 9 Jan 2023 14:04:09 -0700 Subject: containers: Add my own ARC implementation I really want an OnEvict callback. --- lib/containers/fuzzutil_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/containers/fuzzutil_test.go (limited to 'lib/containers/fuzzutil_test.go') diff --git a/lib/containers/fuzzutil_test.go b/lib/containers/fuzzutil_test.go new file mode 100644 index 0000000..79459b6 --- /dev/null +++ b/lib/containers/fuzzutil_test.go @@ -0,0 +1,29 @@ +// Copyright (C) 2023 Luke Shumaker +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package containers + +import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "fmt" + "os" + "path/filepath" + "testing" +) + +func SaveFuzz(f *testing.F, dat []byte) { + var buf bytes.Buffer + fmt.Fprintf(&buf, "go test fuzz v1\n[]byte(%q)\n", dat) + sum := sha256.Sum256(buf.Bytes()) + filename := filepath.Join( + "testdata", + "fuzz", + f.Name(), + hex.EncodeToString(sum[:])) + if err := os.WriteFile(filename, buf.Bytes(), 0o644); err != nil { + f.Error(err) + } +} -- cgit v1.2.3-2-g168b