#!/bin/sh
# PCP QA Test No. 1721
# Exercise the bpftrace PMDA - autostart script
#

seq=`basename $0`
echo "QA output created by $seq"

. ./common.bpftrace

_pmdabpftrace_check

status=1       # failure is the default!
$sudo rm -rf $tmp.* $seq.full

_prepare_pmda bpftrace
trap "_pmdabpftrace_cleanup; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd


# real QA test starts here
_pmdabpftrace_clean_autostart_scripts
$sudo cp $PCP_PMDAS_DIR/bpftrace/autostart.backup/biolatency.bt $PCP_PMDAS_DIR/bpftrace/autostart
cat <<EOF | _pmdabpftrace_install
# Installed by PCP QA test $seq on `date`
EOF

echo "=== check script is running ==="
_pmdabpftrace_wait_for_value bpftrace.scripts.biolatency.probes 3
pminfo bpftrace

echo "=== check metrics ==="
pminfo -dfmtT bpftrace.scripts.biolatency.status


_pmdabpftrace_remove
status=0
exit
