]> git.puffer.fish Git - matthieu/frr.git/commitdiff
topotest: add text normalization function
authorRafael Zalamena <rzalamena@gmail.com>
Fri, 30 Jun 2017 19:09:07 +0000 (16:09 -0300)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:11 +0000 (20:22 -0500)
Standardized function that removes format spaces (or tab) and carriage
returns characters. This function is useful to allow output text
processing without breaking diff capabilities.

Output example:
*N IA 2001:db8:2::/64                ::                        r2-eth0    00:03:39

Becomes:
*N IA 2001:db8:2::/64 :: r2-eth0 00:03:39

If you remove 'IA' you won't have space formatting problem anymore.

tests/topotests/lib/topotest.py

index fa065ad1787f15668a9eef7fe856261dcd9d6aa8..b83d75a717781b39173e3cd3a34105fab3794281 100644 (file)
@@ -224,6 +224,14 @@ def get_file(content):
     fde.close()
     return fname
 
+def normalize_text(text):
+    """
+    Strips formating spaces/tabs and carriage returns.
+    """
+    text = re.sub(r'[ \t]+', ' ', text)
+    text = re.sub(r'\r', '', text)
+    return text
+
 def checkAddressSanitizerError(output, router, component):
     "Checks for AddressSanitizer in output. If found, then logs it and returns true, false otherwise"