import os
import re
import sys
-import difflib
import pytest
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IP RIP status",
- tofile="expected IP RIP status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual IP RIP status",
+ title2="expected IP RIP status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IPv6 RIPng status",
- tofile="expected IPv6 RIPng status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual IPv6 RIPng status",
+ title2="expected IPv6 RIPng status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW IP OSPF INTERFACE",
- tofile="expected SHOW IP OSPF INTERFACE"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW IP OSPF INTERFACE",
+ title2="expected SHOW IP OSPF INTERFACE")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW ISIS INTERFACE DETAIL",
- tofile="expected SHOW ISIS OSPF6 INTERFACE DETAIL"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW ISIS INTERFACE DETAIL",
+ title2="expected SHOW ISIS OSPF6 INTERFACE DETAIL")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW IP BGP SUMMARY",
- tofile="expected SHOW IP BGP SUMMARY"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW IP BGP SUMMARY",
+ title2="expected SHOW IP BGP SUMMARY")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW BGP IPv6 SUMMARY",
- tofile="expected SHOW BGP IPv6 SUMMARY"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv6 SUMMARY",
+ title2="expected SHOW BGP IPv6 SUMMARY")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW BGP IPv4",
- tofile="expected SHOW BGP IPv4"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv4",
+ title2="expected SHOW BGP IPv4")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW BGP IPv6",
- tofile="expected SHOW BGP IPv6"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW BGP IPv6",
+ title2="expected SHOW BGP IPv6")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS LDP interface status",
- tofile="expected MPLS LDP interface status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS LDP interface status",
+ title2="expected MPLS LDP interface status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
import os
import re
import sys
-import difflib
import pytest
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual BGP routing table",
- tofile="expected BGP routing table"))
- # Empty string if it matches, otherwise diff contains unified diff
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual BGP routing table",
+ title2="expected BGP routing table")
if diff:
sys.stderr.write('r%s failed Routing Table Check for view %s:\n%s\n'
import os
import re
import sys
-import difflib
import pytest
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS LDP interface status",
- tofile="expected MPLS LDP interface status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS LDP interface status",
+ title2="expected MPLS LDP interface status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS LDP discovery output",
- tofile="expected MPLS LDP discovery output"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS LDP discovery output",
+ title2="expected MPLS LDP discovery output")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS LDP neighbor output",
- tofile="expected MPLS LDP neighbor output"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS LDP neighbor output",
+ title2="expected MPLS LDP neighbor output")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
swapped = True
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS LDP binding output",
- tofile="expected MPLS LDP binding output"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS LDP binding output",
+ title2="expected MPLS LDP binding output")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IPv4 zebra routing table",
- tofile="expected IPv4 zera routing table"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual IPv4 zebra routing table",
+ title2="expected IPv4 zebra routing table")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
swapped = True
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual MPLS table output",
- tofile="expected MPLS table output"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual MPLS table output",
+ title2="expected MPLS table output")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual Linux Kernel MPLS route",
- tofile="expected Linux Kernel MPLS route"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual Linux Kernel MPLS route",
+ title2="expected Linux Kernel MPLS route")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
import StringIO
import subprocess
import platform
+import difflib
from mininet.topo import Topo
from mininet.net import Mininet
else:
return True
+def get_textdiff(text1, text2, title1="", title2=""):
+ "Returns empty string if same or formatted diff"
+
+ diff = '\n'.join(difflib.context_diff(text1, text2,
+ fromfile=title1, tofile=title2))
+ # Clean up line endings
+ diff = os.linesep.join([s for s in diff.splitlines() if s])
+ return diff
+
def checkAddressSanitizerError(output, router, component):
"Checks for AddressSanitizer in output. If found, then logs it and returns true, false otherwise"
-----/
"""
-# import os
-# import re
-# import sys
-# import difflib
-# import StringIO
-# import glob
-# import subprocess
-
-# from mininet.topo import Topo
-# from mininet.net import Mininet
-# from mininet.node import Node, OVSSwitch, Host
-# from mininet.log import setLogLevel, info
-# from mininet.cli import CLI
-
-# from functools import partial
-# from time import sleep
-
-# import pytest
-
import os
import re
import sys
-import difflib
import pytest
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual OSPFv3 IPv6 routing table",
- tofile="expected OSPFv3 IPv6 routing table"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual OSPFv3 IPv6 routing table",
+ title2="expected OSPFv3 IPv6 routing table")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
# print(line.rstrip())
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IPv6 kernel routing table",
- tofile="expected IPv6 kernel routing table"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual OSPFv3 IPv6 routing table",
+ title2="expected OSPFv3 IPv6 routing table")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
import os
import re
import sys
-import difflib
import pytest
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IP RIP status",
- tofile="expected IP RIP status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual IP RIP status",
+ title2="expected IP RIP status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW IP RIP",
- tofile="expected SHOW IP RIP"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW IP RIP",
+ title2="expected SHOW IP RIP")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual Zebra IPv4 routing table",
- tofile="expected Zebra IPv4 routing table"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual Zebra IPv4 routing table",
+ title2="expected Zebra IPv4 routing table")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
import os
import re
import sys
-import difflib
import pytest
import unicodedata
from time import sleep
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual IPv6 RIPng status",
- tofile="expected IPv6 RIPng status"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual IPv6 RIPng status",
+ title2="expected IPv6 RIPng status")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual SHOW IPv6 RIPng",
- tofile="expected SHOW IPv6 RIPng"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual SHOW IPv6 RIPng",
+ title2="expected SHOW IPv6 RIPng")
# Empty string if it matches, otherwise diff contains unified diff
if diff:
actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1)
# Generate Diff
- diff = ''.join(difflib.context_diff(actual, expected,
- fromfile="actual Zebra IPv6 routing table",
- tofile="expected Zebra IPv6 routing table"))
+ diff = topotest.get_textdiff(actual, expected,
+ title1="actual Zebra IPv6 routing table",
+ title2="expected Zebra IPv6 routing table")
# Empty string if it matches, otherwise diff contains unified diff
if diff: