aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/osutil
diff options
context:
space:
mode:
authorJiaheng Hu <jiahengh@google.com>2020-08-15 00:24:07 +0000
committerDmitry Vyukov <dvyukov@google.com>2020-09-14 09:52:09 +0200
commit3f1d02b23f99beaf2bf3b06c11642e56578b12ee (patch)
tree5bbafe03a705303efd27bd203fd34e9a705e11b9 /pkg/osutil
parent75cbe1c0ce81300769b82940148d2ad8e16d361e (diff)
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.
Diffstat (limited to 'pkg/osutil')
-rw-r--r--pkg/osutil/osutil.go15
1 files changed, 15 insertions, 0 deletions
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)
}