lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZGu3x6suTe1RiCvl@kernel.org>
Date:   Mon, 22 May 2023 15:43:19 -0300
From:   Arnaldo Carvalho de Melo <acme@...nel.org>
To:     Anup Sharma <anupnewsmail@...il.com>
Cc:     Ian Rogers <irogers@...gle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] perf: test: Add support for testing JSON generated by
 perf data command

Em Mon, May 22, 2023 at 03:31:06PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Mon, May 22, 2023 at 03:28:20PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Mon, May 22, 2023 at 11:10:43AM -0700, Ian Rogers escreveu:
> > > On Fri, May 19, 2023 at 12:41 AM Anup Sharma <anupnewsmail@...il.com> wrote:
> > > >
> > > > 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 validation step to ensure that
> > > > the resulting JSON file is contain valid data.
> > > >
> > > > Signed-off-by: Anup Sharma <anupnewsmail@...il.com>
> > > 
> > > Acked-by: Ian Rogers <irogers@...gle.com>
> > 
> > I'm fixing these and some other identation minor issues:
> 
I have this on top, making the indentation to be consistent, using tabs,
as the other .sh files in that directory and also having the 'then' be
on the 'if' line, separated by ;

diff --git a/tools/perf/tests/shell/test_perf_data_converter_json.sh b/tools/perf/tests/shell/test_perf_data_converter_json.sh
index 8f4d6575f34fa82e..72ac6c83231c03d5 100755
--- a/tools/perf/tests/shell/test_perf_data_converter_json.sh
+++ b/tools/perf/tests/shell/test_perf_data_converter_json.sh
@@ -1,18 +1,15 @@
 #!/bin/bash
-# perf data json converter command test
+# 'perf data convert --to-json' command test
 # SPDX-License-Identifier: GPL-2.0
 
 set -e
 
 err=0
 
-if [ "$PYTHON" = "" ]
-then
-	if which python3 > /dev/null
-	then
+if [ "$PYTHON" = "" ] ; then
+	if which python3 > /dev/null ; then
 		PYTHON=python3
-	elif which python > /dev/null
-	then
+	elif which python > /dev/null ; then
 		PYTHON=python
 	else
 		echo Skipping test, python not detected please set environment variable PYTHON.
@@ -42,8 +39,7 @@ test_json_converter_command()
 	echo "Testing Perf Data Convertion Command to JSON"
 	perf record -o "$perfdata" -F 99 -g -- perf test -w noploop > /dev/null 2>&1
 	perf data convert --to-json "$result" --force -i "$perfdata" >/dev/null 2>&1
-	if [ $(cat "${result}" | wc -l) -gt "0" ]
-	then
+	if [ $(cat "${result}" | wc -l) -gt "0" ] ; then
 		echo "Perf Data Converter Command to JSON [SUCCESS]"
 	else
 		echo "Perf Data Converter Command to JSON [FAILED]"
@@ -54,22 +50,20 @@ test_json_converter_command()
 
 validate_json_format()
 {
-    echo "Validating Perf Data Converted JSON file"
-    if [ -f "$result" ]
-    then
-        if $PYTHON -c  "import json; json.load(open('$result'))" >/dev/null 2>&1
-	then
-            echo "The file contains valid JSON format [SUCCESS]"
-        else
-            echo "The file does not contain valid JSON format [FAILED]"
-            err=1
-	    exit
-        fi
-    else
-        echo "File not found [FAILED]"
-        err=2
-        exit
-    fi
+	echo "Validating Perf Data Converted JSON file"
+	if [ -f "$result" ] ; then
+		if $PYTHON -c  "import json; json.load(open('$result'))" >/dev/null 2>&1 ; then
+			echo "The file contains valid JSON format [SUCCESS]"
+		else
+			echo "The file does not contain valid JSON format [FAILED]"
+			err=1
+			exit
+		fi
+	else
+		echo "File not found [FAILED]"
+		err=2
+		exit
+	fi
 }
 
 test_json_converter_command

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