summaryrefslogtreecommitdiff
path: root/validation/test/P2P_throughput/P2P_throughput_caller.py
diff options
context:
space:
mode:
authorJean-Philippe NOEL2013-01-18 15:01:22 +0100
committerJean-Philippe NOEL2013-02-13 12:01:43 +0100
commit2c76a016723c6ac3380ebc591ba4f872402d0b31 (patch)
treedde2abdc9bdcf07e158c278e9fdbd48e16a1929e /validation/test/P2P_throughput/P2P_throughput_caller.py
parentf59ae8a7ac9a1d53511d869aa11a73651c7dc081 (diff)
validation: configuration utilities, refs #3127
Diffstat (limited to 'validation/test/P2P_throughput/P2P_throughput_caller.py')
-rw-r--r--validation/test/P2P_throughput/P2P_throughput_caller.py45
1 files changed, 4 insertions, 41 deletions
diff --git a/validation/test/P2P_throughput/P2P_throughput_caller.py b/validation/test/P2P_throughput/P2P_throughput_caller.py
index 833e1e02c3..503ba27f7c 100644
--- a/validation/test/P2P_throughput/P2P_throughput_caller.py
+++ b/validation/test/P2P_throughput/P2P_throughput_caller.py
@@ -3,10 +3,12 @@
"""Module allowing to call P2P_throughput, with the adequate configuration"""
import numpy
-import P2P_throughput
import sys
import os
+import P2P_throughput
+import validlib.config_utils as config_utils
+
class P2P_throughput_caller:
"""P2P throughput caller"""
@@ -37,46 +39,7 @@ class P2P_throughput_caller:
self._parser = OptionParser(usage = usage)
def run(self, args):
- if len(args) != 2:
- self._parser.error("Bad number of arguments")
- options, args = self._parser.parse_args(args)
- cmd = args[0]
- if cmd not in self._commands:
- self._parser.error("Unknown command \"{0}\".".format(cmd))
-
- template_config = P2P_throughput.evaluate(self.template_config_file)
- config_file = args[1]
-
- try:
- config = P2P_throughput.evaluate(config_file)
- expected = sorted(template_config.keys())
- actual = sorted(config.keys())
- assert actual == expected, (actual, expected)
- except IOError:
- self._parser.error(config_file + " cannot be read.")
- except SyntaxError:
- self._parser.error(config_file + " cannot be evaluated.")
- except AttributeError:
- self._parser.error(config_file + " does not contain a dictionnary.")
- except AssertionError as error:
- (actual, expected) = error.args
- message = file_name + " does not contain exactly the same " \
- "parameters as the template (" + \
- self.template_config_file + ").\n" + \
- config_file + \
- " contains the following parameters:\n" + \
- str(actual) + \
- "\n" + \
- self.template_config_file + \
- " contains the following parameters:\n" + \
- str(expected)
- self._parser.error(message)
- except Exception as error:
- self._parser.error("Unknown error.\n" + \
- str(type(error)) + "\n" + \
- str(error))
-
- self._commands[cmd](config, config_file)
+ config_utils.run(self, args, self.template_config_file)
def run_report(self, config, config_file):
P2P_throughput.report(config, config_file)