[tools 1/2] testbot/SetWinLocale: Check that the locale changes took effect.

Francois Gouget fgouget at codeweavers.com
Fri Dec 24 02:44:33 CST 2021


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
It's more practical than running WineTest just for that and there are 
quite a few cases where the desired changes don't in fact happen.

 testbot/bin/SetWinLocale | 107 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 4f50ed555c..135c7b9b48 100755
--- a/testbot/bin/SetWinLocale
+++ b/testbot/bin/SetWinLocale
@@ -608,6 +608,62 @@ if ($OptShow)
 }
 
 
+#
+# Helper to get the LCIDs
+#
+
+my (%WinLCIDs, %WinKeyboardIds);
+
+sub GetWinKeyboardIds($)
+{
+  my ($Locale) = @_;
+
+  # Look for that locale's keyboard id.
+  # Its first component is the locale's LCID.
+  my $Values = RegGetValues("$HKCU_USER_PROFILE\\$Locale", "*:*");
+  foreach my $VName (keys %$Values)
+  {
+    next if ($VName !~ /^[0-9A-F]{4}:/);
+    $WinKeyboardIds{$Locale} = [$VName];
+    last;
+  }
+  $WinKeyboardIds{$Locale} ||= $Keyboards{$Locale};
+  if (!$WinKeyboardIds{$Locale})
+  {
+    FatalError("could not find the $Locale LCID and keyboard ids\n");
+  }
+
+  my $WinLCID = uc($WinKeyboardIds{$Locale}->[0]);
+  $WinLCID =~ s/:.*$//;
+  $WinLCIDs{$Locale} = $WinLCID;
+
+  # Check our builtin information
+  if ($Keyboards{$Locale})
+  {
+    my $LCID = uc($Keyboards{$Locale}->[0]);
+    $LCID =~ s/:.*$//;
+    if ($LCID ne $WinLCID)
+    {
+      FatalError("inconsistent $Locale LCID: expected $LCID, got $WinLCID\n");
+    }
+  }
+
+  return $WinKeyboardIds{$Locale};
+}
+
+sub GetLCID($)
+{
+  my ($Locale) = @_;
+  return undef if (!$Locale);
+
+  GetWinKeyboardIds($Locale) if (!$WinLCIDs{$Locale});
+  return $WinLCIDs{$Locale};
+}
+
+my $LCIDLocale = GetLCID($OptLocale);
+my $LCIDSystem = GetLCID($OptSystem);
+
+
 #
 # Generate the intl.cpl configuration
 #
@@ -738,5 +794,56 @@ if ($OptReboot)
   }
 }
 
+
+#
+# Check that all the changes succeeded
+#
+
+my $Success = 1;
+sub CheckSetting($$$$;$)
+{
+  my ($Settings, $VName, $Expected, $For, $IgnoreCase) = @_;
+
+  my $Value = $Settings->{$VName};
+  if (defined $Value)
+  {
+    if ((!$IgnoreCase and $Value ne $Expected) or
+        ($IgnoreCase and uc($Value) ne uc($Expected)))
+    {
+      Error("expected $VName = $Expected but got $Value $For\n");
+      $Success = 0;
+    }
+  }
+}
+
+Debug(Elapsed($Start), " Checking the new locale settings\n");
+my $Settings = GetWinSettings($Debug);
+ShowWinSettings($Settings) if ($Debug);
+if ($OptLocale)
+{
+  CheckSetting($Settings, "Locale", "0000$LCIDLocale", "for --locale $OptLocale", 1);
+  CheckSetting($Settings, "LocaleName", $OptLocale, "for --locale $OptLocale");
+}
+if ($OptKeyboard)
+{
+  CheckSetting($Settings, "InputMethod", $Keyboards{$OptKeyboard}->[0], "for --keyboard $OptKeyboard", 1);
+}
+if ($OptMUI)
+{
+  CheckSetting($Settings, "PreferredUILanguages", $OptMUI, "for --mui $OptMUI");
+}
+if ($OptCountry)
+{
+  CheckSetting($Settings, "Country", $CountryId, "for --country $OptCountry");
+  CheckSetting($Settings, "CountryName", $OptCountry, "for --country $OptCountry");
+}
+if ($OptSystem)
+{
+  CheckSetting($Settings, "SysLanguage", $LCIDSystem, "for --system $OptSystem", 1);
+  CheckSetting($Settings, "SysLocale", "0000$LCIDSystem", "for --system $OptSystem", 1);
+}
+exit(1) if (!$Success);
+
+
 Debug(Elapsed($Start), " All done!\n");
 exit(0);
-- 
2.30.2




More information about the wine-devel mailing list