Commit b8df3bfe authored by Matous Holinka's avatar Matous Holinka Committed by Ondřej Zajíček

Netlab: New BFD testing functions added

parent e95bf9f3
#!/bin/sh
. tests/strip_output
cd $1 && ./birdc -l show bfd sessions $2 \
| strip_version \
| strip_timestamp \
| tail +4 \
| sort
......@@ -118,3 +118,33 @@ def check_expected_logs(log_messages: List[str], logfile: str) -> bool:
if os.system(f"egrep '{message}' {logfile}"):
return False
return True
def test_bfd_sessions(**kwargs) -> None:
if cf.save:
save_bfd_sessions(kwargs["key"], kwargs["dev"], kwargs["opts"])
else:
check_bfd_sessions(kwargs["key"], kwargs["dev"], kwargs["opts"])
def save_bfd_sessions(key: str, dev: str, opts: str,
loc: str = cf.datadir) -> None:
os.system(f"./tests/get_stdout_bfd '{dev}' '{opts}' > {loc}/{key}-{dev}")
def timeout_decorator(func):
def inner(key, dev, opts):
for _ in range(61):
if func(key, dev, opts):
return
time.sleep(1)
assert 0
return inner
@timeout_decorator
def check_bfd_sessions(key, dev, opts) -> bool:
save_bfd_sessions(key, dev, opts, cf.tempdir)
current_table = read_file(f"{cf.tempdir}/{key}-{dev}")
saved_table = read_file(f"{cf.datadir}/{key}-{dev}")
return current_table == saved_table
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment