#!/bin/sh
# PCP QA Test No. 1725
# Exercise the bpftrace PMDA - list tracepoints
#

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

. ./common.bpftrace

_pmdabpftrace_check

status=1       # failure is the default!

# on vm15 (MX Linux) tracefs was not mounted ...
#
if ! mount | grep -q tracefs
then
    echo "Hint: sudo mount -t tracefs none /sys/kernel/tracing" >>$seq_full
    _notrun "tracefs not mounted"
fi

_prepare_pmda bpftrace

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


# real QA test starts here
cat <<EOF | _pmdabpftrace_install
# Installed by PCP QA test $seq on `date`
EOF

echo "=== check tracepoint metric ==="
pminfo -dmtT bpftrace.info.tracepoints

echo
echo "=== check example tracepoint metric value ==="
pminfo -f bpftrace.info.tracepoints 2>&1 \
| tr ',' '\n' \
| tee -a $seq_full \
| grep kprobe:version_show

_pmdabpftrace_remove
status=0
exit
