[tools 1/3] testbot/SetWinLocale: Better detect when Windows has rebooted.

Francois Gouget fgouget at codeweavers.com
Tue Feb 8 16:46:22 CST 2022


This no longer relies on a long pause to give time for Windows to start
rebooting and should detect when TestAgentd is ready again faster.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/SetWinLocale | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 2324a5cb16..dc551853af 100755
--- a/testbot/bin/SetWinLocale
+++ b/testbot/bin/SetWinLocale
@@ -902,18 +902,19 @@ if ($OptReboot)
 {
   my $Cmd = ["shutdown.exe", "/r", "/t", "0"];
   Debug(Elapsed($Start), " Rebooting: ", join(" ", @$Cmd), "\n");
+  my $OldCount =  $TA->GetProperties("start.count");
   $TA->Run($Cmd, 0);
   # Note that we cannot wait for this command since it reboots Windows
 
-  # Wait a bit to make sure we don't reconnect before Windows has rebooted.
-  sleep(30);
-
-  Debug(Elapsed($Start), " Waiting for Windows to boot\n");
-  $TA->SetConnectTimeout(undef, undef, $WaitForBoot);
-  if (!$TA->Ping())
+  my ($OneTimeout, $MinAttempts, $MinTimeout) = $TA->SetConnectTimeout(3, 1, 3);
+  while (1)
   {
-    FatalError("could not reconnect to $OptHostName after the reboot: ", $TA->GetLastError(), "\n");
+    my $NewCount = $TA->GetProperties("start.count");
+    next if (!defined $NewCount); # Rebooting (TestAgentd is not running)
+    last if ($NewCount != $OldCount); # start.count got incremented
+    sleep(10); # Not rebooting yet
   }
+  $TA->SetConnectTimeout($OneTimeout, $MinAttempts, $MinTimeout);
 
   # Skip this check on pre-Windows 10 versions, i.e. those that don't have
   # 'CountryName' and if the settings were not changed in the first place.
-- 
2.30.2




More information about the wine-devel mailing list