[dts] [v3 1/6] tests/nic_single_core_perf: beauty JSON string

Lijuan Tu lijuan.tu at intel.com
Wed Mar 31 12:16:54 CEST 2021


with separators and indents, the JSON are more human friendly.

before:
    {"test_perf_nic_single_core": [{ "parameters": [{"name": "Txd/Rxd", ...}, ... }
after:
    {
        "test_perf_nic_single_core": [
            {
                "parameters": [
                    {
                        "name": "Txd/Rxd",
                         ...
                    },
        ...
    }

Signed-off-by: Lijuan Tu <lijuan.tu at intel.com>
---
 tests/TestSuite_nic_single_core_perf.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/TestSuite_nic_single_core_perf.py b/tests/TestSuite_nic_single_core_perf.py
index 8266506b..edb4465d 100644
--- a/tests/TestSuite_nic_single_core_perf.py
+++ b/tests/TestSuite_nic_single_core_perf.py
@@ -368,10 +368,11 @@ class TestNicSingleCorePerf(TestCase):
                     row_dict0['parameters'].append(row_dict4)
                     json_obj[case_name].append(row_dict0)
                     status_result.append(row_dict0['status'])
-        with open(os.path.join(rst.path2Result,
-                               '{0:s}_single_core_perf.json'.format(
-                                   self.nic)), 'w') as fp:
-            json.dump(json_obj, fp)
+
+        json_file = os.path.join(rst.path2Result, '{0:s}_single_core_perf.json'.format(self.nic))
+        with open(json_file, 'w') as fp:
+            json.dump(json_obj, fp, indent=4, separators=(',', ': '), sort_keys=True)
+
         self.verify("FAIL" not in status_result, "Excessive gap between test results and expectations")
 
     def set_fields(self):
-- 
2.25.1



More information about the dts mailing list