linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] perf test: Add support for testing gecko script
@ 2023-08-12  7:16 Anup Sharma
  2023-08-12 21:46 ` Anup Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Anup Sharma @ 2023-08-12  7:16 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	  Adrian Hunter, Anup Sharma, linux-perf-users, linux-kernel

This commit add support for testing gecko script. The test checks
for the presence of required sections such as "meta," "threads,"
"samples," "frameTable," "stackTable," "stringTable," and
"pausedRanges" which are few essential parameter to be present
in output file. Also it verifies the validity of the JSON format
using Python's JSON library if available.

Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>

---
Patch needed for testing:
    https://lore.kernel.org/linux-perf-users/ZNOS0vo58DnVLpD8@yoga/T/#u

changes in v2:
    - Removed uncessary prepare_perf_data.
    - provided patch which is required for testing this patch.
---
 tools/perf/tests/shell/test_gecko.sh | 130 +++++++++++++++++++++++++++
 1 file changed, 130 insertions(+)
 create mode 100755 tools/perf/tests/shell/test_gecko.sh

diff --git a/tools/perf/tests/shell/test_gecko.sh b/tools/perf/tests/shell/test_gecko.sh
new file mode 100755
index 000000000000..44160eff87fd
--- /dev/null
+++ b/tools/perf/tests/shell/test_gecko.sh
@@ -0,0 +1,130 @@
+#!/bin/bash
+# perf script gecko test
+# SPDX-License-Identifier: GPL-2.0
+
+err=0
+
+cleanup() {
+  rm -rf gecko_profile.json
+  trap - exit term int
+}
+
+trap_cleanup() {
+  cleanup
+  exit 1
+}
+trap trap_cleanup exit term int
+
+report() {
+    if [ "$1" = 0 ]; then
+        echo "PASS: \"$2\""
+    else
+        echo "FAIL: \"$2\" Error message: \"$3\""
+        err=1
+    fi
+}
+
+find_str_or_fail() {
+    grep -q "$1" <<< "$2"
+    if [ "$?" != 0 ]; then
+        report 1 "$3" "Failed to find required string:'${1}'."
+    else
+        report 0 "$3"
+    fi
+}
+
+# To validate the json format, check if python is installed
+if [ "$PYTHON" = "" ] ; then
+	if which python3 > /dev/null ; then
+		PYTHON=python3
+	elif which python > /dev/null ; then
+		PYTHON=python
+	else
+		echo Skipping JSON format check, python not detected please set environment variable PYTHON.
+		PYTHON_NOT_AVAILABLE=1
+	fi
+fi
+
+# Check execution of perf script gecko command
+test_gecko_command() {
+    echo "Testing Gecko Command"
+    perf script gecko -a sleep 0.5
+    # Store the content of the file in the 'out' variable
+    out=$(< "gecko_profile.json")
+    # Get the length of the gecko_profile.json output in 'out'
+	length=${#out}
+	if [ "$length" -gt 0 ]; then
+        echo "PASS: \"Gecko Command\""
+    else
+        echo "FAIL: \"Gecko Command\""
+        err=1
+        exit
+    fi
+}
+
+# with the help of python json libary validate the json output
+if [ "$PYTHON_NOT_AVAILABLE" != "0" ]; then
+	validate_json_format()
+	{
+		if [ "$out" ] ; then
+			if [ "$PYTHON -c import json; json.load($out)" ]; then
+				echo "PASS: \"The file contains valid JSON format\""
+			else
+				echo "FAIL: \"The file does not contain valid JSON format\""
+				err=1
+				exit
+			fi
+		else
+			echo "FAIL: \"File not found\""
+			err=2
+			exit
+		fi
+	}
+fi
+
+# validate output for the presence of "meta".
+test_meta() {
+    find_str_or_fail "meta" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "threads".
+test_threads() {
+	find_str_or_fail "threads" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "samples".
+test_samples() {
+	find_str_or_fail "samples" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "frameTable".
+test_frametable() {
+	find_str_or_fail "frameTable" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "stackTable".
+test_stacktable() {
+	find_str_or_fail "stackTable" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "stringTable"
+test_stringtable() {
+	find_str_or_fail "stringTable" "$out" "${FUNCNAME[0]}"
+}
+
+# validate output for the presence of "pausedRanges".
+test_pauseranges(){
+	find_str_or_fail "pausedRanges" "$out" "${FUNCNAME[0]}"
+}
+
+test_gecko_command
+validate_json_format
+test_meta
+test_threads
+test_samples
+test_frametable
+test_stacktable
+test_stringtable
+test_pauseranges
+cleanup
+exit $err
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] perf test: Add support for testing gecko script
  2023-08-12  7:16 [PATCH V2] perf test: Add support for testing gecko script Anup Sharma
@ 2023-08-12 21:46 ` Anup Sharma
  2023-08-15  9:05   ` Ian Rogers
  0 siblings, 1 reply; 4+ messages in thread
From: Anup Sharma @ 2023-08-12 21:46 UTC (permalink / raw)
  To: Anup Sharma
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	  Adrian Hunter, linux-perf-users, linux-kernel

On Sat, Aug 12, 2023 at 12:46:00PM +0530, Anup Sharma wrote:
> This commit add support for testing gecko script. The test checks
> for the presence of required sections such as "meta," "threads,"
> "samples," "frameTable," "stackTable," "stringTable," and
> "pausedRanges" which are few essential parameter to be present
> in output file. Also it verifies the validity of the JSON format
> using Python's JSON library if available.
> 
> Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> 
> ---
> Patch needed for testing:
>     https://lore.kernel.org/linux-perf-users/ZNOS0vo58DnVLpD8@yoga/T/#u

To run this script:
./test_gecko.sh
or
bash test_gecko.sh

Expected output:

Testing Gecko Command
Staring Firefox Profiler on your default browser...
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [13/Aug/2023 03:07:35] "GET /gecko_profile.json HTTP/1.1" 200 -
[ perf gecko: Captured and wrote into gecko_profile.json ]
PASS: "Gecko Command"
PASS: "The file contains valid JSON format"
PASS: "test_meta"
PASS: "test_threads"
PASS: "test_samples"
PASS: "test_frametable"
PASS: "test_stacktable"
PASS: "test_stringtable"
PASS: "test_pauseranges"

> changes in v2:
>     - Removed uncessary prepare_perf_data.
>     - provided patch which is required for testing this patch.
> ---
>  tools/perf/tests/shell/test_gecko.sh | 130 +++++++++++++++++++++++++++
>  1 file changed, 130 insertions(+)
>  create mode 100755 tools/perf/tests/shell/test_gecko.sh
> 
> diff --git a/tools/perf/tests/shell/test_gecko.sh b/tools/perf/tests/shell/test_gecko.sh
> new file mode 100755
> index 000000000000..44160eff87fd
> --- /dev/null
> +++ b/tools/perf/tests/shell/test_gecko.sh
> @@ -0,0 +1,130 @@
> +#!/bin/bash
> +# perf script gecko test
> +# SPDX-License-Identifier: GPL-2.0
> +
> +err=0
> +
> +cleanup() {
> +  rm -rf gecko_profile.json
> +  trap - exit term int
> +}
> +
> +trap_cleanup() {
> +  cleanup
> +  exit 1
> +}
> +trap trap_cleanup exit term int
> +
> +report() {
> +    if [ "$1" = 0 ]; then
> +        echo "PASS: \"$2\""
> +    else
> +        echo "FAIL: \"$2\" Error message: \"$3\""
> +        err=1
> +    fi
> +}
> +
> +find_str_or_fail() {
> +    grep -q "$1" <<< "$2"
> +    if [ "$?" != 0 ]; then
> +        report 1 "$3" "Failed to find required string:'${1}'."
> +    else
> +        report 0 "$3"
> +    fi
> +}
> +
> +# To validate the json format, check if python is installed
> +if [ "$PYTHON" = "" ] ; then
> +	if which python3 > /dev/null ; then
> +		PYTHON=python3
> +	elif which python > /dev/null ; then
> +		PYTHON=python
> +	else
> +		echo Skipping JSON format check, python not detected please set environment variable PYTHON.
> +		PYTHON_NOT_AVAILABLE=1
> +	fi
> +fi
> +
> +# Check execution of perf script gecko command
> +test_gecko_command() {
> +    echo "Testing Gecko Command"
> +    perf script gecko -a sleep 0.5
> +    # Store the content of the file in the 'out' variable
> +    out=$(< "gecko_profile.json")
> +    # Get the length of the gecko_profile.json output in 'out'
> +	length=${#out}
> +	if [ "$length" -gt 0 ]; then
> +        echo "PASS: \"Gecko Command\""
> +    else
> +        echo "FAIL: \"Gecko Command\""
> +        err=1
> +        exit
> +    fi
> +}
> +
> +# with the help of python json libary validate the json output
> +if [ "$PYTHON_NOT_AVAILABLE" != "0" ]; then
> +	validate_json_format()
> +	{
> +		if [ "$out" ] ; then
> +			if [ "$PYTHON -c import json; json.load($out)" ]; then
> +				echo "PASS: \"The file contains valid JSON format\""
> +			else
> +				echo "FAIL: \"The file does not contain valid JSON format\""
> +				err=1
> +				exit
> +			fi
> +		else
> +			echo "FAIL: \"File not found\""
> +			err=2
> +			exit
> +		fi
> +	}
> +fi
> +
> +# validate output for the presence of "meta".
> +test_meta() {
> +    find_str_or_fail "meta" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "threads".
> +test_threads() {
> +	find_str_or_fail "threads" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "samples".
> +test_samples() {
> +	find_str_or_fail "samples" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "frameTable".
> +test_frametable() {
> +	find_str_or_fail "frameTable" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "stackTable".
> +test_stacktable() {
> +	find_str_or_fail "stackTable" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "stringTable"
> +test_stringtable() {
> +	find_str_or_fail "stringTable" "$out" "${FUNCNAME[0]}"
> +}
> +
> +# validate output for the presence of "pausedRanges".
> +test_pauseranges(){
> +	find_str_or_fail "pausedRanges" "$out" "${FUNCNAME[0]}"
> +}
> +
> +test_gecko_command
> +validate_json_format
> +test_meta
> +test_threads
> +test_samples
> +test_frametable
> +test_stacktable
> +test_stringtable
> +test_pauseranges
> +cleanup
> +exit $err
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] perf test: Add support for testing gecko script
  2023-08-12 21:46 ` Anup Sharma
