With this patch all findadv tests pass now.

This is result of collaboration with Tommaso. Not important for alpha,
but also no side effects to the rest.

        Kornel

Attachment: signature.asc
Description: This is a digitally signed message part.

diff --git a/development/autotests/bug-export-latex-in.txt b/development/autotests/bug-export-latex-in.txt
index b45c815..9b6ae27 100644
--- a/development/autotests/bug-export-latex-in.txt
+++ b/development/autotests/bug-export-latex-in.txt
@@ -7,6 +7,8 @@ TestBegin -dbg files test.lyx > lyx-log.txt 2>&1
 KK: \Axinfo-insert icon math-mode\[Return]
 KK: \Axbuffer-export luatex\[Return]
 KK: \[Tab]\[Return]
+KK: \Axbuffer-write\[Return]
+KK: \[Tab]\[Return]
 TestEnd
 Lang C
 Assert ! pcregrep -M "support/FileName.cpp .* creating path '/.*/lib/images'" lyx-log.txt
diff --git a/development/autotests/keytest.py b/development/autotests/keytest.py
index 3a60927..f6551e9 100755
--- a/development/autotests/keytest.py
+++ b/development/autotests/keytest.py
@@ -169,12 +169,39 @@ def intr_system(cmd, ignore_err = False):
         raise BaseException("command failed:" + cmd)
     return ret
 
+statreg = re.compile(r'^State:.*\(([a-z]+)\)')
+
+def lyx_status(pid):
+  if lyx_pid is None:
+    return "dead"
+  fname = '/proc/' + pid + '/status'
+  try:
+    f = open(fname)
+    for line in f:
+      m = statreg.match(line)
+      if m:
+        status = m.group(1)
+        f.close()
+        return status
+    f.close()
+  except IOError as e:
+     print "I/O error({0}): {1}".format(e.errno, e.strerror)
+     return "dead"
+  except:
+    print "Unexpected error:", sys.exc_info()[0]
+  return "dead"
 
 # Return true if LyX (identified via lyx_pid) is sleeping
 def lyx_sleeping():
-    fname = '/proc/' + lyx_pid + '/status'
-    return intr_system("grep 'State.*sleeping' " + fname, True)
+    return lyx_status(lyx_pid) == "sleeping"
+
+# Return true if LyX (identified via lyx_pid) is zombie
+def lyx_zombie():
+    return lyx_status(lyx_pid) == "zombie"
 
+def lyx_dead():
+    status = lyx_status(lyx_pid)
+    return (status == "dead") or (status == "zombie")
 
 def sendKeystring(keystr, LYX_PID):
 
@@ -365,6 +392,7 @@ while not failed:
             failed = True
         print 'lyx_pid: ' + lyx_pid + '\n'
         print 'lyx_win: ' + lyx_window_name + '\n'
+        sendKeystring("\C\[Home]", lyx_pid)
     elif c[0:5] == 'Sleep':
         print "Sleeping for " + c[6:] + " seconds\n"
         time.sleep(float(c[6:]))
@@ -400,15 +428,20 @@ while not failed:
         failed = failed or (result != 0)
         print "result=" + str(result) + ", failed=" + str(failed)
     elif c[0:7] == 'TestEnd':
-        time.sleep(0.5)
+#        time.sleep(0.5)
         if not lyx_exists():
             print "LyX instance not found because of crash or assert !\n"
             failed = True
         else:
-            print "Terminating lyx instance: " + str(lyx_pid) + "\n"
-            intr_system("kill -9 " + str(lyx_pid), True);
-            while lyx_exists():
-                print "Waiting for lyx to die...\n"
+            print "Forcing quit of lyx instance: " + str(lyx_pid) + "...\n"
+            # intr_system("kill -9 " + str(lyx_pid), True);
+            sendKeystring("\Cq", lyx_pid)
+            lcount = 0
+            while not lyx_dead():
+                lcount = lcount + 1
+                if lcount > 20:
+                    print "LyX still up, killing process and waiting for it to die...\n"
+                    intr_system("kill -9 " + str(lyx_pid), True);
                 time.sleep(0.5)
         cmd = c[8:].rstrip()
         print "Executing " + cmd

Reply via email to