Skip to content

Commit

Permalink
Add runtime test for ThreadStatic valuetype access
Browse files Browse the repository at this point in the history
  • Loading branch information
BrzVlad committed Jun 2, 2021
1 parent 6c8fcfc commit 27d4895
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/tests/baseservices/threading/threadstatic/threadstatic08.cs
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;
}
}
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>

0 comments on commit 27d4895

Please sign in to comment.