-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add runtime test for ThreadStatic valuetype access
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/tests/baseservices/threading/threadstatic/threadstatic08.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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 System.IO; | ||
using System.Threading; | ||
|
||
public struct Struct | ||
{ | ||
public uint a; | ||
public uint b; | ||
} | ||
|
||
public class Program | ||
{ | ||
[ThreadStatic] | ||
private static Struct TSStruct; | ||
|
||
public static int Main(string[] args) | ||
{ | ||
if(TSStruct.a != 0 || TSStruct.b != 0) | ||
return 101; | ||
|
||
Struct str = new Struct (); | ||
str.a = 0xdeadbeef; | ||
str.b = 0xba5eba11; | ||
|
||
TSStruct = str; | ||
if(TSStruct.a != 0xdeadbeef || TSStruct.b != 0xba5eba11) | ||
return 102; | ||
|
||
Struct str2 = TSStruct; | ||
if(str2.a != 0xdeadbeef || str2.b != 0xba5eba11) | ||
return 103; | ||
|
||
Console.WriteLine("Test Succeeded."); | ||
return 100; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/baseservices/threading/threadstatic/threadstatic08.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<CLRTestPriority>0</CLRTestPriority> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="threadstatic08.cs" /> | ||
</ItemGroup> | ||
</Project> |