@ 2023-08-15  9:05   ` Ian Rogers
  2023-08-16 16:47     ` Anup Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Rogers @ 2023-08-15  9:05 UTC (permalink / raw)
  To: Anup Sharma
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Adrian Hunter, linux-perf-users, linux-kernel

On Sat, Aug 12, 2023 at 2:47 PM Anup Sharma <anupnewsmail@gmail.com> wrote:
>
> On Sat, Aug 12, 2023 at 12:46:00PM +0530, Anup Sharma wrote:
> > This commit add support for testing gecko script. The test checks
> > for the presence of required sections such as "meta," "threads,"
> > "samples," "frameTable," "stackTable," "stringTable," and
> > "pausedRanges" which are few essential parameter to be present
> > in output file. Also it verifies the validity of the JSON format
> > using Python's JSON library if available.
> >
> > Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> >
> > ---
> > Patch needed for testing:
> >     https://lore.kernel.org/linux-perf-users/ZNOS0vo58DnVLpD8@yoga/T/#u
>
> To run this script:
> ./test_gecko.sh
> or
> bash test_gecko.sh
>
> Expected output:
>
> Testing Gecko Command
> Staring Firefox Profiler on your default browser...
> Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
> 127.0.0.1 - - [13/Aug/2023 03:07:35] "GET /gecko_profile.json HTTP/1.1" 200 -
> [ perf gecko: Captured and wrote into gecko_profile.json ]
> PASS: "Gecko Command"
> PASS: "The file contains valid JSON format"
> PASS: "test_meta"
> PASS: "test_threads"
> PASS: "test_samples"
> PASS: "test_frametable"
> PASS: "test_stacktable"
> PASS: "test_stringtable"
> PASS: "test_pauseranges"

