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

Message ID 20210331101659.506185-2-lijuan.tu@intel.com (mailing list archive)
State Accepted
Headers
Series revise tests/nic_signle_core_perf |

Commit Message

Tu, Lijuan March 31, 2021, 10:16 a.m. UTC
  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@intel.com>
---
 tests/TestSuite_nic_single_core_perf.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Patch

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):