[tools] testbot/LibvirtTool: Move waiting for the X session start to its own function.

Francois Gouget fgouget at codeweavers.com
Mon Feb 14 09:47:15 CST 2022


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/bin/LibvirtTool.pl | 43 ++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index e2f2fd3c46..ef94a2be09 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -441,6 +441,30 @@ sub CheckOff()
   return ChangeStatus("dirty", "off", "done");
 }
 
+sub WaitForSession($)
+{
+  my ($TA) = @_;
+
+  if ($VM->Type eq "wine")
+  {
+    # For Wine VMs we have to wait some more for the X session to start.
+    Debug(Elapsed($Start), " Waiting for the X session\n");
+    LogMsg "Waiting for the $VMKey X session\n";
+    my $Pid = $TA->Run(["sh", "-c", "while ! xset -display :0.0 q >/dev/null; do sleep 1; done"], 0);
+    FatalError("Could not check for the $VMKey X session\n") if (!$Pid);
+
+    if (!defined $TA->Wait($Pid, $SleepAfterBoot))
+    {
+      my $ErrMessage = $TA->GetLastError();
+      if ($ErrMessage =~ /timed out waiting for the child process/)
+      {
+        FatalError("Timed out waiting for the $VMKey X session\n");
+      }
+      FatalError("An error occurred while waiting for the $VMKey X session: $ErrMessage\n");
+    }
+  }
+}
+
 sub SetupTestAgentd($$$)
 {
   my ($Booting, $UpgradeTestAgentd, $ResetStartCount) = @_;
@@ -506,24 +530,7 @@ sub SetupTestAgentd($$$)
     FatalError("Setting the $VMKey VM system time failed: ". $PTA->GetLastError() ."\n");
   }
 
-  if ($Booting and $VM->Type eq "wine")
-  {
-    # Make sure the X session has had time to start
-    Debug(Elapsed($Start), " Waiting for the X session\n");
-    LogMsg "Waiting for the $VMKey X session\n";
-    my $Pid = $TA->Run(["sh", "-c", "while ! xset -display :0.0 q >/dev/null; do sleep 1; done"], 0);
-    FatalError("Could not check for the $VMKey X session\n") if (!$Pid);
-
-    if (!defined $TA->Wait($Pid, $SleepAfterBoot))
-    {
-      my $ErrMessage = $TA->GetLastError();
-      if ($ErrMessage =~ /timed out waiting for the child process/)
-      {
-        FatalError("Timed out waiting for the $VMKey X session\n");
-      }
-      FatalError("An error occurred while waiting for the $VMKey X session: $ErrMessage\n");
-    }
-  }
+  WaitForSession($TA) if ($Booting);
 
   if ($ResetStartCount)
   {
-- 
2.30.2



More information about the wine-devel mailing list