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