[tools 1/2] testbot/SetWinLocale: Add an option to change the locale of VMs.

Francois Gouget fgouget at codeweavers.com
Wed Apr 6 07:17:16 CDT 2022


The --vm ensures the right TestAgent connection parameters will be used
to connect to the specified VM.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
This partially reverts commit 206c7478dcb4 but with some important
differences:
- It does not parse the VM name to infer the locale to be used. Here
  --vm is purely a way to specify how to connect to that machine's
  TestAgentd server.
- It does not add back the options for 'refreshing' snapshots, or 
  creating new VMs for the specified locales. Those were not used and 
  are not coming back.
---
 testbot/bin/SetWinLocale | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 670de4604..e41af2088 100755
--- a/testbot/bin/SetWinLocale
+++ b/testbot/bin/SetWinLocale
@@ -40,6 +40,7 @@ use WineTestBot::Config;
 use WineTestBot::Log;
 use WineTestBot::TestAgent;
 use WineTestBot::Utils;
+use WineTestBot::VMs;
 
 my $HKCU_INTERNATIONAL = "HKCU\\Control Panel\\International";
 my $HKCU_GEO = "HKCU\\Control Panel\\International\\Geo";
@@ -315,7 +316,7 @@ sub CheckLocale($$)
   return undef;
 }
 
-my ($OptHostName, $OptShow, $OptSysCopy, $OptDefCopy, $OptUseIntl, $OptReboot);
+my ($OptVM, $OptHostName, $OptShow, $OptSysCopy, $OptDefCopy, $OptUseIntl, $OptReboot);
 my ($OptDefault, $OptLocale, $OptCountry, $OptSystem, $OptUTF8, $OptMUI, $OptKeyboard);
 while (@ARGV)
 {
@@ -324,6 +325,10 @@ while (@ARGV)
   {
     $Usage = 0;
   }
+  elsif ($Arg eq "--vm")
+  {
+    $OptVM = CheckValue($Arg, $OptVM);
+  }
   elsif ($Arg eq "--show")
   {
     $OptShow = 1;
@@ -415,10 +420,25 @@ while (@ARGV)
 }
 
 # Check and untaint parameters
-my ($Keyboard, $CountryId);
+my ($VM, $Keyboard, $CountryId);
 if (!defined $Usage)
 {
-  if (!defined $OptHostName)
+  if (defined $OptVM)
+  {
+    my $VMs = CreateVMs();
+    $VM = $VMs->GetItem($OptVM);
+    if (!$VM)
+    {
+      Error("could not find the '$OptVM' VM\n");
+      $Usage = 2;
+    }
+    elsif (!$Debug and $VM->Role eq "deleted")
+    {
+      Error("'$OptVM' is marked for deletion\n");
+      $Usage = 2;
+    }
+  }
+  elsif (!defined $OptHostName)
   {
     Error("you must specify the Windows machine to work on\n");
     $Usage = 2;
@@ -510,14 +530,16 @@ if (defined $Usage)
     Error("try '$name0 --help' for more information\n");
     exit $Usage;
   }
-  print "Usage: $name0 [options] --show HOSTNAME\n";
-  print "or     $name0 [options] [--default DEF] [--locale LOC] [--country CTY] [--system SYS] [--utf8] [--mui MUI] [--keyboard KBD] [--no-sys-copy] [--no-def-copy] [--use-intl] [--no-reboot] HOSTNAME\n";
+  print "Usage: $name0 [options] --show (HOSTNAME|--vm VM)\n";
+  print "or     $name0 [options] [--default DEF] [--locale LOC] [--country CTY] [--system SYS] [--utf8] [--mui MUI] [--keyboard KBD] [--no-sys-copy] [--no-def-copy] [--use-intl] [--no-reboot] (HOSTNAME|--vm VM)\n";
   print "\n";
   print "Sets the locale of the specified Windows machine.\n";
   print "\n";
   print "Where:\n";
   print "  HOSTNAME       Work on the specified Windows host (must be running TestAgentd).\n";
   print "  --show         Show the locale settings of the specified host and exit.\n";
+  print "  --vm VM        Work on the specified TestBot VM, using its TestAgent\n";
+  print "                 connection parameters.\n";
   print "  --default DEF  Use this Windows locale as the default for the other options.\n";
   print "                 The locale must be in a form suitable for Windows' intl.cpl\n";
   print "                 control panel module, that is roughly ll-CC where ll is an\n";
@@ -604,7 +626,7 @@ if (defined $Usage)
   exit 0;
 }
 
-$TA = TestAgent->new($OptHostName, $AgentPort);
+$TA = $VM ? $VM->GetAgent() : TestAgent->new($OptHostName, $AgentPort);
 
 
 #
-- 
2.30.2




More information about the wine-devel mailing list