• Anup Sharma's avatar
    perf test: Add test validating JSON generated by 'perf data convert --to-json' · 68d12418
    Anup Sharma authored
    This commit adds support for testing the JSON output generated by the
    'perf data' command's conversion to JSON functionality.
    
    The test script now includes a step to ensure that the resulting JSON
    file contains valid data.
    
    Changes:
    V1 -> V2:
    
    Added a check for the existence of the result output file.
    Replaced the usage of jq with json.load for validating the JSON format.
    Checks using ShellCheck and checkpatch, addressing and resolving warnings.
    Removed the unnecessary root permission check.
    Modified the 'perf record' command to avoid requiring root permissions.
    
    Committer testing:
    
      $ perf test to-json
      115: 'perf data convert --to-json' command test                      : Ok
      $ perf test -v to-json
      Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
      115: 'perf data convert --to-json' command test                      :
      --- start ---
      test child forked, pid 1746867
      Testing Perf Data Convertion Command to JSON
      Perf Data Converter Command to JSON [SUCCESS]
      Validating Perf Data Converted JSON file
      The file contains valid JSON format [SUCCESS]
      test child finished with 0
      ---- end ----
      'perf data convert --to-json' command test: Ok
      $
    Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
    Acked-by: default avatarIan Rogers <irogers@google.com>
    Link: https://lore.kernel.org/r/ZGcoJBAGlknjsA/n@yogaTested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Anup Sharma <anupnewsmail@gmail.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-perf-users@vger.kernel.org
    [ Fixup indentation to use consistently tabs, not a mixture of spaces and tabs, have 'if ... ; then'  on the same line ]
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    68d12418
test_perf_data_converter_json.sh 1.45 KB