Skip to content

Commit 8b06601

Browse files
saibulususaibulusu
andauthored
azlinux3 dnf packages for compiler installation (#423)
* Adding packages to install for azlinux3. * Adding git as a package installed via dnf. * Upversion * gcc version is empty by default. Throwing error if gcc version is not empty for azlinux. * Fixing typo. * Fixing test. * Adding make for RHEL/Cent OS. * Logging gcc version, only confirming version if supplied version is unempty * Installing version-less packages for ubuntu/debian. * Adding libnsl package for RHEL/CentOS. * Removed speccpu gcc limit in documentation, and checking for gcc version with metadata. * Removing existing version of gcc before installing new version. * Dnf remove instead of apt-get for CentOS/RHEL. * Getting gcc version, if already installed and not supplied, does not install. * Fixing unit test for case where supplied version is empty. * Adding a unit test for no supplied version, with existing version. * Splitting dumpversion output * upversion * Removing compiler name from compiler installation, compiler version from speccpu * Adding purge and updating unit tests. * upversion * Removing compiler name, setting compiler version empty. * Removing unecessary unit test. * Fixing unit test for windows speccpu. * Fixing documentation. --------- Signed-off-by: Sai Bulusu <[email protected]> Co-authored-by: saibulusu <[email protected]>
1 parent b38f970 commit 8b06601

File tree

19 files changed

+336
-362
lines changed

19 files changed

+336
-362
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.16.19
1+
1.16.20

src/VirtualClient/VirtualClient.Actions.FunctionalTests/CoreMarkProfileTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ public async Task CoreMarkProWorkloadProfileExecutesTheExpectedWorkloadsOnWindow
177177
this.mockFixture.SetupLinuxPackagesInstalled(new Dictionary<string, string>
178178
{
179179
{ "gcc", "10" }, // Should match profile defaults.
180-
{ "cc", "10" }
180+
{ "cc", "10" },
181+
{ "gfortran", "10" }
181182
});
182183

183184
this.mockFixture.ProcessManager.OnGetProcess = (id) => null;

src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace VirtualClient.Actions
1010
using System.IO.Abstractions;
1111
using System.Linq;
1212
using System.Reflection;
13+
using System.Text;
1314
using System.Threading;
1415
using System.Threading.Tasks;
1516
using global::VirtualClient;
@@ -55,6 +56,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInLin
5556
{
5657
$"sudo mount -t iso9660 -o ro,exec,loop {this.mockPackage.Path}/speccpu.iso {this.mockFixture.GetPackagePath()}/speccpu_mount",
5758
$"sudo ./install.sh -f -d {this.mockPackage.Path}",
59+
$"sudo gcc -dumpversion",
5860
$"sudo chmod -R ugo=rwx {this.mockPackage.Path}",
5961
$"sudo umount {this.mockFixture.GetPackagePath()}/speccpu_mount",
6062
$"sudo bash runspeccpu.sh \"--config vc-linux-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --reportable intrate\""
@@ -66,25 +68,43 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInLin
6668
Assert.AreEqual(expectedCommands.ElementAt(processCount), $"{exe} {arguments}");
6769
processCount++;
6870

69-
return new InMemoryProcess
71+
if (exe == "sudo" && arguments == "gcc -dumpversion")
7072
{
71-
StartInfo = new ProcessStartInfo
73+
return new InMemoryProcess
7274
{
73-
FileName = exe,
74-
Arguments = arguments
75-
},
76-
ExitCode = 0,
77-
OnStart = () => true,
78-
OnHasExited = () => true
79-
};
75+
StartInfo = new ProcessStartInfo
76+
{
77+
FileName = exe,
78+
Arguments = arguments
79+
},
80+
StandardOutput = new ConcurrentBuffer(new StringBuilder("10")),
81+
ExitCode = 0,
82+
OnStart = () => true,
83+
OnHasExited = () => true
84+
};
85+
}
86+
else
87+
{
88+
return new InMemoryProcess
89+
{
90+
StartInfo = new ProcessStartInfo
91+
{
92+
FileName = exe,
93+
Arguments = arguments
94+
},
95+
ExitCode = 0,
96+
OnStart = () => true,
97+
OnHasExited = () => true
98+
};
99+
}
80100
};
81101

82102
using (TestSpecCpuExecutor specCpuExecutor = new TestSpecCpuExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters))
83103
{
84104
await specCpuExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
85105
}
86106

87-
Assert.AreEqual(5, processCount);
107+
Assert.AreEqual(expectedCommands.Count, processCount);
88108
}
89109

90110
[Test]
@@ -99,6 +119,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
99119
$"powershell -Command \"Mount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
100120
$"powershell -Command \"(Get-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso| Get-Volume).DriveLetter\"",
101121
$"cmd /c echo 1 | X:\\install.bat {this.mockPackage.Path}",
122+
"gcc -dumpversion",
102123
$"powershell -Command \"Dismount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
103124
$"cmd /c runspeccpu.bat --config vc-win-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --noreportable intrate"
104125
};
@@ -114,26 +135,44 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
114135
output.Append("X");
115136
}
116137

