Commit ed46a999 authored by Samir Mulani's avatar Samir Mulani Committed by Arnaldo Carvalho de Melo
Browse files

perf tests shell: Fixed shellcheck warnings



Fixed the shellcheck warnings in buildid.sh, record+probe_libc_inet_pton.sh
and record+script_probe_vfs_getname.sh perf shell scripts:

1. Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
2. Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
3. Used * argument to avoid the argument mixes string and array
4. Resolved issue for variable refernce, where the variable is
   being used before it has been initialized.
5. Resolved word splitting issue (syntax error).
6. The "err" variable has been removed from buildid.sh since
   it is not used anywhere in the code.

Signed-off-by: default avatarSamir Mulani <samir@linux.vnet.ibm.com>
Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: linuxppc-dev@lists.ozlabs.org
Link: https://lore.kernel.org/r/20230613164145.50488-13-atrajeev@linux.vnet.ibm.com


Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fa33cbe2
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -83,12 +83,12 @@ check()
	# in case of pe-file.exe file
	echo $1 | grep ".exe"
	if [ $? -eq 0 ]; then
		if [ -x $1  -a ! -x $file ]; then
		if [ -x $1 ] && [ ! -x $file ]; then
			echo "failed: file ${file} executable does not exist"
			exit 1
		fi

		if [ ! -x $file -a ! -e $file ]; then
		if [ ! -x $file ] && [ ! -e $file ]; then
			echo "failed: file ${file} does not exist"
			exit 1
		fi
@@ -136,10 +136,10 @@ test_record()
	log_err=$(mktemp /tmp/perf.log.err.XXX)
	perf="perf --buildid-dir ${build_id_dir}"

	echo "running: perf record $@"
	${perf} record --buildid-all -o ${data} $@ 1>${log_out} 2>${log_err}
	echo "running: perf record $*"
	${perf} record --buildid-all -o ${data} "$@" 1>${log_out} 2>${log_err}
	if [ $? -ne 0 ]; then
		echo "failed: record $@"
		echo "failed: record $*"
		echo "see log: ${log_err}"
		exit 1
	fi
@@ -172,4 +172,4 @@ if [ ${run_pe} -eq 1 ]; then
	rm -r ${wineprefix}
fi

exit ${err}
exit 0
+3 −3
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@
# SPDX-License-Identifier: GPL-2.0
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017

. $(dirname $0)/lib/probe.sh
. $(dirname $0)/lib/probe_vfs_getname.sh
. "$(dirname "$0")/lib/probe.sh"
. "$(dirname "$0")/lib/probe_vfs_getname.sh"

libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')
nm -Dg $libc 2>/dev/null | fgrep -q inet_pton || exit 254
@@ -23,7 +23,7 @@ add_libc_inet_pton_event() {
	event_name=$(perf probe -f -x $libc -a inet_pton 2>&1 | tail -n +2 | head -n -5 | \
			grep -P -o "$event_pattern(?=[[:space:]]\(on inet_pton in $libc\))")

	if [ $? -ne 0 -o -z "$event_name" ] ; then
	if [ $? -ne 0 ] || [ -z "$event_name" ] ; then
		printf "FAIL: could not add event\n"
		return 1
	fi
+2 −2
Original line number Diff line number Diff line
@@ -9,11 +9,11 @@
# SPDX-License-Identifier: GPL-2.0
# Arnaldo Carvalho de Melo <acme@kernel.org>, 2017

. $(dirname $0)/lib/probe.sh
. "$(dirname "$0")/lib/probe.sh"

skip_if_no_perf_probe || exit 2

. $(dirname $0)/lib/probe_vfs_getname.sh
. "$(dirname "$0")/lib/probe_vfs_getname.sh"

record_open_file() {
	echo "Recording open file:"