[PATCH 3/3] testbot/LibvirtTool: Wait for the X session for live Wine snapshots.

Francois Gouget fgouget at codeweavers.com
Tue Sep 24 04:10:08 CDT 2019


The TestAgentd server may start before the X session. But we need the
latter to run the Wine tests so make sure the X session has started
before creating the live snapshot.

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

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index 72075ae5e..d1402bc49 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -386,6 +386,29 @@ sub CreateSnapshot($$)
 {
   my ($Domain, $SnapshotName) = @_;
 
+  if ($VM->Type eq "wine")
+  {
+    # Make sure an X session has started before taking the snapshot
+    Debug(Elapsed($Start), " Waiting for the X session\n");
+    LogMsg "Waiting for the $VMKey X session\n";
+    my $TA = $VM->GetAgent();
+    my $Pid = $TA->Run(["sh", "-c", "while ! xset -display :0.0 q >/dev/null; do sleep 1; done"], 0);
+    if (!$Pid)
+    {
+      FatalError("Could not check for the X session on the $VMKey VM\n");
+    }
+    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 X session\n");
+      }
+      FatalError("An error occurred while waiting for the X session: $ErrMessage\n");
+    }
+    $TA->Disconnect();
+  }
+
   if ($SleepAfterBoot != 0)
   {
     Debug(Elapsed($Start), " Sleeping for the $SnapshotName snapshot\n");
-- 
2.20.1



More information about the wine-devel mailing list