From 77d8278ff2dbde352480e6f12788a7d483c0beeb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 25 Feb 2024 12:57:06 -0500 Subject: [PATCH] Workaround for linux test race condition --- .../Live/Instance/WatchdogTest.cs | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 4a453d4f510..3bf26e3f1d9 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -729,28 +729,41 @@ void TestLinuxIsntBeingFuckingCheekyAboutFilePaths(DreamDaemonResponse currentSt var foundLivePath = false; var allPaths = new List(); - Assert.IsFalse(proc.HasExited); - foreach (var fd in Directory.GetFiles($"/proc/{pid}/fd")) + var features = new PosixProcessFeatures( + new Lazy(Mock.Of()), + Mock.Of(), + Mock.Of>()); + + features.SuspendProcess(proc); + try { - var sb = new StringBuilder(UInt16.MaxValue); - if (Syscall.readlink(fd, sb) == -1) - throw new UnixIOException(Stdlib.GetLastError()); + Assert.IsFalse(proc.HasExited); + foreach (var fd in Directory.GetFiles($"/proc/{pid}/fd")) + { + var sb = new StringBuilder(UInt16.MaxValue); + if (Syscall.readlink(fd, sb) == -1) + throw new UnixIOException(Stdlib.GetLastError()); - var path = sb.ToString(); + var path = sb.ToString(); - allPaths.Add($"Path: {path}"); - if (path.Contains($"Game/{previousStatus.DirectoryName}")) - failingLinks.Add($"Found fd {fd} resolving to previous absolute path game dir path: {path}"); + allPaths.Add($"Path: {path}"); + if (path.Contains($"Game/{previousStatus.DirectoryName}")) + failingLinks.Add($"Found fd {fd} resolving to previous absolute path game dir path: {path}"); - if (path.Contains($"Game/{currentStatus.ActiveCompileJob.DirectoryName}")) - failingLinks.Add($"Found fd {fd} resolving to current absolute path game dir path: {path}"); + if (path.Contains($"Game/{currentStatus.ActiveCompileJob.DirectoryName}")) + failingLinks.Add($"Found fd {fd} resolving to current absolute path game dir path: {path}"); - if (path.Contains($"Game/Live")) - foundLivePath = true; - } + if (path.Contains($"Game/Live")) + foundLivePath = true; + } - if (!foundLivePath) - failingLinks.Add($"Failed to find a path containing the 'Live' directory!"); + if (!foundLivePath) + failingLinks.Add($"Failed to find a path containing the 'Live' directory!"); + } + finally + { + features.ResumeProcess(proc); + } Assert.IsTrue(failingLinks.Count == 0, String.Join(Environment.NewLine, failingLinks.Concat(allPaths))); }