Hi Anup,

this works for me but when I run as root (using sudo) I need to set
PERF_EXEC_PATH. Running as a user it launches firefox profiler which I
don't think it should.

Thanks,
Ian

> > changes in v2:
> >     - Removed uncessary prepare_perf_data.
> >     - provided patch which is required for testing this patch.
> > ---
> >  tools/perf/tests/shell/test_gecko.sh | 130 +++++++++++++++++++++++++++
> >  1 file changed, 130 insertions(+)
> >  create mode 100755 tools/perf/tests/shell/test_gecko.sh
> >
> > diff --git a/tools/perf/tests/shell/test_gecko.sh b/tools/perf/tests/shell/test_gecko.sh
> > new file mode 100755
> > index 000000000000..44160eff87fd
> > --- /dev/null
> > +++ b/tools/perf/tests/shell/test_gecko.sh
> > @@ -0,0 +1,130 @@
> > +#!/bin/bash
> > +# perf script gecko test
> > +# SPDX-License-Identifier: GPL-2.0
> > +
> > +err=0
> > +
> > +cleanup() {
> > +  rm -rf gecko_profile.json
> > +  trap - exit term int
> > +}
> > +
> > +trap_cleanup() {
> > +  cleanup
> > +  exit 1
> > +}
> > +trap trap_cleanup exit term int
> > +
> > +report() {
> > +    if [ "$1" = 0 ]; then
> > +        echo "PASS: \"$2\""
> > +    else
> > +        echo "FAIL: \"$2\" Error message: \"$3\""
> > +        err=1
> > +    fi
> > +}
> > +
> > +find_str_or_fail() {
> > +    grep -q "$1" <<< "$2"
> > +    if [ "$?" != 0 ]; then
> > +        report 1 "$3" "Failed to find required string:'${1}'."
> > +    else
> > +        report 0 "$3"
> > +    fi
> > +}
> > +
> > +# To validate the json format, check if python is installed
> > +if [ "$PYTHON" = "" ] ; then
> > +     if which python3 > /dev/null ; then
> > +             PYTHON=python3
> > +     elif which python > /dev/null ; then
> > +             PYTHON=python
> > +     else
> > +             echo Skipping JSON format check, python not detected please set environment variable PYTHON.
> > +             PYTHON_NOT_AVAILABLE=1
> > +     fi
> > +fi
> > +
> > +# Check execution of perf script gecko command
> > +test_gecko_command() {
> > +    echo "Testing Gecko Command"
> > +    perf script gecko -a sleep 0.5
> > +    # Store the content of the file in the 'out' variable
> > +    out=$(< "gecko_profile.json")
> > +    # Get the length of the gecko_profile.json output in 'out'
> > +     length=${#out}
> > +     if [ "$length" -gt 0 ]; then
> > +        echo "PASS: \"Gecko Command\""
> > +    else
> > +        echo "FAIL: \"Gecko Command\""
> > +        err=1
> > +        exit
> > +    fi
> > +}
> > +
> > +# with the help of python json libary validate the json output
> > +if [ "$PYTHON_NOT_AVAILABLE" != "0" ]; then
> > +     validate_json_format()
> > +     {
> > +             if [ "$out" ] ; then
> > +                     if [ "$PYTHON -c import json; json.load($out)" ]; then
> > +                             echo "PASS: \"The file contains valid JSON format\""
> > +                     else
> > +                             echo "FAIL: \"The file does not contain valid JSON format\""
> > +                             err=1
> > +                             exit
> > +                     fi
> > +             else
> > +                     echo "FAIL: \"File not found\""
> > +                     err=2
> > +                     exit
> > +             fi
> > +     }
> > +fi
> > +
> > +# validate output for the presence of "meta".
> > +test_meta() {
> > +    find_str_or_fail "meta" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "threads".
> > +test_threads() {
> > +     find_str_or_fail "threads" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "samples".
> > +test_samples() {
> > +     find_str_or_fail "samples" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "frameTable".
> > +test_frametable() {
> > +     find_str_or_fail "frameTable" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "stackTable".
> > +test_stacktable() {
> > +     find_str_or_fail "stackTable" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "stringTable"
> > +test_stringtable() {
> > +     find_str_or_fail "stringTable" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +# validate output for the presence of "pausedRanges".
> > +test_pauseranges(){
> > +     find_str_or_fail "pausedRanges" "$out" "${FUNCNAME[0]}"
> > +}
> > +
> > +test_gecko_command
> > +validate_json_format
> > +test_meta
> > +test_threads
> > +test_samples
> > +test_frametable
> > +test_stacktable
> > +test_stringtable
> > +test_pauseranges
> > +cleanup
> > +exit $err
> > --
> > 2.34.1
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] perf test: Add support for testing gecko script
  2023-08-15  9:05   ` Ian Rogers
@ 2023-08-16 16:47     ` Anup Sharma
  0 siblings, 0 replies; 4+ messages in thread
From: Anup Sharma @ 2023-08-16 16:47 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Anup Sharma, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Adrian Hunter, linux-perf-users,
	linux-kernel

On Tue, Aug 15, 2023 at 02:05:02AM -0700, Ian Rogers wrote:
> On Sat, Aug 12, 2023 at 2:47 PM Anup Sharma <anupnewsmail@gmail.com> wrote:
> >
> > On Sat, Aug 12, 2023 at 12:46:00PM +0530, Anup Sharma wrote:
> > > This commit add support for testing gecko script. The test checks
> > > for the presence of required sections such as "meta," "threads,"
> > > "samples," "frameTable," "stackTable," "stringTable," and
> > > "pausedRanges" which are few essential parameter to be present
> > > in output file. Also it verifies the validity of the JSON format
> > > using Python's JSON library if available.
> > >
> > > Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> > >
> > > ---
> > > Patch needed for testing:
> > >     https://lore.kernel.org/linux-perf-users/ZNOS0vo58DnVLpD8@yoga/T/#u
> >
> > To run this script:
> > ./test_gecko.sh
> > or
> > bash test_gecko.sh
> >
> > Expected output:
> >
> > Testing Gecko Command
> > Staring Firefox Profiler on your default browser...
> > Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
> > 127.0.0.1 - - [13/Aug/2023 03:07:35] "GET /gecko_profile.json HTTP/1.1" 200 -
> > [ perf gecko: Captured and wrote into gecko_profile.json ]
> > PASS: "Gecko Command"
> > PASS: "The file contains valid JSON format"
> > PASS: "test_meta"
> > PASS: "test_threads"
> > PASS: "test_samples"
> > PASS: "test_frametable"
> > PASS: "test_stacktable"
> > PASS: "test_stringtable"
> > PASS: "test_pauseranges"
> 
> Hi Anup,
> 
> this works for me but when I run as root (using sudo) I need to set
> PERF_EXEC_PATH. Running as a user it launches firefox profiler which I
> don't think it should.

Hi Ian, thanks for testing this patch. I checked it seems like
gecko.py Line 359: webbrowser.open(f'{url}') is not launching
firefox or any browser when run as root. Few discussion have
already taken place which I am looking right now:
https://forums.opensuse.org/t/python-webbrowser-with-root/92189
https://github.com/pyinstaller/pyinstaller/issues/6334
I will check if there is any way to launch browser as both root
and user.

Thanks,
Anup

> Thanks,
> Ian
> 
> > > changes in v2:
> > >     - Removed uncessary prepare_perf_data.
> > >     - provided patch which is required for testing this patch.
> > > ---
> > >  tools/perf/tests/shell/test_gecko.sh | 130 +++++++++++++++++++++++++++
> > >  1 file changed, 130 insertions(+)
> > >  create mode 100755 tools/perf/tests/shell/test_gecko.sh
> > >
> > > diff --git a/tools/perf/tests/shell/test_gecko.sh b/tools/perf/tests/shell/test_gecko.sh
> > > new file mode 100755
> > > index 000000000000..44160eff87fd
> > > --- /dev/null
> > > +++ b/tools/perf/tests/shell/test_gecko.sh
> > > @@ -0,0 +1,130 @@
> > > +#!/bin/bash
> > > +# perf script gecko test
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +
> > > +err=0
> > > +
> > > +cleanup() {
> > > +  rm -rf gecko_profile.json
> > > +  trap - exit term int
> > > +}
> > > +
> > > +trap_cleanup() {
> > > +  cleanup
> > > +  exit 1
> > > +}
> > > +trap trap_cleanup exit term int
> > > +
> > > +report() {
> > > +    if [ "$1" = 0 ]; then
> > > +        echo "PASS: \"$2\""
> > > +    else
> > > +        echo "FAIL: \"$2\" Error message: \"$3\""
> > > +        err=1
> > > +    fi
> > > +}
> > > +
> > > +find_str_or_fail() {
> > > +    grep -q "$1" <<< "$2"
> > > +    if [ "$?" != 0 ]; then
> > > +        report 1 "$3" "Failed to find required string:'${1}'."
> > > +    else
> > > +        report 0 "$3"
> > > +    fi
> > > +}
> > > +
> > > +# To validate the json format, check if python is installed
> > > +if [ "$PYTHON" = "" ] ; then
> > > +     if which python3 > /dev/null ; then
> > > +             PYTHON=python3
> > > +     elif which python > /dev/null ; then
> > > +             PYTHON=python
> > > +     else
> > > +             echo Skipping JSON format check, python not detected please set environment variable PYTHON.
> > > +             PYTHON_NOT_AVAILABLE=1
> > > +     fi
> > > +fi
> > > +
> > > +# Check execution of perf script gecko command
> > > +test_gecko_command() {
> > > +    echo "Testing Gecko Command"
> > > +    perf script gecko -a sleep 0.5
> > > +    # Store the content of the file in the 'out' variable
> > > +    out=$(< "gecko_profile.json")
> > > +    # Get the length of the gecko_profile.json output in 'out'
> > > +     length=${#out}
> > > +     if [ "$length" -gt 0 ]; then
> > > +        echo "PASS: \"Gecko Command\""
> > > +    else
> > > +        echo "FAIL: \"Gecko Command\""
> > > +        err=1
> > > +        exit
> > > +    fi
> > > +}
> > > +
> > > +# with the help of python json libary validate the json output
> > > +if [ "$PYTHON_NOT_AVAILABLE" != "0" ]; then
> > > +     validate_json_format()
> > > +     {
> > > +             if [ "$out" ] ; then
> > > +                     if [ "$PYTHON -c import json; json.load($out)" ]; then
> > > +                             echo "PASS: \"The file contains valid JSON format\""
> > > +                     else
> > > +                             echo "FAIL: \"The file does not contain valid JSON format\""
> > > +                             err=1
> > > +                             exit
> > > +                     fi
> > > +             else
> > > +                     echo "FAIL: \"File not found\""
> > > +                     err=2
> > > +                     exit
> > > +             fi
> > > +     }
> > > +fi
> > > +
> > > +# validate output for the presence of "meta".
> > > +test_meta() {
> > > +    find_str_or_fail "meta" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "threads".
> > > +test_threads() {
> > > +     find_str_or_fail "threads" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "samples".
> > > +test_samples() {
> > > +     find_str_or_fail "samples" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "frameTable".
> > > +test_frametable() {
> > > +     find_str_or_fail "frameTable" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "stackTable".
> > > +test_stacktable() {
> > > +     find_str_or_fail "stackTable" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "stringTable"
> > > +test_stringtable() {
> > > +     find_str_or_fail "stringTable" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +# validate output for the presence of "pausedRanges".
> > > +test_pauseranges(){
> > > +     find_str_or_fail "pausedRanges" "$out" "${FUNCNAME[0]}"
> > > +}
> > > +
> > > +test_gecko_command
> > > +validate_json_format
> > > +test_meta
> > > +test_threads
> > > +test_samples
> > > +test_frametable
> > > +test_stacktable
> > > +test_stringtable
> > > +test_pauseranges
> > > +cleanup
> > > +exit $err
> > > --
> > > 2.34.1
> > >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-16 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-12  7:16 [PATCH V2] perf test: Add support for testing gecko script Anup Sharma
2023-08-12 21:46 ` Anup Sharma
2023-08-15  9:05   ` Ian Rogers
2023-08-16 16:47     ` Anup Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).