From f7840f6bdfba174107344b4c723af126b9397dcf Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Fri, 30 Jun 2017 16:09:07 -0300 Subject: [PATCH] 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. --- tests/topotests/lib/topotest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index fa065ad178..b83d75a717 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -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" -- 2.39.5