Skip to content

Commit aa8b9b3

Browse files
Add a test for mapped paths
1 parent 45ba0d2 commit aa8b9b3

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

src/tests/nativeaot/SmokeTests/HelloWasm/WasmDebugging.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using System;
1010
using System.Diagnostics;
1111

12-
unsafe class Program
12+
unsafe partial class Program
1313
{
1414
public static int Main()
1515
{
@@ -32,6 +32,8 @@ public static int Main()
3232
simpleStruct.TestStructInstanceMethod();
3333
simpleClass.TestClassInstanceMethod();
3434
TestVariables(5, simpleStruct, simpleClass);
35+
TestSourceFileResolved();
36+
TestMappedSourceFileResolved();
3537

3638
// TODO-LLVM-DI: debugging and EH.
3739
return 100;
@@ -133,6 +135,11 @@ private static void TestVariables(int p1, SimpleStruct p2, SimpleClass p3)
133135
classLocal = p3;
134136
Debugger.Break(); // "p3" and "classLocal" should be equal to "{ 5, 2.0 }".
135137
}
138+
139+
private static void TestSourceFileResolved()
140+
{
141+
Debugger.Break(); // This source code should be resolved and visible.
142+
}
136143
}
137144

138145
struct SimpleStruct

src/tests/nativeaot/SmokeTests/HelloWasm/WasmDebugging.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<CLRTestKind>BuildAndRun</CLRTestKind>
55
<InvariantGlobalization>true</InvariantGlobalization>
66
<RequiresProcessIsolation>true</RequiresProcessIsolation>
77
<ReferenceXUnitWrapperGenerator>false</ReferenceXUnitWrapperGenerator>
8+
9+
<PathMap>$(MSBuildThisFileDirectory)WasmDebuggingMappedPath=MAPPED_PATH</PathMap>
810
</PropertyGroup>
911

1012
<PropertyGroup Condition="'$(TargetsWasi)' == 'true'">
@@ -31,5 +33,6 @@ CLRTestExecutionArguments=("$WASM_DEBUGGING_LLDB" $(_LldbArgs) -- "$WASM_DEBUGGI
3133

3234
<ItemGroup>
3335
<Compile Include="WasmDebugging.cs" />
36+
<Compile Include="WasmDebuggingMappedPath/WasmDebuggingMappedFile.cs" />
3437
</ItemGroup>
3538
</Project>

src/tests/nativeaot/SmokeTests/HelloWasm/WasmDebugging.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def run_wasm_debugging_tests(debugger):
3939
test_struct_instance_method(target, process, thread)
4040
test_class_instance_method(target, process, thread)
4141
test_variables(target, process, thread);
42+
test_source_file_resolved(target, process, thread)
43+
test_mapped_source_file_resolved(target, process, thread)
4244

4345
if all_tests_passed:
4446
print('==== All WASM debugging tests passed ====')
@@ -185,6 +187,25 @@ def test_values_display(target, process, thread, pyname, expected_states, use_ge
185187
return
186188
pass_test()
187189

190+
def test_source_file_resolved(target, process, thread):
191+
start_test('test_source_file_resolved')
192+
process.Continue()
193+
source_file = thread.GetSelectedFrame().line_entry.file;
194+
print(f'File under test: "{source_file}"')
195+
end_test(source_file.exists, f'"{source_file}" not found')
196+
197+
def test_mapped_source_file_resolved(target, process, thread):
198+
start_test('test_mapped_source_file_resolved')
199+
path = os.path.abspath(os.path.dirname(__file__))
200+
path = os.path.join(path, "WasmDebuggingMappedPath")
201+
print(f'Mapping MAPPED_PATH to "{path}"')
202+
target.GetDebugger().HandleCommand(f'settings set target.source-map MAPPED_PATH "{path}"')
203+
process.Continue()
204+
205+
source_file = thread.GetSelectedFrame().line_entry.file;
206+
print(f'File under test: "{source_file}"')
207+
end_test(source_file.exists, f'"{source_file}" not found')
208+
188209
all_tests_passed = True
189210
current_test_name = None
190211

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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.Diagnostics;
5+
6+
partial class Program
7+
{
8+
private static void TestMappedSourceFileResolved()
9+
{
10+
Debugger.Break(); // This source code should be resolved and visible.
11+
}
12+
}

0 commit comments

Comments
 (0)