summaryrefslogtreecommitdiff
path: root/tests/helpers
diff options
context:
space:
mode:
authorGalaxyGorilla <sascha@netdef.org>2020-11-17 13:11:34 +0000
committerGalaxyGorilla <sascha@netdef.org>2020-11-17 13:19:44 +0000
commit6fc170c5afc188cf9253f177fc7478595e4cafee (patch)
treec18865613b9a006938cfa66871bd070735eaa73a /tests/helpers
parentb1545a5c598b4f9a846126b94c33b792bae7f2e4 (diff)
tests: ignore Windows vs Unix style newlines
Within unit tests the output of vtysh commands is compared to hand made reference files. For some reason the output of those vtysh commands contains Windows Style newlines which results in error outputs which make it hard to identify this problem. Since there seems to be no benefit in checking those newlines anyway this commit just normalizes them. Signed-off-by: GalaxyGorilla <sascha@netdef.org>
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/python/frrtest.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/helpers/python/frrtest.py b/tests/helpers/python/frrtest.py
index 0ac54fd900..584fa90374 100644
--- a/tests/helpers/python/frrtest.py
+++ b/tests/helpers/python/frrtest.py
@@ -168,8 +168,8 @@ class TestMultiOut(_TestMultiOut):
class TestRefMismatch(Exception):
def __init__(self, _test, outtext, reftext):
- self.outtext = outtext.decode("utf8") if type(outtext) is bytes else outtext
- self.reftext = reftext.decode("utf8") if type(reftext) is bytes else reftext
+ self.outtext = outtext
+ self.reftext = reftext
def __str__(self):
rv = "Expected output and actual output differ:\n"
@@ -214,7 +214,12 @@ class TestRefOut(object):
[binpath(program)], stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
outtext, _ = proc.communicate(intext)
- if outtext != reftext:
- raise TestRefMismatch(self, outtext, reftext)
+
+ # Get rid of newline problems (Windows vs Unix Style)
+ outtext_str = outtext.decode("utf8").replace("\r\n", "\n").replace("\r", "\n")
+ reftext_str = reftext.decode("utf8").replace("\r\n", "\n").replace("\r", "\n")
+
+ if outtext_str != reftext_str:
+ raise TestRefMismatch(self, outtext_str, reftext_str)
if proc.wait() != 0:
raise TestExitNonzero(self)