Skip to content

Commit 3510ea2

Browse files
committed
supply platform tags to allow non-native-architecture-images to run during tests
1 parent 021c629 commit 3510ea2

File tree

1 file changed

+10
-10
lines changed
  • Test.Microsoft.NET.Build.Containers.Filesystem

1 file changed

+10
-10
lines changed

Test.Microsoft.NET.Build.Containers.Filesystem/EndToEnd.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private static async Task<string> BuildLocalApp(string tfm = "net6.0", string ri
111111
await dotnetNew.WaitForExitAsync();
112112
Assert.AreEqual(0, dotnetNew.ExitCode, await dotnetNew.StandardOutput.ReadToEndAsync() + Environment.NewLine + await dotnetNew.StandardError.ReadToEndAsync());
113113

114-
ProcessStartInfo publishPSI = rid is null ? new("dotnet", $"publish -bl MinimalTestApp") : new("dotnet", $"publish -bl MinimalTestApp -r {rid}");
114+
ProcessStartInfo publishPSI = rid is null ? new("dotnet", $"publish -bl MinimalTestApp") : new("dotnet", $"publish -bl MinimalTestApp -r {rid} --self-contained");
115115
publishPSI.RedirectStandardOutput = true;
116116
publishPSI.RedirectStandardError = true;
117117
Process publish = Process.Start(publishPSI);
@@ -276,13 +276,13 @@ public async Task EndToEnd_NoAPI()
276276
privateNuGetAssets.Delete(true);
277277
}
278278

279-
[DataRow("linux-arm", false, "/app")] // packaging framework-dependent because emulating arm on x64 Docker host doesn't work
280-
//[DataRow("linux-x86", false, "/app")] // packaging framework-dependent because missing runtime packs for x86 linux. // MS doesn't ship a linux-x86 image
281-
[DataRow("linux-arm64", false, "/app")] // packaging framework-dependent because emulating arm64 on x64 Docker host doesn't work
282-
[DataRow("win-x64", true, "C:\\app")]
283-
[DataRow("linux-x64", true, "/app")]
279+
[DataRow("linux-arm", false, "/app", "linux/arm/v7")] // packaging framework-dependent because emulating arm on x64 Docker host doesn't work
280+
//[DataRow("linux-x86", false, "/app", "linux/386")] // packaging framework-dependent because missing runtime packs for x86 linux. // MS doesn't ship a linux-x86 image
281+
[DataRow("linux-arm64", false, "/app", "linux/arm/v8")] // packaging framework-dependent because emulating arm64 on x64 Docker host doesn't work
282+
[DataRow("win-x64", true, "C:\\app", "windows/amd64")] // packaging self-contained because Windows containers can't run on Linux hosts
283+
[DataRow("linux-x64", true, "/app", "linux/amd64")]
284284
[TestMethod]
285-
public async Task CanPackageForAllSupportedContainerRIDs(string rid, bool isRIDSpecific, string workingDir) {
285+
public async Task CanPackageForAllSupportedContainerRIDs(string rid, bool isRIDSpecific, string workingDir, string dockerPlatform) {
286286
if (rid == "win-x64") {
287287
Assert.Inconclusive("Cannot run Windows containers on Linux hosts (or at the same time as Linux containers), so skipping for now");
288288
return;
@@ -306,17 +306,17 @@ public async Task CanPackageForAllSupportedContainerRIDs(string rid, bool isRIDS
306306

307307
await LocalDocker.Load(x, NewImageName(), rid, DockerRegistryManager.BaseImage);
308308

309+
var args = $"run --rm --tty --platform {dockerPlatform} {NewImageName()}:{rid}";
309310
// Run the image
310-
311-
ProcessStartInfo runInfo = new("docker", $"run --rm --tty {NewImageName()}:{rid}") {
311+
ProcessStartInfo runInfo = new("docker", args) {
312312
RedirectStandardError = true,
313313
RedirectStandardOutput = true,
314314
};
315315
Process run = Process.Start(runInfo);
316316
Assert.IsNotNull(run);
317317
await run.WaitForExitAsync();
318318

319-
Assert.AreEqual(0, run.ExitCode, run.StandardOutput.ReadToEnd() + Environment.NewLine + run.StandardError.ReadToEnd());
319+
Assert.AreEqual(0, run.ExitCode, $"Arguments: {args}\n{run.StandardOutput.ReadToEnd()}\n{run.StandardError.ReadToEnd()}");
320320

321321
string[] DecideEntrypoint(string rid, bool isRIDSpecific, string appName, string workingDir) {
322322
var binary = rid.StartsWith("win") ? $"{appName}.exe" : appName;

0 commit comments

Comments
 (0)