#!/bin/sh

set -e

if [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt 2 ] ; then \
    echo
    echo "***********************************************************"
    echo "error: not running test suite, /proc/sys/kernel/perf_event_paranoid value too high"
    echo "***********************************************************"
    echo
    exit 0
fi

coz run --- /bin/ls

if grep -q 'startup	time=' profile.coz ; then
    echo "success: coz ran successfully"
    cat profile.coz |sed 's/^/  /'
    rm profile.coz
else
    echo "error: coz failed to run"
    rm profile.coz
    exit 1
fi
