From 92c6d6572e1bcb5d2117bd8a19a14ea1503ab902 Mon Sep 17 00:00:00 2001 From: Zack Olson Date: Fri, 10 Jan 2025 11:33:17 -0500 Subject: [PATCH] include windows for cleanup retries in runtime tests (#2042) --- pkg/osquery/runtime/runtime_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/osquery/runtime/runtime_test.go b/pkg/osquery/runtime/runtime_test.go index d4bb4e8bd..2f481d7bf 100644 --- a/pkg/osquery/runtime/runtime_test.go +++ b/pkg/osquery/runtime/runtime_test.go @@ -827,14 +827,16 @@ func setUpTestSlogger() (*threadsafebuffer.ThreadSafeBuffer, *slog.Logger) { // The default t.TempDir is too long of a path, creating too long of an osquery // extension socket, on posix systems. func testRootDirectory(t *testing.T) string { + var rootDir string + if runtime.GOOS == "windows" { - return t.TempDir() + rootDir = t.TempDir() + } else { + ulid := ulid.New() + rootDir = filepath.Join(os.TempDir(), ulid[len(ulid)-4:]) + require.NoError(t, os.Mkdir(rootDir, 0700)) } - ulid := ulid.New() - rootDir := filepath.Join(os.TempDir(), ulid[len(ulid)-4:]) - require.NoError(t, os.Mkdir(rootDir, 0700)) - t.Cleanup(func() { // Do a couple retries in case the directory is still in use -- // Windows is a little slow on this sometimes