From 5ba31a4e2e27cf0f78e4db138c42b79d8e0ccc95 Mon Sep 17 00:00:00 2001 From: Ciara Power Date: Tue, 2 Feb 2021 16:58:16 +0000 Subject: [PATCH] app/crypto-perf: fix handling of config parameters The crypto perf graphing script did not handle parsing parameters from the JSON config files correctly. A common parsing function is used for both EAL and app parameters, to ensure they are handled the same way and to reduce code duplication. Short parameters are now passed with the value being a second argument, rather than as one argument with dividing space. Long parameters with no expected value are supported for EAL now also. e.g. "--no-huge" can be added to config as "no-huge": true Fixes: f400e0b82bf1 ("app/crypto-perf: add script to graph perf results") Signed-off-by: Ciara Power Acked-by: Adam Dybkowski --- .../dpdk-graph-crypto-perf.py | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/app/test-crypto-perf/dpdk-graph-crypto-perf.py b/app/test-crypto-perf/dpdk-graph-crypto-perf.py index f4341ee718..02322d2d7e 100755 --- a/app/test-crypto-perf/dpdk-graph-crypto-perf.py +++ b/app/test-crypto-perf/dpdk-graph-crypto-perf.py @@ -192,10 +192,23 @@ def run_test(test_cmd, test, grapher, params, verbose): return +def parse_parameters(config_parameters): + """Convert the JSON config to list of strings.""" + params = [] + for (key, val) in config_parameters: + if isinstance(val, bool): + params.append("--" + key if val is True else "") + elif len(key) == 1: + params.append("-" + key) + params.append(val) + else: + params.append("--" + key + "=" + val) + return params + + def run_test_suite(test_cmd, suite_config, verbose): """Parse test cases for the test suite and run each test.""" print("\nRunning Test Suite: " + suite_config['suite']) - default_params = [] graph_path = os.path.join(suite_config['output_path'], GRAPH_DIR, suite_config['suite'], "") grapher = Grapher(suite_config['config_name'], suite_config['suite'], @@ -204,18 +217,10 @@ def run_test_suite(test_cmd, suite_config, verbose): if 'default' not in test_cases: print("Test Suite must contain default case, skipping") return - for (key, val) in test_cases['default']['eal'].items(): - if len(key) == 1: - default_params.append("-" + key + " " + val) - else: - default_params.append("--" + key + "=" + val) + default_params = parse_parameters(test_cases['default']['eal'].items()) default_params.append("--") - for (key, val) in test_cases['default']['app'].items(): - if isinstance(val, bool): - default_params.append("--" + key if val is True else "") - else: - default_params.append("--" + key + "=" + val) + default_params += parse_parameters(test_cases['default']['app'].items()) if 'ptest' not in test_cases['default']['app']: print("Test Suite must contain default ptest value, skipping") @@ -224,13 +229,7 @@ def run_test_suite(test_cmd, suite_config, verbose): for (test, params) in {k: v for (k, v) in test_cases.items() if k != "default"}.items(): - extra_params = [] - for (key, val) in params.items(): - if isinstance(val, bool): - extra_params.append("--" + key if val is True else "") - else: - extra_params.append("--" + key + "=" + val) - + extra_params = parse_parameters(params.items()) run_test(test_cmd, test, grapher, default_params + extra_params, verbose) -- 2.20.1