117-
return new InMemoryProcess
138+
if (exe == "gcc" && arguments == "-dumpversion")
118139
{
119-
StartInfo = new ProcessStartInfo
140+
return new InMemoryProcess
120141
{
121-
FileName = exe,
122-
Arguments = arguments
123-
},
124-
ExitCode = 0,
125-
OnStart = () => true,
126-
OnHasExited = () => true,
127-
StandardOutput = output
128-
};
142+
StartInfo = new ProcessStartInfo
143+
{
144+
FileName = exe,
145+
Arguments = arguments
146+
},
147+
ExitCode = 0,
148+
OnStart = () => true,
149+
OnHasExited = () => true,
150+
StandardOutput = new ConcurrentBuffer(new StringBuilder("10")),
151+
};
152+
}
153+
else
154+
{
155+
return new InMemoryProcess
156+
{
157+
StartInfo = new ProcessStartInfo
158+
{
159+
FileName = exe,
160+
Arguments = arguments
161+
},
162+
ExitCode = 0,
163+
OnStart = () => true,
164+
OnHasExited = () => true,
165+
StandardOutput = output
166+
};
167+
}
129168
};
130169

131170
using (TestSpecCpuExecutor specCpuExecutor = new TestSpecCpuExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters))
132171
{
133172
await specCpuExecutor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
134173
}
135174

136-
Assert.AreEqual(5, processCount);
175+
Assert.AreEqual(processCount, expectedCommands.Count);
137176
}
138177

139178
[Test]
@@ -273,7 +312,7 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithDifferentProfiles
273312
{
274313
commandCalled = true;
275314
}
276-
315+
277316
return new InMemoryProcess
278317
{
279318
StartInfo = new ProcessStartInfo
@@ -353,7 +392,6 @@ private void SetupLinux()
353392

354393
this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
355394
{
356-
{ nameof(SpecCpuExecutor.CompilerVersion), "10" },
357395
{ nameof(SpecCpuExecutor.SpecProfile), "intrate" },
358396
{ nameof(SpecCpuExecutor.PackageName), "speccpu" },
359397
{ nameof(SpecCpuExecutor.RunPeak), true },
@@ -385,7 +423,6 @@ private void SetupWindows()
385423

386424
this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
387425
{
388-
{ nameof(SpecCpuExecutor.CompilerVersion), "10" },
389426
{ nameof(SpecCpuExecutor.SpecProfile), "intrate" },
390427
{ nameof(SpecCpuExecutor.PackageName), "speccpu" },
391428
{ nameof(SpecCpuExecutor.RunPeak), true },

src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace VirtualClient.Actions
1919
using global::VirtualClient.Contracts;
2020
using Microsoft.Extensions.DependencyInjection;
2121
using VirtualClient.Contracts.Metadata;
22+
using VirtualClient.Metadata;
2223

2324
/// <summary>
2425
/// The SpecCpu workload executor.
@@ -86,17 +87,6 @@ public string BaseOptimizingFlags
8687
}
8788
}
8889

89-
/// <summary>
90-
/// Compiler version
91-
/// </summary>
92-
public string CompilerVersion
93-
{
94-
get
95-
{
96-
return this.Parameters.GetValue<string>(nameof(SpecCpuExecutor.CompilerVersion));
97-
}
98-
}
99-
10090
/// <summary>
10191
/// Iterations.
10292
/// Recommand Default: 2
@@ -432,16 +422,50 @@ private async Task WriteSpecCpuConfigAsync(CancellationToken cancellationToken)
432422
true);
433423
}
434424

425+
string compilerVersion = await this.GetInstalledCompilerDumpVersionAsync("gcc", cancellationToken);
426+
427+
if (string.IsNullOrEmpty(compilerVersion))
428+
{
429+
throw new WorkloadException("gcc version not found.");
430+
}
431+
435432
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.BaseOptimizingFlags, this.BaseOptimizingFlags, StringComparison.OrdinalIgnoreCase);
436433
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.PeakOptimizingFlags, this.PeakOptimizingFlags, StringComparison.OrdinalIgnoreCase);
437434
templateText = templateText.Replace(
438435
SpecCpuConfigPlaceHolder.Gcc10Workaround,
439-
Convert.ToInt32(this.CompilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
436+
Convert.ToInt32(compilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
440437
StringComparison.OrdinalIgnoreCase);
441438

442439
await this.fileSystem.File.WriteAllTextAsync(this.Combine(this.PackageDirectory, "config", configurationFile), templateText, cancellationToken);
443440
}
444441

442+
private async Task<string> GetInstalledCompilerDumpVersionAsync(string compilerName, CancellationToken cancellationToken)
443+
{
444+
string command = compilerName;
445+
string commandArguments = "-dumpversion";
446+
447+
string version = string.Empty;
448+
449+
using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, command, commandArguments))
450+
{
451+
try
452+
{
453+
await process.StartAndWaitAsync(cancellationToken);
454+
455+
if (!cancellationToken.IsCancellationRequested)
456+
{
457+
version = process.StandardOutput.ToString().Trim().Split(".")[0];
458+
}
459+
}
460+
catch
461+
{
462+
version = string.Empty;
463+
}
464+
}
465+
466+
return version;
467+
}
468+
445469
internal class SpecCpuState : State
446470
{
447471
public SpecCpuState(IDictionary<string, IConvertible> properties = null)

0 commit comments

Comments
 (0)