]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Look for zlog_backtrace in ci system
authorDonald Sharp <sharpd@nvidia.com>
Thu, 29 Jun 2023 19:12:57 +0000 (15:12 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 10 Jul 2023 13:06:40 +0000 (09:06 -0400)
There are parts of our daemons that upon certain types
of errors that a zlog_backtrace is auto-generated.
It is desirable for this to be caught and have the
test auto-failed.

Issue: #13787
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
tests/topotests/conftest.py

index cb25d63a360f912d83328f261a7538c51e244bae..27a6909a46a5a43da7c8c6927e98710f5e97384d 100755 (executable)
@@ -297,6 +297,39 @@ def check_for_memleaks():
         pytest.fail("memleaks found for daemons: " + " ".join(daemons))
 
 
+def check_for_backtraces():
+    backtraces = []
+    tgen = get_topogen()  # pylint: disable=redefined-outer-name
+    latest = []
+    existing = []
+
+    if tgen is not None:
+        logdir = tgen.logdir
+        if hasattr(tgen, "backtraces_existing_files"):
+            existing = tgen.backtraces_existing_files
+        latest = glob.glob(os.path.join(logdir, "*/*.log"))
+
+    daemons = []
+    for vfile in latest:
+        if vfile in existing:
+            continue
+        with open(vfile, encoding="ascii") as vf:
+            vfcontent = vf.read()
+            backtrace = vfcontent.count("Backtrace:")
+            if backtrace:
+                existing.append(vfile)  # have backtrace don't check again
+                emsg = "Backtrace found in {}, failing test".format(vfile)
+                backtraces.append(emsg)
+
+    if tgen is not None:
+        tgen.backtrace_existing_files = existing
+
+    if backtraces:
+        logger.error("Backtraces found in test suite, erroring")
+        logger.error(backtraces)
+        pytest.fail("Backtraces found")
+
+
 @pytest.fixture(autouse=True, scope="module")
 def module_autouse(request):
     basename = get_test_logdir(request.node.nodeid, True)
@@ -320,6 +353,7 @@ def module_check_memtest(request):
     if request.config.option.memleaks:
         if get_topogen() is not None:
             check_for_memleaks()
+    check_for_backtraces()
 
 
 #