sleep.sh 836 Bytes
Newer Older
Philip Carns's avatar
Philip Carns committed
1 2 3 4 5 6 7
#!/bin/bash

set -x

out1=/tmp/sleep-standard-$$.out
out2=/tmp/sleep-abt-$$.out

8
bash -c "time -p tests/margo-test-sleep 1" >& $out1
Philip Carns's avatar
Philip Carns committed
9 10 11 12 13
if [ $? -ne 0 ]; then
    exit 1
fi
standardrealtime=`grep real $out1 | cut -d ' ' -f 2 |cut -d '.' -f 1`

14
bash -c "time -p tests/margo-test-sleep 1 ABT" >& $out2
Philip Carns's avatar
Philip Carns committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
if [ $? -ne 0 ]; then
    exit 1
fi
abtrealtime=`grep real $out2 | cut -d ' ' -f 2 |cut -d '.' -f 1`

echo standard:
cat $out1

echo abt:
cat $out2

# standard one should take at least 4 seconds to complete; there are 4
# serialized sleeps of 1 second each
if [ "$standardrealtime" -lt 4 ]; then
    exit 1
fi

# abt one should take at least one second, but no more than 2 (there are 4
# sleeps running concurrently)
if [ "$abtrealtime" -lt 1 ]; then
    exit 1
fi
if [ "$abtrealtime" -gt 2 ]; then
    exit 1
fi

rm $out1
rm $out2

exit 0