aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2020-05-07 16:33:40 +0100
committerDavid Spickett <david.spickett@linaro.org>2020-05-11 12:29:13 +0100
commit17d02b8f3b8df92ff411eddf876f2d95f1cff09c (patch)
tree1258e22ed9603586bf45a99fccda8b26e6f24143
parent370a9cfc9b5365e2df975da579e2fd6a796b8997 (diff)
Various: Fix the majority of shellcheck warnings
Change-Id: I143ac44f14de68935116bbe62a9a9ff752d7a395
-rw-r--r--bmk-to-board-cpu.sh1
-rw-r--r--board-bmk-map.sh4
-rwxr-xr-xboard-cpu-to-bmk-list.sh5
-rwxr-xr-xperf-archive.sh7
-rwxr-xr-xperf-buildid-cache.sh3
-rwxr-xr-xperfdatadir2csv.sh2
-rwxr-xr-xprepare-board.sh4
-rwxr-xr-xrun.sh17
-rwxr-xr-xset-freq.sh3
9 files changed, 28 insertions, 18 deletions
diff --git a/bmk-to-board-cpu.sh b/bmk-to-board-cpu.sh
index 7d5abc5..baf7ee4 100644
--- a/bmk-to-board-cpu.sh
+++ b/bmk-to-board-cpu.sh
@@ -17,6 +17,7 @@ mydir="$(pwd)"
cd ${rundir}
# Load benchmark/board table
+# shellcheck source=board-bmk-map.sh
. ${mydir}/board-bmk-map.sh
bench=
diff --git a/board-bmk-map.sh b/board-bmk-map.sh
index c8d3626..5f83ce8 100644
--- a/board-bmk-map.sh
+++ b/board-bmk-map.sh
@@ -1,3 +1,7 @@
+#!/bin/bash
+# shellcheck disable=SC2034
+# (vars here are used in other scripts)
+
# Hardcoded mapping between board number/cpu number and benchmarks to run
# This script hardcodes a mapping from board/cpu to a list of
diff --git a/board-cpu-to-bmk-list.sh b/board-cpu-to-bmk-list.sh
index 2d45574..a01d020 100755
--- a/board-cpu-to-bmk-list.sh
+++ b/board-cpu-to-bmk-list.sh
@@ -17,7 +17,8 @@
set -e
# Load benchmark/board table
-. $(dirname $0)/board-bmk-map.sh
+# shellcheck source=board-bmk-map.sh
+. "$(dirname $0)"/board-bmk-map.sh
board="unspecified"
cpus=()
@@ -83,5 +84,5 @@ case $profile:$board in
esac
for cpu in "${cpus[@]}"; do
- eval "echo \${bmks_$profile[${boardno}_${cpu}]}"
+ eval "echo \${bmks_${profile}[${boardno}_${cpu}]}"
done
diff --git a/perf-archive.sh b/perf-archive.sh
index 7d03895..2d73975 100755
--- a/perf-archive.sh
+++ b/perf-archive.sh
@@ -8,7 +8,7 @@ buildid_dir="$HOME/.debug"
output=""
verbose=""
-OPTS="`getopt -o o:v -l buildid-dir:,output:,verbose -- "$@"`"
+getopt -o o:v -l buildid-dir:,output:,verbose -- "$@"
while test $# -gt 0; do
case $1 in
--buildid-dir) buildid_dir="$2"; shift ;;
@@ -24,7 +24,7 @@ $verbose
if [ $# -eq 0 ] ; then
PERF_DATA=perf.data
else
- PERF_DATA="$@"
+ PERF_DATA="$*"
fi
if [ x"$output" = x"" ]; then
@@ -50,6 +50,7 @@ buildid_dir=$buildid_dir/
BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
+# shellcheck disable=SC2064
trap "rm -f $BUILDIDS $MANIFEST" EXIT
NOBUILDID=0000000000000000000000000000000000000000
@@ -73,4 +74,4 @@ while read build_id ; do
echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
done
-tar c${comression}f $output -C $buildid_dir -T $MANIFEST
+tar c${compression}f $output -C $buildid_dir -T $MANIFEST
diff --git a/perf-buildid-cache.sh b/perf-buildid-cache.sh
index 9b52ab6..31bc18f 100755
--- a/perf-buildid-cache.sh
+++ b/perf-buildid-cache.sh
@@ -3,12 +3,13 @@
set -e
missing=$(mktemp /tmp/perf-buildid-missing.XXXXXX)
+# shellcheck disable=SC2064
trap "rm -rf $missing" EXIT
cachedir=""
verbose=""
-OPTS="`getopt -o vd: -l cachedir:,verbose -- "$@"`"
+getopt -o vd: -l cachedir:,verbose -- "$@"
while test $# -gt 0; do
case $1 in
--cachedir|-d) cachedir="$2"; shift ;;
diff --git a/perfdatadir2csv.sh b/perfdatadir2csv.sh
index 6496829..63fa6de 100755
--- a/perfdatadir2csv.sh
+++ b/perfdatadir2csv.sh
@@ -154,7 +154,7 @@ for perf_dir in "${perf_dirs[@]}"; do
-t, 2>/dev/null \
| awk "
BEGIN { found_samples=0; found_command=0 }
-/^# Samples: .* of event '$event['/]/ { if (found_samples) { exit }; found_samples=1; next }
+/^# Samples: .* of event '${event}['/]/ { if (found_samples) { exit }; found_samples=1; next }
/^# .*, *Samples/ { if (found_samples) { found_command=1 }; next }
/^#/ { if (found_command) { exit } }
/^$/ { next }
diff --git a/prepare-board.sh b/prepare-board.sh
index b1952f3..23c25a4 100755
--- a/prepare-board.sh
+++ b/prepare-board.sh
@@ -273,6 +273,8 @@ configure_perf_hack()
fi
if [ "$op" = "start_docker" ]; then
+ # We do want word splitting here as the conf contains cmd line options for perf
+ # shellcheck disable=SC2046
taskset -c 0 $LINUX_TOOLS/perf record -q -N $(cat $conf_file) -o /dev/null -- sleep 2000d 1>&- 2>&- &
pid=$!
disown $pid
@@ -337,7 +339,7 @@ do_cpufreq_start()
# By default use ondemand governor with HW min and max frequencies.
# This avoid inconsistent state when we try to set $minfreq below
# current maximum frequency.
- $LINUX_TOOLS/cpupower -c $cpu frequency-set --governor ondemand --min $(calc_freq "$cpufreq_path" min) --max $(calc_freq "$cpufreq_path" max)
+ $LINUX_TOOLS/cpupower -c $cpu frequency-set --governor ondemand --min "$(calc_freq "$cpufreq_path" min)" --max "$(calc_freq "$cpufreq_path" max)"
set_var "$restore_file" "$cpufreq_path/scaling_governor" "$gov"
set_var "$restore_file" "$cpufreq_path/scaling_min_freq" "$minfreq"
diff --git a/run.sh b/run.sh
index 44750f6..7c67a08 100755
--- a/run.sh
+++ b/run.sh
@@ -188,14 +188,13 @@ mode=$(getconf LONG_BIT)
# Clean old results if requested (to make some free space)
for spec in $installdir/cpu2006-*; do
- if [ x"$clean_older_than" != x"" \
- -a -d $spec/result ]; then
+ if [ x"$clean_older_than" != x"" ] && [ -d $spec/result ]; then
find $spec/result -depth -type f -mtime +$clean_older_than -exec rm {} \;
find $spec/result -depth -empty -delete # removes empty dirs
fi
done
-for cpu in ${cpus[@]}
+for cpu in "${cpus[@]}"
do
if ${forceinstall} ; then
rm -rf ${installdir}/cpu2006-$sha1-$mode-$cpu
@@ -223,7 +222,7 @@ $nosudo || sudo ${mydir}/prepare-board.sh --action start_docker \
--hw_tag "$hw_tag" --verbose
# Configure the benchmarks
-for cpu in ${cpus[@]}
+for cpu in "${cpus[@]}"
do
${mydir}/spec2xxx-config --config $config --ccprefix $ccprefix \
--ccflags "$cflags" --ldflags "$ldflags" --bind $cpu \
@@ -236,7 +235,7 @@ done
declare -A bmks
# Build list of benchmarks to run per cpu
-for cpu in ${cpus[@]}
+for cpu in "${cpus[@]}"
do
# Get the list of benches that can potentially be executed on this board/cpu
this_board_bmks=$(${mydir}/board-cpu-to-bmk-list.sh --board ${nodename} --cpu ${cpu} --profile "$run_profile")
@@ -259,7 +258,7 @@ status=0
# Build the benchmarks
pids=()
-for cpu in ${cpus[@]}
+for cpu in "${cpus[@]}"
do
# If nothing to run on this cpu, continue
[ x"${bmks[${cpu}]}" = x ] && continue
@@ -295,7 +294,7 @@ done
if $ignore_errors; then
# Remove failed-to-build benchmarks from run lists.
# Otherwise we will try to build them again.
- for cpu in ${cpus[@]}; do
+ for cpu in "${cpus[@]}"; do
failed_csv="${installdir}/cpu2006-$sha1-$mode-$cpu/result/failed.$config.csv.build.$cpu"
if [ ! -f "$failed_csv" ]; then
continue
@@ -315,7 +314,7 @@ fi
# Run the benchmarks
pids=()
-for cpu in ${cpus[@]}; do
+for cpu in "${cpus[@]}"; do
# If nothing to run on this cpu, continue
[ x"${bmks[${cpu}]}" = x ] && continue
(
@@ -350,7 +349,7 @@ fi
# We run AArch32 benchmarks rarely enough that it's not worth eating up disk
# space with SPEC installs for it. Clean up if this was an AArch32 run.
# FIXME: Support other armv8 boards besides the tx1.
-for cpu in ${cpus[@]}
+for cpu in "${cpus[@]}"
do
if [[ ${mode} == 32 && ${nodename} =~ .*-tx1-.* ]]; then
echo "Removing SPEC installation at ${installdir}/cpu2006-$sha1-$mode-$cpu"
diff --git a/set-freq.sh b/set-freq.sh
index 0304e64..25f6f06 100755
--- a/set-freq.sh
+++ b/set-freq.sh
@@ -20,7 +20,8 @@ freqset () {
sudo cpufreq-set -c $cpus -g $gov $opts
if [ x"$freq_check" != x"0" ]; then
- local cur_freq="$(cpufreq-info -c $cpus -f)"
+ local cur_freq
+ cur_freq="$(cpufreq-info -c $cpus -f)"
if [ x"$cur_freq" != x"$freq_check" ]; then
echo "ERROR: Frequency of CPU $cpus is $cur_freq, but $freq_check is expected."
exit 1