From 68ad850ef3cd5488cf2a992c80717630c36f44c9 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 23 Feb 2019 17:08:00 +0000 Subject: [PATCH] Removed erroneous use of 'PROCESSOR_ARCHITECTURE' Enviroment variable (dotnet/coreclr#22743) Removed erroneous use of 'PROCESSOR_ARCHITECTURE' Enviroment variable Changed all uses of 'Enviroment.GetEnviromentVariable("PROCESSOR_ARCHITECTURE")' to usage of 'System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture' and 'enum System.Runtime.InteropServices.Architecture'. Fix dotnet/coreclr#22694 Commit migrated from https://github.com/dotnet/coreclr/commit/333232d98639df980133205c41791cb9dc7f3d34 --- src/coreclr/tests/src/GC/Performance/Tests/Allocation.cs | 6 +++--- src/coreclr/tests/src/JIT/Directed/intrinsic/pow/pow1.cs | 15 +++------------ .../tests/src/JIT/Methodical/doublearray/dblarray1.cs | 3 ++- .../tests/src/JIT/Methodical/doublearray/dblarray2.cs | 3 ++- .../tests/src/JIT/Methodical/doublearray/dblarray3.cs | 5 +++-- .../tests/src/JIT/Methodical/doublearray/dblarray4.cs | 3 ++- 6 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/coreclr/tests/src/GC/Performance/Tests/Allocation.cs b/src/coreclr/tests/src/GC/Performance/Tests/Allocation.cs index 064f73c..3a8be8f 100644 --- a/src/coreclr/tests/src/GC/Performance/Tests/Allocation.cs +++ b/src/coreclr/tests/src/GC/Performance/Tests/Allocation.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.InteropServices; //Measure allocation time when allocating objects on a single thread. //Should be run with server GC @@ -17,11 +18,10 @@ class Allocation return; } - string processor = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); - Console.WriteLine("Running on {0}", processor); + Console.WriteLine("Running on {0}", RuntimeInformation.ProcessArchitecture); UInt64 MaxBytes = 1500000000; - if (processor.ToLower() == "amd64") + if (RuntimeInformation.ProcessArchitecture == Architecture.X64) { MaxBytes = 5000000000; } diff --git a/src/coreclr/tests/src/JIT/Directed/intrinsic/pow/pow1.cs b/src/coreclr/tests/src/JIT/Directed/intrinsic/pow/pow1.cs index 6f2921d..7f2e65d 100644 --- a/src/coreclr/tests/src/JIT/Directed/intrinsic/pow/pow1.cs +++ b/src/coreclr/tests/src/JIT/Directed/intrinsic/pow/pow1.cs @@ -6,6 +6,7 @@ //Testing the special values using System; +using System.Runtime.InteropServices; internal class pow1 { @@ -15,18 +16,8 @@ internal class pow1 bool pass = true; //Check if the test is being executed on ARMARCH - bool isProcessorArmArch = false; - - string processorArchEnvVar = null; - - processorArchEnvVar = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); - - if ((processorArchEnvVar != null) - && (processorArchEnvVar.Equals("ARM", StringComparison.CurrentCultureIgnoreCase) - || processorArchEnvVar.Equals("ARM64", StringComparison.CurrentCultureIgnoreCase))) - { - isProcessorArmArch = true; - } + bool isProcessorArmArch = RuntimeInformation.ProcessArchitecture == Architecture.Arm + || RuntimeInformation.ProcessArchitecture == Architecture.Arm64; x = 0; y = 0; diff --git a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray1.cs b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray1.cs index de3a234..55d7a4f 100644 --- a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray1.cs +++ b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray1.cs @@ -13,6 +13,7 @@ // Variation on array length +using System.Runtime.InteropServices; using System; internal class DblArray1 { @@ -92,7 +93,7 @@ internal class DblArray1 public static int Main() { - if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "x86") + if (RuntimeInformation.ProcessArchitecture == Architecture.X86) { s_LOH_GEN = 2; } diff --git a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray2.cs b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray2.cs index f05fb59..79ac40d 100644 --- a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray2.cs +++ b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray2.cs @@ -12,6 +12,7 @@ // 6) the threshold can be set by registry key DoubleArrayToLargeObjectHeap +using System.Runtime.InteropServices; using System; internal class DblArray { @@ -281,7 +282,7 @@ internal class DblArray public static int Main() { - if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "x86") + if (RuntimeInformation.ProcessArchitecture == Architecture.X86) { s_LOH_GEN = 2; } diff --git a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray3.cs b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray3.cs index f9167bc..9a2667e 100644 --- a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray3.cs +++ b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray3.cs @@ -5,6 +5,7 @@ using System; +using System.Runtime.InteropServices; internal struct VT { @@ -141,8 +142,8 @@ internal class DblArray3 public static int Main() { - Console.WriteLine(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")); - if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "x86") + Console.WriteLine(RuntimeInformation.ProcessArchitecture); + if (RuntimeInformation.ProcessArchitecture == Architecture.X86) { s_LOH_GEN = 2; } diff --git a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray4.cs b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray4.cs index c31a3e4..404de0a 100644 --- a/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray4.cs +++ b/src/coreclr/tests/src/JIT/Methodical/doublearray/dblarray4.cs @@ -14,13 +14,14 @@ // Test DoubleArrayToLargeObjectHeap - need to set the key to <= 100 using System; +using System.Runtime.InteropServices; internal class DblArray4 { private static int s_LOH_GEN = 0; public static int Main() { - if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") == "x86") + if (RuntimeInformation.ProcessArchitecture == Architecture.X86) { s_LOH_GEN = 2; } -- 2.7.4