From 3f1d02b23f99beaf2bf3b06c11642e56578b12ee Mon Sep 17 00:00:00 2001 From: Jiaheng Hu Date: Sat, 15 Aug 2020 00:24:07 +0000 Subject: syz-manager: add test file as corpus This commit enables the syz-manager to add unit test files as corpus to accelerate fuzzing. The syz-ci would copy unit tests into the worker/seeds folder for each manager process, and the manager would add those tests as seed into the corpus. --- pkg/osutil/osutil.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pkg/osutil') diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go index 47fcc8b7b..1eafafcb9 100644 --- a/pkg/osutil/osutil.go +++ b/pkg/osutil/osutil.go @@ -222,6 +222,21 @@ func LinkFiles(srcDir, dstDir string, files map[string]bool) error { return nil } +// LinkDir creates soft links from dstDir to srcDir. +// All other files in dstDir are removed. +func LinkDir(srcDir, dstDir string) error { + if err := os.RemoveAll(dstDir); err != nil { + return err + } + if err := MkdirAll(dstDir); err != nil { + return err + } + if err := os.Symlink(srcDir, dstDir); err != nil { + return err + } + return nil +} + func MkdirAll(dir string) error { return os.MkdirAll(dir, DefaultDirPerm) } -- cgit mrf-deployment