Skip to content

Commit

Permalink
Workaround for linux test race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Feb 25, 2024
1 parent c373491 commit 77d8278
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,28 +729,41 @@ void TestLinuxIsntBeingFuckingCheekyAboutFilePaths(DreamDaemonResponse currentSt
var foundLivePath = false;
var allPaths = new List<string>();

Assert.IsFalse(proc.HasExited);
foreach (var fd in Directory.GetFiles($"/proc/{pid}/fd"))
var features = new PosixProcessFeatures(
new Lazy<IProcessExecutor>(Mock.Of<IProcessExecutor>()),
Mock.Of<IIOManager>(),
Mock.Of<ILogger<PosixProcessFeatures>>());

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)));
}
Expand Down

0 comments on commit 77d8278

Please sign in to comment.