Skip to content

Commit 67d3be3

Browse files
authored
Merge pull request #2500 from AdamKorcz/fuzz6
add fuzzer for Inspect
2 parents e3eff00 + c42e746 commit 67d3be3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

pkg/store/fuzz_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"os"
55
"path/filepath"
66
"testing"
7+
8+
"github.com/lima-vm/lima/pkg/store/filenames"
79
)
810

911
func FuzzLoadYAMLByFilePath(f *testing.F) {
@@ -17,3 +19,26 @@ func FuzzLoadYAMLByFilePath(f *testing.F) {
1719
LoadYAMLByFilePath(localFile)
1820
})
1921
}
22+
23+
func FuzzInspect(f *testing.F) {
24+
f.Fuzz(func(t *testing.T, yml, limaVersion []byte) {
25+
limaDir := t.TempDir()
26+
os.Setenv("LIMA_HOME", limaDir)
27+
err := os.MkdirAll(filepath.Join(limaDir, "fuzz-instance"), 0o700)
28+
if err != nil {
29+
// panic so that we know of problems here
30+
panic(err)
31+
}
32+
ymlFile := filepath.Join(limaDir, "fuzz-instance", filenames.LimaYAML)
33+
limaVersionFile := filepath.Join(limaDir, filenames.LimaVersion)
34+
err = os.WriteFile(ymlFile, yml, 0o600)
35+
if err != nil {
36+
return
37+
}
38+
err = os.WriteFile(limaVersionFile, limaVersion, 0o600)
39+
if err != nil {
40+
return
41+
}
42+
_, _ = Inspect("fuzz-instance")
43+
})
44+
}

0 commit comments

Comments
 (0)