diff options
| author | Lou Berger <lberger@labn.net> | 2018-05-21 09:47:18 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-11-27 20:22:14 -0500 |
| commit | da63d5b319b42cd54f2590bd96cd71037f7c828c (patch) | |
| tree | 158e79d1d3ecb0e0ad970a8ac99175400e9cb11e | |
| parent | deb4cef09a277a6ca7e730b540742415c338b6e4 (diff) | |
lib: use per node log directory when topotest is used without topogen
Signed-off-by: Lou Berger <lberger@labn.net>
| -rw-r--r-- | tests/topotests/lib/topotest.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index 4344781b5a..fbdb9bbbc1 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -59,6 +59,24 @@ class json_cmp_result(object): "Returns True if there were errors, otherwise False." return len(self.errors) > 0 +def get_test_logdir(node=None, init=False): + """ + Return the current test log directory based on PYTEST_CURRENT_TEST + environment variable. + Optional paramters: + node: when set, adds the node specific log directory to the init dir + init: when set, initializes the log directory and fixes path permissions + """ + cur_test = os.environ['PYTEST_CURRENT_TEST'] + + ret = '/tmp/topotests/' + cur_test[0:cur_test.find(".py")].replace('/','.') + if node != None: + dir = ret + "/" + node + if init: + os.system('mkdir -p ' + dir) + os.system('chmod 775 ' + dir) + return ret + def json_diff(d1, d2): """ Returns a string with the difference between JSON data. @@ -462,7 +480,7 @@ class Router(Node): def __init__(self, name, **params): super(Router, self).__init__(name, **params) - self.logdir = params.get('logdir', '/tmp') + self.logdir = params.get('logdir', get_test_logdir(name, True)) self.daemondir = None self.hasmpls = False self.routertype = 'frr' |
