Use InvariantCulture for parsing float arguments in GC stress tests
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 6 Nov 2015 16:42:51 +0000 (17:42 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 16 Nov 2015 19:47:23 +0000 (20:47 +0100)
Otherwise they'd fail on cultures where '.' isn't used as a decimal separator.

tests/src/GC/Stress/Tests/GCSimulator.cs
tests/src/GC/Stress/Tests/StressAllocator.cs

index b5564bf..ad62c69 100644 (file)
@@ -825,7 +825,7 @@ namespace GCSimulator
                     else if (currentArg.StartsWith("datapinned") || currentArg.StartsWith("dp")) // percentage data pinned
                     {
                         currentArgValue = args[++i];
-                        s_percentPinned = float.Parse(currentArgValue);
+                        s_percentPinned = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                         if (s_percentPinned < 0 || s_percentPinned > 1)
                         {
                             Console.WriteLine("Error! datapinned should be a number from 0 to 1");
@@ -848,7 +848,7 @@ namespace GCSimulator
                     else if (currentArg.StartsWith("dataweak") || currentArg.StartsWith("dw"))
                     {
                         currentArgValue = args[++i];
-                        s_percentWeak = float.Parse(currentArgValue);
+                        s_percentWeak = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                         if (s_percentWeak < 0 || s_percentWeak > 1)
                         {
                             Console.WriteLine("Error! dataweak should be a number from 0 to 1");
index 2e0ec1a..2c3c89e 100644 (file)
@@ -518,7 +518,7 @@ namespace StressAllocator
                     else if (String.Compare(currentArg.ToLower(), "pinned") == 0)
                     {
                         currentArgValue = args[++i];
-                        percentPinned = float.Parse(currentArgValue);
+                        percentPinned = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                     }
                     else if (String.Compare(currentArg.ToLower(), "lohpin") == 0)  //for LOH compacting testing, this is the option to apply the pinning percentage to LOH
                     {
@@ -527,22 +527,22 @@ namespace StressAllocator
                     else if (String.Compare(currentArg.ToLower(), "bucket1") == 0)
                     {
                         currentArgValue = args[++i];
-                        percentBucket1 = float.Parse(currentArgValue);
+                        percentBucket1 = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                     }
                     else if (String.Compare(currentArg.ToLower(), "bucket2") == 0)
                     {
                         currentArgValue = args[++i];
-                        percentBucket2 = float.Parse(currentArgValue);
+                        percentBucket2 = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                     }
                     else if (String.Compare(currentArg.ToLower(), "bucket3") == 0)
                     {
                         currentArgValue = args[++i];
-                        percentBucket3 = float.Parse(currentArgValue);
+                        percentBucket3 = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                     }
                     else if (String.Compare(currentArg.ToLower(), "bucket4") == 0)
                     {
                         currentArgValue = args[++i];
-                        percentBucket4 = float.Parse(currentArgValue);
+                        percentBucket4 = float.Parse(currentArgValue, System.Globalization.CultureInfo.InvariantCulture);
                     }
                     else if (String.Compare(currentArg.ToLower(), "nolocks") == 0)
                     {