Skip to content

Commit

Permalink
Merge branch 'main' into yueqianli/SBConfigAndRepo
Browse files Browse the repository at this point in the history
  • Loading branch information
LiYueqian-James authored Aug 26, 2024
2 parents 1f7591b + 89a81f1 commit e6eca5b
Show file tree
Hide file tree
Showing 91 changed files with 4,329 additions and 1,310 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.15.13
1.15.15
2 changes: 1 addition & 1 deletion src/VirtualClient/Module.props
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<Serilog_Sinks_RollingFile_PackageVersion>3.3.0</Serilog_Sinks_RollingFile_PackageVersion>

<!-- SSH.Net -->
<SSH_Net_PackageVersion>2020.0.2</SSH_Net_PackageVersion>
<SSH_Net_PackageVersion>2024.0.0</SSH_Net_PackageVersion>

<!-- System.CommandLine -->
<System_CommandLine_PackageVersion>2.0.0-beta1.21308.1</System_CommandLine_PackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
namespace VirtualClient.Actions
{
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.IO.Abstractions;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using global::VirtualClient;
using global::VirtualClient.Common;
using global::VirtualClient.Common.Extensions;
using global::VirtualClient.Common.Platform;
using global::VirtualClient.Common.Telemetry;
using global::VirtualClient.Contracts;
using global::VirtualClient.Contracts.Metadata;
Expand Down Expand Up @@ -101,20 +98,24 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
{
case "win-x64":
this.ExecutablePath = this.PlatformSpecifics.Combine(workloadPackage.Path, "geekbench_x86_64.exe");
this.SupportingExecutables.Add("geekbench_x86_64.exe");
break;

case "win-arm64":
this.ExecutablePath = this.PlatformSpecifics.Combine(workloadPackage.Path, "geekbench_aarch64.exe");
this.SupportingExecutables.Add("geekbench_aarch64.exe");
break;

case "linux-x64":
this.ExecutablePath = this.PlatformSpecifics.Combine(workloadPackage.Path, "geekbench_x86_64");
this.SupportingExecutables.Add("geekbench_x86_64");
await this.systemManagement.MakeFilesExecutableAsync(workloadPackage.Path, this.Platform, CancellationToken.None);

break;

case "linux-arm64":
this.ExecutablePath = this.PlatformSpecifics.Combine(workloadPackage.Path, "geekbench_aarch64");
this.SupportingExecutables.Add("geekbench_aarch64");
await this.systemManagement.MakeFilesExecutableAsync(workloadPackage.Path, this.Platform, CancellationToken.None);

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,28 @@ public void GetStatePathReturnsTheExpectedPathOnWindowsSystems()
Assert.AreEqual(@"C:\users\anyuser\virtualclient\state\other\anystate.json", platformSpecifics.GetStatePath(@"\other", "anystate.json"));
}

[Test]
public void GetToolsPathReturnsTheExpectedPathOnUnixSystems()
{
PlatformSpecifics platformSpecifics = new TestPlatformSpecifics2(PlatformID.Unix, Architecture.X64, "/home/anyuser/virtualclient");

Assert.AreEqual("/home/anyuser/virtualclient/tools", platformSpecifics.GetToolsPath());
Assert.AreEqual("/home/anyuser/virtualclient/tools/lshw", platformSpecifics.GetToolsPath("lshw"));
Assert.AreEqual("/home/anyuser/virtualclient/tools/lshw/linux-x64", platformSpecifics.GetToolsPath("lshw", "linux-x64"));
Assert.AreEqual("/home/anyuser/virtualclient/tools/lshw/linux-x64/lshw", platformSpecifics.GetToolsPath("lshw", "linux-x64", "lshw"));
}

[Test]
public void GetToolsPathReturnsTheExpectedPathOnWindowsSystems()
{
PlatformSpecifics platformSpecifics = new TestPlatformSpecifics2(PlatformID.Win32NT, Architecture.X64, @"C:\users\anyuser\virtualclient");

Assert.AreEqual(@"C:\users\anyuser\virtualclient\tools", platformSpecifics.GetToolsPath());
Assert.AreEqual(@"C:\users\anyuser\virtualclient\tools\systemtools", platformSpecifics.GetToolsPath("systemtools"));
Assert.AreEqual(@"C:\users\anyuser\virtualclient\tools\systemtools\win-x64", platformSpecifics.GetToolsPath("systemtools", "win-x64"));
Assert.AreEqual(@"C:\users\anyuser\virtualclient\tools\systemtools\win-x64\coreinfo.exe", platformSpecifics.GetToolsPath("systemtools", "win-x64", "coreinfo.exe"));
}

[Test]
[TestCase(PlatformID.Win32NT, Architecture.X64, "win-x64")]
[TestCase(PlatformID.Win32NT, Architecture.Arm64, "win-arm64")]
Expand Down
4 changes: 2 additions & 2 deletions src/VirtualClient/VirtualClient.Contracts/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public static class EnvironmentVariable
public const string VC_LIBRARY_PATH = nameof(VC_LIBRARY_PATH);

/// <summary>
/// Name = VC_PACKAGES_PATH
/// Name = VC_PACKAGES_DIR
/// </summary>
public const string VC_PACKAGES_PATH = nameof(VC_PACKAGES_PATH);
public const string VC_PACKAGES_DIR = nameof(VC_PACKAGES_DIR);
}

