Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Tests/H5.Compiler.IntegrationTests/Infrastructure/H5Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using System.Net.Http;
using System.Text.Json;
using System.Collections.Generic;
Expand All @@ -17,16 +18,18 @@ public static class H5Compiler
{
private static readonly HttpClient _httpClient = new HttpClient();
private static Dictionary<string, NuGetVersion> _cachedLatestVersion = new Dictionary<string, NuGetVersion>();
private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);

private static async Task<NuGetVersion> GetLatestVersionAsync(string package = "h5")
{
if (_cachedLatestVersion.TryGetValue(package, out var cachedVersion))
{
return cachedVersion;
}

await _semaphore.WaitAsync();
try
{
if (_cachedLatestVersion.TryGetValue(package, out var cachedVersion))
{
return cachedVersion;
}

if (package == "h5")
{
var repoRoot = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "../../../../../"));
Expand Down Expand Up @@ -82,6 +85,10 @@ private static async Task<NuGetVersion> GetLatestVersionAsync(string package = "
{
throw new Exception("Failed to fetch or restore latest h5 version.", ex);
}
finally
{
_semaphore.Release();
}
}

private static async Task EnsurePackageRestored(NuGetVersion version, string package, string repoRoot = null)
Expand Down
100 changes: 100 additions & 0 deletions Tests/H5.Compiler.IntegrationTests/RuntimeTests/1086745236Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace H5.Compiler.IntegrationTests.RuntimeTests
{
[TestClass]
public class 1086745236Tests : IntegrationTestBase
{
[TestMethod]
public async Task 1086745236_Run()
{
var code = """
// Original: External/dotnet_runtime/src/tests/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b320147/1086745236.cs
using System;

public static class TestFramework
{
public static void BeginTestCase(string message) { Console.WriteLine("BeginTestCase: " + message); }
public static void EndTestCase() { Console.WriteLine("EndTestCase"); }
public static void LogInformation(string message) { Console.WriteLine(message); }
public static void LogError(string id, string message) { Console.WriteLine("Error " + id + ": " + message); }
public static void BeginScenario(string message) { Console.WriteLine("BeginScenario: " + message); }
}


// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//


namespace b320147;

using System;
using System.Collections;
using System.Runtime.InteropServices;
// using Xunit;

public struct AA
{
public void Method1()
{
bool local1 = true;
for (; local1; )
{
if (local1)
break;
}
do
{
if (local1)
break;
}
while (local1);
return;
}

}

[StructLayout(LayoutKind.Sequential)]
public class App
{
// [OuterLoop]
// [Fact]
public static void TestEntryPoint()
{
try
{
Console.WriteLine("Testing AA::Method1");
new AA().Method1();
}
catch (Exception x)
{
Console.WriteLine("Exception handled: " + x.ToString());
}

// JIT Stress test... if jitted it passes
Console.WriteLine("Passed.");
}
}


public class Program
{
public static int Main()
{
try {
return App.TestEntryPoint();
} catch(Exception e) {
Console.WriteLine(e.ToString());
return 0;
}
return 100;
}
}
""";
await RunTest(code);
}
}
}
84 changes: 84 additions & 0 deletions Tests/H5.Compiler.IntegrationTests/RuntimeTests/5w1d06Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace H5.Compiler.IntegrationTests.RuntimeTests
{
[TestClass]
public class 5w1d06Tests : IntegrationTestBase
{
[TestMethod]
public async Task 5w1d06_Run()
{
var code = """
// Original: External/dotnet_runtime/src/tests/JIT/Methodical/fp/exgen/5w1d-06.cs
using System;

public static class TestFramework
{
public static void BeginTestCase(string message) { Console.WriteLine("BeginTestCase: " + message); }
public static void EndTestCase() { Console.WriteLine("EndTestCase"); }
public static void LogInformation(string message) { Console.WriteLine(message); }
public static void LogError(string id, string message) { Console.WriteLine("Error " + id + ": " + message); }
public static void BeginScenario(string message) { Console.WriteLine("BeginScenario: " + message); }
}


// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
// using Xunit;
// namespace Test_5w1d_06
{
public class testout1
{
private static double[,,] s_arr3d_0 = new double[5, 6, 4];
private static double[,] s_arr2d_0 = new double[3, 6];


public static int Func_0()
{
s_arr3d_0[4, 0, 3] = 1177305879;
s_arr2d_0[2, 1] = 1177305779D;
if ((s_arr2d_0[2, 1]) <= ((int)(s_arr3d_0[4, 0, 3]) % (int)s_arr2d_0[2, 1]))
Console.WriteLine("Func_0: <= true");
int retval_0 = (int)(s_arr3d_0[4, 0, 3]) % (int)s_arr2d_0[2, 1];
return retval_0;
}

// [Fact]
// [OuterLoop]
public static int TestEntryPoint()
{
int retval;
retval = Convert.ToInt32(Func_0());
if ((retval >= 99) && (retval < 100))
retval = 100;
if ((retval > 100) && (retval <= 101))
retval = 100;
Console.WriteLine(retval);
return retval;
}
}
// }


public class Program
{
public static int Main()
{
try {
return testout1.TestEntryPoint();
} catch(Exception e) {
Console.WriteLine(e.ToString());
return 0;
}
return 100;
}
}
""";
await RunTest(code);
}
}
}
101 changes: 101 additions & 0 deletions Tests/H5.Compiler.IntegrationTests/RuntimeTests/BouncingBallTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace H5.Compiler.IntegrationTests.RuntimeTests
{
[TestClass]
public class BouncingBallTests : IntegrationTestBase
{
[TestMethod]
public async Task BouncingBall_Run()
{
var code = """
// Original: External/dotnet_runtime/src/tests/JIT/Methodical/fp/apps/BouncingBall.cs
using System;

public static class TestFramework
{
public static void BeginTestCase(string message) { Console.WriteLine("BeginTestCase: " + message); }
public static void EndTestCase() { Console.WriteLine("EndTestCase"); }
public static void LogInformation(string message) { Console.WriteLine(message); }
public static void LogError(string id, string message) { Console.WriteLine("Error " + id + ": " + message); }
public static void BeginScenario(string message) { Console.WriteLine("BeginScenario: " + message); }
}


// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Method: Simulate a bouncing ball based on the laws of physics.

using System;
// using Xunit;

public class BouncingBall
{

// [Fact]
// [OuterLoop]
public static int TestEntryPoint()
{
double coef;
double height;
Ball B;
double inc;
string output;
bool FirstTime;

coef = 0.8;
height = 80.0;

Console.WriteLine("Coeficient of Restitution: {0}", coef);
Console.WriteLine("Balls starting height : {0} m", height);

B = new Ball(coef, height);

FirstTime = true;
inc = 70 / height;
while (FirstTime || B.Step())
{
output = "|";
for (int i = 0; i < (int)Math.Floor(inc * B.Height); i++) output += " ";
output += "*";
Console.WriteLine("{0}\r", output);
FirstTime = false;
}
Console.WriteLine("");

double d = B.DistanceTraveled();

Console.WriteLine("The Ball Traveld: {0} m", d);

if ((d - 363.993284074572) > 1.0e-11)
{
Console.WriteLine("FAILED");
return 1;
}
Console.WriteLine("PASSED");
return 100;
}
}


public class Program
{
public static int Main()
{
try {
return BouncingBall.TestEntryPoint();
} catch(Exception e) {
Console.WriteLine(e.ToString());
return 0;
}
return 100;
}
}
""";
await RunTest(code);
}
}
}
Loading