Files
rt-validation/rt-tests/rt-tests.sh
Jörg Sommer bd2dadcf93 rt-tests: Add DURATION variable to control test duration
Running the test for 12h is too long in some cases. It would be better if
the duration of the test could be set from outside. With the new environment
variable DURATION a user can control the value of the parameter `-D` of
cyclictest and set the desired value.
2023-06-29 17:28:28 +02:00

64 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Run cyclictest
if ! cyclictest -S -p99 -i1000 -m -D${DURATION:-12h} -h400 -q >output; then
echo "ERROR: cyclictest failed" >&2
exit 1
fi
# Get maximum latency
max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
# Grep data lines, remove empty lines and create a common field separator
grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram
# Create two-column data sets with latency classes and frequency values for each core
cores=$(grep -c ^processor /proc/cpuinfo)
for i in `seq 1 $cores`
do
column=`expr $i + 1`
cut -f1,$column histogram >histogram$i
done
# Create plot command header
echo -n -e "set title \"Latency plot\"\n\
set terminal png\n\
set xlabel \"Latency (us), max $max us\"\n\
set logscale y\n\
set xrange [0:400]\n\
set yrange [0.8:*]\n\
set ylabel \"Number of latency samples\"\n\
set output \"plot.png\"\n\
plot " >plotcmd
# Append plot command data references
for i in `seq 1 $cores`
do
if test $i != 1
then
echo -n ", " >>plotcmd
fi
cpuno=`expr $i - 1`
if test $cpuno -lt 10
then
title=" CPU$cpuno"
else
title="CPU$cpuno"
fi
echo -n "\"histogram$i\" using 1:2 title \"$title\" with histeps" >>plotcmd
done
# Execute plot command
gnuplot -persist <plotcmd
# Print summary to /tmp
echo "Generating latency summary to /tmp/latency-summary.log"
grep -e "^#" output >/tmp/latency-summary.log
# Copy plot to /tmp/latency-plot.png
echo "Generating latency plot to /tmp/latency-plot.png"
cp plot.png /tmp/latency-plot.png
# Clean up
rm -f histogram* output plotcmd plot.png