#!/bin/sh -eu

fail () {
    printf "%s\n" "$*"
    exit
}

count_ticks --cpu 0 --start || fail "Failed starting tick counting"
find /usr -name dummy 2>&1 > /dev/null

nr_ticks=$(count_ticks --batch --cpu 0 --end)

if [ $? -ne 0 ]; then
    echo "FAIL: count_ticks failed execution"
    exit
fi

if [ $nr_ticks == 0 ]; then
    echo "FAIL: count_ticks didn't see any ticks"
    exit
fi

echo "PASS: count_ticks"
