From af99f19eb2ad5158afe97093ced4aab83d66f3ce Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 15 Dec 2018 10:49:59 -0500 Subject: [PATCH 1/2] topotests: Cleanup diagnose_env to allow thought about multi-platforms Start the cleanup of diagnose_env to allow the running of topotests on platforms besides linux. So we split up diagnose_env into linux and freebsd variants. At this point in time freebsd doesn't have any special code. To be determined in the future. Signed-off-by: Donald Sharp --- tests/topotests/lib/topogen.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 25edfe0324..8688a13aef 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -908,7 +908,7 @@ class TopoExaBGP(TopoHost): # Disable linter branch warning. It is expected to have these here. # pylint: disable=R0912 -def diagnose_env(): +def diagnose_env_linux(): """ Run diagnostics in the running environment. Returns `True` when everything is ok, otherwise `False`. @@ -1066,3 +1066,14 @@ def diagnose_env(): logger.removeHandler(fhandler) return ret + +def diagnose_env_freebsd(): + return True + +def diagnose_env(): + if sys.platform.startswith("linux"): + return diagnose_env_linux() + elif sys.platform.startswith("freebsd"): + return diagnose_env_freebsd() + + return False From cc95fbd9ffc193c7aefdef6bfad2d99067b635be Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 15 Dec 2018 10:54:11 -0500 Subject: [PATCH 2/2] topotests: Start abstraction of module_present for other platforms Start abstraction of the module_present into module_present_linux and freebsd To allow for multiple platforms that the topotests can be run on. Signed-off-by: Donald Sharp --- tests/topotests/lib/topotest.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index e9b8d34ec3..6d3e512a4d 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -336,7 +336,7 @@ def normalize_text(text): return text -def module_present(module, load=True): +def module_present_linux(module, load): """ Returns whether `module` is present. @@ -352,6 +352,15 @@ def module_present(module, load=True): else: return True +def module_present_freebsd(module, load): + return True + +def module_present(module, load=True): + if sys.platform.startswith("linux"): + module_present_linux(module, load) + elif sys.platform.startswith("freebsd"): + module_present_freebsd(module, load) + def version_cmp(v1, v2): """ Compare two version strings and returns: