From 2cdcbfd5bfec0916496021a0f053a3713848a442 Mon Sep 17 00:00:00 2001 From: Rebecca Mahany-Horton Date: Mon, 13 Nov 2023 14:28:20 -0500 Subject: [PATCH] See if symlinking helps for interactive test --- pkg/osquery/interactive/interactive_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/osquery/interactive/interactive_test.go b/pkg/osquery/interactive/interactive_test.go index 44281f0bd..f7d1ec610 100644 --- a/pkg/osquery/interactive/interactive_test.go +++ b/pkg/osquery/interactive/interactive_test.go @@ -113,15 +113,12 @@ func downloadOsquery(dir string) error { return fmt.Errorf("error parsing platform: %w, %s", err, runtime.GOOS) } + // Binary is already downloaded to osquerydCacheDir -- create a symlink at outputFile, + // rather than copying the file, to maybe avoid https://github.com/golang/go/issues/22315 outputFile := filepath.Join(dir, "osqueryd") - - path, err := packaging.FetchBinary(context.TODO(), osquerydCacheDir, "osqueryd", target.PlatformBinaryName("osqueryd"), "stable", target) - if err != nil { - return fmt.Errorf("error fetching binary osqueryd binary: %w", err) - } - - if err := fsutil.CopyFile(path, outputFile); err != nil { - return fmt.Errorf("error copying binary osqueryd binary: %w", err) + sourceFile := filepath.Join(osquerydCacheDir, fmt.Sprintf("osqueryd-%s-stable", runtime.GOOS), "osqueryd") + if err := os.Symlink(sourceFile, outputFile); err != nil { + return fmt.Errorf("creating symlink from %s to %s: %w", sourceFile, outputFile, err) } return nil