topotest: add text normalization function

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.
This commit is contained in:
Rafael Zalamena 2017-06-30 16:09:07 -03:00 committed by Donald Sharp
parent d176de4d0a
commit f7840f6bdf

View 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"