/// <summary>
Expand Down
38 changes: 26 additions & 12 deletions src/VirtualClient/VirtualClient.Contracts/PlatformSpecifics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace VirtualClient.Contracts
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using VirtualClient.Common.Extensions;
Expand Down Expand Up @@ -78,12 +76,13 @@ protected PlatformSpecifics(PlatformID platform, Architecture architecture, stri
this.ProfileDownloadsDirectory = this.Combine(standardizedCurrentDirectory, "profiles", "downloads");
this.ScriptsDirectory = this.Combine(standardizedCurrentDirectory, "scripts");
this.StateDirectory = this.Combine(standardizedCurrentDirectory, "state");
this.ToolsDirectory = this.Combine(standardizedCurrentDirectory, "tools");
}

/// <summary>
/// The directory for file/content upload notifications (e.g. /logs/contentuploads).
/// </summary>
public string ContentUploadsDirectory { get; internal set; }
public string ContentUploadsDirectory { get; }

/// <summary>
/// The CPU architecture (e.g. x64, arm64).
Expand All @@ -96,24 +95,24 @@ protected PlatformSpecifics(PlatformID platform, Architecture architecture, stri
public string CurrentDirectory { get; }

/// <summary>
/// The directory where log files are are written.
/// The directory where log files are are written. Overridable.
/// </summary>
public string LogsDirectory { get; internal set; }
public string LogsDirectory { get; set; }

/// <summary>
/// The directory where packages are stored.
/// The directory where packages are stored. Overridable.
/// </summary>
public string PackagesDirectory { get; internal set; }
public string PackagesDirectory { get; set; }

/// <summary>
/// The directory where profiles are stored.
/// </summary>
public string ProfilesDirectory { get; internal set; }
public string ProfilesDirectory { get; }

/// <summary>
/// The directory where profiles downloaded are stored.
/// </summary>
public string ProfileDownloadsDirectory { get; internal set; }
public string ProfileDownloadsDirectory { get; }

/// <summary>
/// The OS platform (e.g. Windows, Unix).
Expand All @@ -129,18 +128,23 @@ protected PlatformSpecifics(PlatformID platform, Architecture architecture, stri
/// <summary>
/// The directory where scripts related to workloads exist.
/// </summary>
public string ScriptsDirectory { get; internal set; }
public string ScriptsDirectory { get; }

/// <summary>
/// The directory where state objects are stored.
/// </summary>
public string StateDirectory { get; internal set; }
public string StateDirectory { get; }

/// <summary>
/// The directory where built-in tools/toolsets are stored.
/// </summary>
public string ToolsDirectory { get; }

/// <summary>
/// True to standardize paths using Unix-style conventions (e.g. forward slashes '/')
/// only. When 'true' all paths (including Windows-formatted) will use forward slashes.
/// </summary>
public bool UseUnixStylePathsOnly { get; internal set; }
public bool UseUnixStylePathsOnly { get; }

/// <summary>
/// Returns the platform + architecture name used by the Virtual Client to represent a
Expand Down Expand Up @@ -435,6 +439,16 @@ public string GetStatePath(params string[] additionalPathSegments)
: this.Combine(this.StateDirectory, this.Combine(additionalPathSegments));
}

/// <summary>
/// Combines the path segments provided with path where built-in tools/toolsets are stored.
/// </summary>
public string GetToolsPath(params string[] additionalPathSegments)
{
return additionalPathSegments?.Any() != true
? this.ToolsDirectory
: this.Combine(this.ToolsDirectory, this.Combine(additionalPathSegments));
}

/// <summary>
/// Sets the value of the environment variable or appends a value to the end of it.
/// </summary>
Expand Down
Loading

0 comments on commit e6eca5b

Please sign in to comment.