]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: topotests/lib/lutil.py: optimize wait to not repeat command after expected...
authorLou Berger <lberger@labn.net>
Tue, 26 Oct 2021 14:56:50 +0000 (10:56 -0400)
committerLou Berger <lberger@labn.net>
Tue, 26 Oct 2021 14:56:50 +0000 (10:56 -0400)
Signed-off-by: Lou Berger <lberger@labn.net>
tests/topotests/lib/lutil.py

index c17c7f14e76ea04595e17bb2a966b4114648a7c6..5c1fa24a7b120cac20ac95821445c7e6c72441b5 100644 (file)
@@ -189,11 +189,8 @@ Total %-4d                                                           %-4d %d\n\
             self.log("unable to read: " + tstFile)
             sys.exit(1)
 
-    def command(self, target, command, regexp, op, result, returnJson):
+    def command(self, target, command, regexp, op, result, returnJson, startt=None):
         global net
-        if op != "wait":
-            self.l_line += 1
-
         if op == "jsoncmp_pass" or op == "jsoncmp_fail":
             returnJson = True
 
@@ -294,7 +291,11 @@ Total %-4d                                                           %-4d %d\n\
                     % (group_nl_converted, ret),
                     9,
                 )
-        if op == "pass" or op == "fail":
+        if startt != None:
+            if js != None or ret is not False:
+                delta = time.time() - startt
+                self.result(target, success, "%s +%4.2f secs" % (result, delta))
+        elif op == "pass" or op == "fail":
             self.result(target, success, result)
         if js != None:
             return js
@@ -326,7 +327,7 @@ Total %-4d                                                           %-4d %d\n\
 
         while wait_count > 0:
             n += 1
-            found = self.command(target, command, regexp, op, result, returnJson)
+            found = self.command(target, command, regexp, op, result, returnJson, startt)
             if found is not False:
                 break
 
@@ -336,14 +337,6 @@ Total %-4d                                                           %-4d %d\n\
 
         delta = time.time() - startt
         self.log("Done after %d loops, time=%s, Found=%s" % (n, delta, found))
-        found = self.command(
-            target,
-            command,
-            regexp,
-            "pass",
-            "%s +%4.2f secs" % (result, delta),
-            returnJson,
-        )
         return found