diff options
Diffstat (limited to 'test/lib/base.py')
-rw-r--r-- | test/lib/base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/lib/base.py b/test/lib/base.py index 7718de93..8f251283 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -52,6 +52,21 @@ env.abort_exception = RuntimeError output.stderr = False +def community_str(i): + """ + Converts integer in to colon separated two bytes decimal strings like + BGP Community or Large Community representation. + + For example, this function converts 13107300 = ((200 << 16) | 100) + into "200:100". + """ + values = [] + while i > 0: + values.append(str(i & 0xffff)) + i >>= 16 + return ':'.join(reversed(values)) + + def wait_for_completion(f, timeout=120): interval = 1 count = 0 |