From 882d9cd999a2a36d6d2efb8004dc558dfb9cc9a0 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari Date: Fri, 7 Mar 2025 13:28:59 -0600 Subject: [PATCH 1/2] Installed Compiler Check fix for Windows --- .../SPEC/SpecCpuExecutorTests.cs | 4 +++- .../VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs b/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs index 83d32add90..243c8ddd4c 100644 --- a/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs +++ b/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs @@ -119,7 +119,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin $"powershell -Command \"Mount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"", $"powershell -Command \"(Get-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso| Get-Volume).DriveLetter\"", $"cmd /c echo 1 | X:\\install.bat {this.mockPackage.Path}", - "gcc -dumpversion", + "C:\\tools\\cygwin\\bin\\gcc -dumpversion", $"powershell -Command \"Dismount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"", $"cmd /c runspeccpu.bat --config vc-win-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --noreportable intrate" }; @@ -421,6 +421,8 @@ private void SetupWindows() this.mockFixture.FileInfo.Setup(file => file.New(It.IsAny())) .Returns(new Mock().Object); + this.mockFixture.SetEnvironmentVariable("ChocolateyToolsLocation", "C:\\tools"); + this.mockFixture.Parameters = new Dictionary() { { nameof(SpecCpuExecutor.SpecProfile), "intrate" }, diff --git a/src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs b/src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs index 9836463c9e..f0930a366b 100644 --- a/src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs @@ -443,9 +443,15 @@ private async Task GetInstalledCompilerDumpVersionAsync(string compilerN { string command = compilerName; string commandArguments = "-dumpversion"; - + string chocolateyToolsLocation = this.GetEnvironmentVariable("ChocolateyToolsLocation", EnvironmentVariableTarget.User); + string cygwinInstallationPath = this.PlatformSpecifics.Combine(chocolateyToolsLocation, "cygwin"); string version = string.Empty; + if (this.Platform == PlatformID.Win32NT) + { + command = this.PlatformSpecifics.Combine(cygwinInstallationPath, "bin", compilerName); + } + using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, command, commandArguments)) { try From 58f252d087da5c2a1014c3edfde9fde83525ec29 Mon Sep 17 00:00:00 2001 From: Rakeshwar Reddy Kambaiahgari Date: Fri, 7 Mar 2025 21:46:03 -0600 Subject: [PATCH 2/2] Update Path. --- .../SPEC/SpecCpuExecutorTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs b/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs index 243c8ddd4c..080bb0408a 100644 --- a/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs +++ b/src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs @@ -135,7 +135,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin output.Append("X"); } - if (exe == "gcc" && arguments == "-dumpversion") + if (exe == "C:\\tools\\cygwin\\bin\\gcc" && arguments == "-dumpversion") { return new InMemoryProcess { @@ -421,7 +421,7 @@ private void SetupWindows() this.mockFixture.FileInfo.Setup(file => file.New(It.IsAny())) .Returns(new Mock().Object); - this.mockFixture.SetEnvironmentVariable("ChocolateyToolsLocation", "C:\\tools"); + this.mockFixture.SetEnvironmentVariable("ChocolateyToolsLocation", this.mockFixture.Combine("C:", "tools")); this.mockFixture.Parameters = new Dictionary() {