packaging/perftest.sh: Hook script for running performance tests on binary upload

This commit is contained in:
rand00 2022-12-20 14:14:59 +01:00
parent 3bb8925bd3
commit db82447841

123
packaging/perftest.sh Normal file
View file

@ -0,0 +1,123 @@
#!/bin/sh
set -e
#set -x
prog_NAME=$(basename "${0}")
warn()
{
echo "${prog_NAME}: WARN: $*"
}
info()
{
echo "${prog_NAME}: INFO: $*"
}
err()
{
echo "${prog_NAME}: ERROR: $*" 1>&2
}
die()
{
echo "${prog_NAME}: ERROR: $*" 1>&2
exit 1
}
usage()
{
cat <<EOM 1>&2
usage: ${prog_NAME} [ OPTIONS ]
Starts up performance-test for supported jobs, and updates a plot of this.
Options:
--uuid=STRING
UUID of build.
--data-dir=STRING
Path to the data directory.
--cache-dir=STRING
Path to the cache directory.
EOM
exit 1
}
UUID=
JOB=
BIN_SHA256=
CACHE_DIR=
DATA_DIR=
while [ $# -gt 0 ]; do
OPT="$1"
case "${OPT}" in
--uuid=*)
UUID="${OPT##*=}"
;;
--job=*)
JOB="${OPT##*=}"
;;
--sha256=*)
BIN_SHA256="${OPT##*=}"
;;
--cache-dir=*)
CACHE_DIR="${OPT##*=}"
;;
--data-dir=*)
DATA_DIR="${OPT##*=}"
;;
*)
warn "Ignoring unknown option: '${OPT}' (Note that this script reads DB)"
;;
esac
shift
done
[ -z "${UUID}" ] && die "The --uuid option must be specified"
[ -z "${JOB}" ] && die "The --job option must be specified"
[ -z "${BIN_SHA256}" ] && die "The --sha256 option must be specified"
[ -z "${CACHE_DIR}" ] && die "The --cache-dir option must be specified"
[ -z "${DATA_DIR}" ] && die "The --data-dir option must be specified"
BIN_REL="$1"
[ -z "${BIN_REL}" ] && \
die "The main binarys localpath must be given as the first positional argument"
info "processing UUID '$UUID'"
BIN="${DATA_DIR}/$BIN_REL"
BIN_EXT=$(echo "$BIN_REL" | sed 's/.*\.\(.*\)/\1/')
DB="${DATA_DIR}/builder.sqlite3"
PERFDATA_DIR="$DATA_DIR/_performance/$JOB/$BIN_SHA256"
PERFSCRIPT_DIR="$DATA_DIR/_performance/$JOB"
#< goto think if this dir makes the most sense
case "${JOB},${BIN_EXT}" in
unipi,hvt)
if [ -d "$PERFDATA_DIR" ]; then
info "$PERFDATA_DIR already exists, exiting"
exit 0
fi;
#> goto pass [ server-ip; ]
"$PERFSCRIPT_DIR"/run-test.sh "$PERFDATA_DIR"
#> goto pass [ cache-dir; ]
"$PERFSCRIPT_DIR"/plot.sh "$PERFDATA_DIR"
;;
*)
info "Job '${JOB}' compiled to '${BIN_EXT}' target doesn't support performance-testing"
;;
esac