Skip to content

Commit 33fc8f4

Browse files
committed
Add interpreter test
The test contains one application that contains a method named `RunInterpreterTests` serving as the interpreter entry point. This application is built only, as it is not the test itself. This application is executed with corerun by the actual test, which waits for the corerun exit code to determine success.
1 parent ef7604e commit 33fc8f4

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ int InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
515515
uint8_t opcode = *ip;
516516
switch (opcode)
517517
{
518+
case CEE_NOP:
519+
ip++;
520+
break;
518521
case CEE_LDC_I4_M1:
519522
case CEE_LDC_I4_0:
520523
case CEE_LDC_I4_1:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
7+
public class InterpreterTest
8+
{
9+
static int Main(string[] args)
10+
{
11+
RunInterpreterTests();
12+
return 100;
13+
}
14+
15+
[MethodImpl(MethodImplOptions.NoInlining)]
16+
public static void RunInterpreterTests()
17+
{
18+
// Console.WriteLine("Run interp tests");
19+
}
20+
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<!-- This is a separate app launched by the actual test in InterpreterTester.csproj -->
4+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
5+
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
6+
<CLRTestKind>BuildOnly</CLRTestKind>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<Compile Include="Interpreter.cs" />
10+
</ItemGroup>
11+
</Project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Diagnostics;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Reflection;
9+
using System.Runtime;
10+
using System.Text;
11+
12+
using Xunit;
13+
14+
public class InterpreterTester
15+
{
16+
[Fact]
17+
public static void RunTests()
18+
{
19+
string corerun = TestLibrary.Utilities.IsWindows ? "corerun.exe" : "corerun";
20+
string libInterp = TestLibrary.Utilities.IsWindows ? "clrinterpreter.dll" : "libclrinterpreter.so";
21+
string coreRoot = Environment.GetEnvironmentVariable("CORE_ROOT");
22+
string interpreterApp = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Interpreter.dll");
23+
24+
var startInfo = new ProcessStartInfo(Path.Combine(coreRoot, corerun), interpreterApp);
25+
startInfo.EnvironmentVariables["DOTNET_AltJitName"] = libInterp;
26+
startInfo.EnvironmentVariables["DOTNET_AltJitPath"] = Path.Combine(coreRoot, libInterp);
27+
startInfo.EnvironmentVariables["DOTNET_AltJit"] = "RunInterpreterTests";
28+
29+
using (Process p = Process.Start(startInfo))
30+
{
31+
p.WaitForExit();
32+
Console.WriteLine ("Interpreted App returned {0}", p.ExitCode);
33+
if (p.ExitCode != 100)
34+
throw new Exception("Interpreted App failed execution");
35+
}
36+
}
37+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<RequiresProcessIsolation>true</RequiresProcessIsolation>
4+
<DisableProjectBuild Condition="'$(RuntimeFlavor)' == 'Mono'">true</DisableProjectBuild>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<Compile Include="InterpreterTester.cs" />
8+
</ItemGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
11+
<ProjectReference Include="$(MSBuildThisFileDirectory)Interpreter.csproj">
12+
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
13+
<OutputItemType>Content</OutputItemType>
14+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
15+
</ProjectReference>
16+
</ItemGroup>
17+
</Project>

0 commit comments

Comments
 (0)