1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/bin/bash
failed=0
failedTests="\n"
rootcheck () {
if [ $(id -u) != "0" ]
then
sudo "$0" "$@"
exit $?
fi
}
rootcheck
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ ! -e /usr/bin/stress-ng ]; then
echo "Please install stress-ng before running this script!"
exit 1
fi
if [ ! -e /usr/bin/dotnet ]; then
echo "Please install .NET before running this script!"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
function runTest {
printf "\n========================================================================================\n"
printf "\nStarting $(basename $1)\n"
$1
if [ $? -ne 0 ]; then
echo "$(basename $1) failed"
failedTests="$failedTests$(basename $1)\n"
failed=1
else
echo "$(basename $1) passed"
fi
}
for file in $DIR/scenarios/*.sh
do
runTest $file
done
printf "\nFailed tests: $failedTests"
if [ "$failed" -eq "1" ]; then
exit 1
else
exit 0
fi
|