Skip to content

Commit

Permalink
Make shell scripts shell check clean and enable shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Dec 12, 2024
1 parent b54a221 commit 2e2d46f
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 72 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ jobs:
python -m pip install --upgrade pip
pip install flake8 pytest mypy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
sudo apt install -y shellcheck
- name: Lint with flake8
run: |
./FLAKE8
- name: Type check with mypy
run: |
./MYPY
- name: Run shell check
run: |
shellcheck -e SC2086,SC2012 -x tl-tester tester other-tester parallel-tester all-tester jevents/tester ucevent/uctester
- name: Run toplev tests
run: |
if ! grep -q GenuineIntel /proc/cpuinfo ; then export NATIVE_ARGS="--force-cpu skl" ; fi
Expand Down
23 changes: 13 additions & 10 deletions jevents/tester
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ trap failed ERR 0
PATH=.:./examples:$PATH


$V listevents > l
[ $(wc -l < l) -gt 50 ]
grep -q offcore_response l
$V listevents > l$$
[ "$(wc -l < l$$)" -gt 50 ]
grep -q offcore_response l$$

if grep -q br_misp_retired.taken l ; then
if grep -q br_misp_retired.taken l$$ ; then
E=br_misp_retired.taken
elif grep -q br_misp_retired.near_taken l ; then
elif grep -q br_misp_retired.near_taken l$$ ; then
E=br_misp_retired.near_taken
else
E=instructions
fi

if [ -r /sys/devices/cpu*/events/instructions ] ; then
if [ "$(ls /sys/devices/cpu*/events/instructions | wc -l)" -gt 0 ] ; then
$V jestat true
$V jestat -e cpu-cycles,cpu_clk_unhalted.ref_tsc,$E true
$V jestat -e "{cpu-cycles,cpu_clk_unhalted.ref_tsc},{$E,cache-references}" -a sleep 1
$V jestat -a sleep 1
$V jestat -a -e "uops_executed.thread:k" sleep 1
OCR=$(grep -E '^(offcore_response|ocr)\.' l | head -1 | cut -d ' ' -f 1)
OCR=$(grep -E '^(offcore_response|ocr)\.' l$$ | head -1 | cut -d ' ' -f 1)
$V jestat -a -e "$OCR:config1=0x1" sleep 1
$V jestat -A -a -I 500 cycles sleep 2

# test all events
LEN=$(wc -l l | awk ' { print $1 }')
LEN=$(wc -l l$$ | awk ' { print $1 }')
INC=20

# skip i915/vcs-* which often returns ENODEV for no good reason
Expand All @@ -45,7 +45,8 @@ if [ ! -d /sys/devices/uncore_upi_0 ] ; then
fi

for ((i = 1; i <= LEN; i += INC)) ; do
$V jestat $(nl l |
# shellcheck disable=SC2046
$V jestat $(nl l$$ |
grep -E -v "$SKIP" |
awk -v v=$i -v inc=$INC '$1 >= v && $1 <= v+inc { print "-e " $2 } ') -a true
done
Expand All @@ -56,12 +57,14 @@ fi

$V event-rmap $E

if [ -r /sys/devices/cpu*/events/instructions ] ; then
if [ "$(ls /sys/devices/cpu*/events/instructions | wc -l)" -gt 0 ] ; then
$V examples/addr
examples/rtest
examples/rtest2
fi

rm l$$

trap "" ERR 0

echo SUCCEEDED
Expand Down
4 changes: 2 additions & 2 deletions other-tester
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ $WRAP cputop.py "socket == 0"
$WRAP cputop.py "thread == 0 and socket == 0"
$WRAP cputop.py "thread == 1" offline
$WRAP cputop.py offline online
[ $($WRAP cputop.py True | wc -l | cut -d ' ' -f 1) -eq $(getconf _NPROCESSORS_ONLN) ]
[ "$($WRAP cputop.py True | wc -l | cut -d ' ' -f 1)" -eq "$(getconf _NPROCESSORS_ONLN)" ]

# list-events.py

EVENTMAP=${cpus[hsw]} $WRAP list-events.py > x$$.lst
[ $(wc -l x$$.lst | cut -d ' ' -f 1) -gt 20 ]
[ "$(wc -l x$$.lst | cut -d ' ' -f 1)" -gt 20 ]
grep -qi rtm_retired.aborted x$$.lst
rm x$$.lst

Expand Down
16 changes: 8 additions & 8 deletions tester
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ checklist()

# see if all events are visible
R=$(EVENTMAP=${cpus[$1]} $WRAP ./ocperf.py list | wc -l)
if [ $[$R - $BASELEN] -lt $2 ]; then
echo $1 list mismatch $[$R - $BASELEN]
if [ $((R - BASELEN)) -lt $2 ]; then
echo $1 list mismatch $((R - BASELEN))
exit 1
fi
}
Expand Down Expand Up @@ -201,19 +201,19 @@ cat >top2$$ <<EOL
/sys/devices/uncore_r2pcie/format/umask
/sys/devices/uncore_r2pcie/format/cmask
EOL
TOPOLOGY=top2$$ UNCORE=Jaketown* checkp 'unc_r2_iio_credits_acquired.ncb:state=0x123' 'filter_state=0x123'
TOPOLOGY=top2$$ UNCORE="Jaketown*" checkp 'unc_r2_iio_credits_acquired.ncb:state=0x123' 'filter_state=0x123'

cat >top2$$ <<EOL
/sys/devices/uncore_cbox_0
/sys/devices/uncore_cbox_0/format/umask
/sys/devices/uncore_cbox_1
/sys/devices/uncore_cbox_1/format/umask
EOL
TOPOLOGY=top2$$ UNCORE=haswell_uncore* checkp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox_1'
TOPOLOGY=top2$$ UNCORE=haswell_uncore* checkp 'unc_cbo_xsnp_response.hit_xcore:one_unit' 'uncore_cbox_0'
TOPOLOGY=top2$$ UNCORE=haswell_uncore* checknotp 'unc_cbo_xsnp_response.hit_xcore:one_unit' 'uncore_cbox_1'
TOPOLOGY=top2$$ UNCORE=haswell_uncore* checknotp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox_1' --noexplode
TOPOLOGY=top2$$ UNCORE=haswell_uncore* checkp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox[^_]' --noexplode
TOPOLOGY=top2$$ UNCORE="haswell_uncore*" checkp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox_1'
TOPOLOGY=top2$$ UNCORE="haswell_uncore*" checkp 'unc_cbo_xsnp_response.hit_xcore:one_unit' 'uncore_cbox_0'
TOPOLOGY=top2$$ UNCORE="haswell_uncore*" checknotp 'unc_cbo_xsnp_response.hit_xcore:one_unit' 'uncore_cbox_1'
TOPOLOGY=top2$$ UNCORE="haswell_uncore*" checknotp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox_1' --noexplode
TOPOLOGY=top2$$ UNCORE="haswell_uncore*" checkp 'unc_cbo_xsnp_response.hit_xcore' 'uncore_cbox[^_]' --noexplode

TOPOLOGY=top2$$ EVENTMAP=${cpus[jkt]} checkp 'UNC_C_TOR_INSERTS.MISS_OPCODE:opc=0x1c8:tid=0x3e' 'filter_opc=0x1c8,filter_tid=0x3e'

Expand Down
Loading

0 comments on commit 2e2d46f

Please sign in to comment.