Joseph Beckenbach | 169720f | 2014-03-26 15:08:46 +0000 | [diff] [blame] | 1 | #!/bin/bash |
subrata_modak | 2173c48 | 2007-12-27 10:02:41 +0000 | [diff] [blame] | 2 | ################################################################################ |
| 3 | ## ## |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 4 | ## Copyright © International Business Machines Corp., 2007, 2008 ## |
subrata_modak | 2173c48 | 2007-12-27 10:02:41 +0000 | [diff] [blame] | 5 | ## ## |
| 6 | ## This program is free software; you can redistribute it and#or modify ## |
| 7 | ## it under the terms of the GNU General Public License as published by ## |
| 8 | ## the Free Software Foundation; either version 2 of the License, or ## |
| 9 | ## (at your option) any later version. ## |
| 10 | ## ## |
| 11 | ## This program is distributed in the hope that it will be useful, but ## |
| 12 | ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## |
| 13 | ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## |
| 14 | ## for more details. ## |
| 15 | ## ## |
| 16 | ## You should have received a copy of the GNU General Public License ## |
| 17 | ## along with this program; if not, write to the Free Software ## |
Wanlong Gao | 4548c6c | 2012-10-19 18:03:36 +0800 | [diff] [blame] | 18 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## |
subrata_modak | 2173c48 | 2007-12-27 10:02:41 +0000 | [diff] [blame] | 19 | ## ## |
| 20 | ################################################################################ |
| 21 | |
| 22 | |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 23 | # |
| 24 | # Script to run the tests in rt-test |
| 25 | # |
| 26 | # Usage: $0 test_argument |
| 27 | # |
| 28 | # where test-argument = func | stress | perf | all | list | clean | test_name |
| 29 | # |
| 30 | # test_name is the name of a subdirectory in func/, stress/ or perf/ |
| 31 | # |
| 32 | |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 33 | usage() |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 34 | { |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 35 | cat <<EOF |
| 36 | usage: $(basename "$0") [-p profile] -t test-argument [-l num_of_loops] |
| 37 | |
| 38 | -h help |
| 39 | -p profile Use profile instead of default (see |
| 40 | doc/AUTOMATED_RUN) |
| 41 | -t test-arguments Where test-argument can be a space separated |
| 42 | sequence of: |
| 43 | func all functional tests will be run |
| 44 | stress all stress tests will be run |
| 45 | perf all perf tests will be run |
| 46 | all all tests will be run |
| 47 | list all available tests will be listed |
| 48 | clean all logs deleted, make clean |
| 49 | performed |
| 50 | test_name only test_name subdir will be run |
| 51 | (e.g: func/pi-tests) |
| 52 | |
| 53 | EOF |
| 54 | exit 1 |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 55 | } |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 56 | check_error() |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 57 | { |
| 58 | if [ $? -gt 0 ]; then |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 59 | echo |
| 60 | echo " $1 Failed" |
| 61 | echo |
| 62 | exit 1 |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 63 | fi |
| 64 | } |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 65 | list_tests() |
| 66 | { |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 67 | echo |
| 68 | echo " Available tests are:" |
| 69 | echo |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 70 | |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 71 | pushd $TESTS_DIR >/dev/null |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 72 | for file in `find -name run_auto.sh` |
| 73 | do |
Petr Vorel | 0702d49 | 2016-11-29 09:22:40 +0100 | [diff] [blame] | 74 | echo " `dirname $file `" |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 75 | done |
Petr Vorel | 0702d49 | 2016-11-29 09:22:40 +0100 | [diff] [blame] | 76 | printf " \n\n" |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 79 | run_test() |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 80 | { |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 81 | local profile |
| 82 | |
| 83 | profile=$1 |
| 84 | shift |
| 85 | |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 86 | iter=0 |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 87 | LOOPS=$(( 0 + $2 )) |
| 88 | if [ $LOOPS -eq 0 ]; then |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 89 | LOOPS=1 |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 90 | fi |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 91 | if [ -d "$test" ]; then |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 92 | pushd $test >/dev/null |
| 93 | if [ -f "run_auto.sh" ]; then |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 94 | echo " Running $LOOPS runs of $subdir " |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 95 | iter=0 |
| 96 | while [ $iter -lt $LOOPS ]; do |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 97 | ./run_auto.sh $profile |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 98 | : $(( iter += 1 )) |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 99 | done |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 100 | else |
| 101 | echo |
| 102 | echo " Failed to find run script in $test \n" |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 103 | fi |
| 104 | pushd $TESTS_DIR >/dev/null |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 105 | else |
Petr Vorel | 0702d49 | 2016-11-29 09:22:40 +0100 | [diff] [blame] | 106 | printf "\n $test is not a valid test subdirectory \n" |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 107 | usage |
| 108 | exit 1 |
| 109 | fi |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 110 | } |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 111 | |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 112 | make_clean() |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 113 | { |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 114 | pushd $TESTS_DIR >/dev/null |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 115 | rm -rf logs/* |
| 116 | for mfile in `find -name "Makefile"`; |
| 117 | do |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 118 | target_dir=`dirname $mfile` |
| 119 | pushd $target_dir >/dev/null |
| 120 | make clean |
| 121 | pushd $TESTS_DIR >/dev/null |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 122 | done |
| 123 | } |
| 124 | |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 125 | find_test() |
| 126 | { |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 127 | local profile |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 128 | |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 129 | profile=$1 |
| 130 | shift |
| 131 | |
| 132 | case $1 in |
| 133 | func) |
| 134 | TESTLIST="func" |
| 135 | ;; |
| 136 | stress) |
| 137 | TESTLIST="stress" |
| 138 | ;; |
| 139 | perf) |
| 140 | TESTLIST="perf" |
| 141 | ;; |
| 142 | all) |
| 143 | # Run all tests which have run_auto.sh |
subrata_modak | 7859695 | 2008-09-18 10:30:56 +0000 | [diff] [blame] | 144 | TESTLIST="func stress perf" |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 145 | ;; |
| 146 | list) |
| 147 | # This will only display subdirs which have run_auto.sh |
| 148 | list_tests |
| 149 | exit |
| 150 | ;; |
| 151 | clean) |
| 152 | # This will clobber logs, out files, .o's etc |
| 153 | make_clean |
| 154 | exit |
| 155 | ;; |
| 156 | |
| 157 | *) |
| 158 | # run the tests in the individual subdirectory if it exists |
| 159 | TESTLIST="$1" |
| 160 | ;; |
| 161 | esac |
| 162 | |
| 163 | for subdir in $TESTLIST; do |
| 164 | if [ -d $subdir ]; then |
| 165 | pushd $subdir >/dev/null |
| 166 | for name in `find -name "run_auto.sh"`; do |
| 167 | test="`dirname $name`" |
| 168 | run_test "$profile" "$test" "$2" |
| 169 | pushd $subdir > /dev/null |
| 170 | done |
| 171 | pushd $TESTS_DIR >/dev/null |
| 172 | else |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 173 | echo |
| 174 | echo " $subdir not found; check name/path with $0 list " |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 175 | fi |
| 176 | done |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 177 | |
| 178 | } |
| 179 | |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 180 | SCRIPTS_DIR="$(readlink -f "$(dirname "$0")")/scripts" |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 181 | source $SCRIPTS_DIR/setenv.sh |
| 182 | |
| 183 | if [ $# -lt 1 ]; then |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 184 | usage |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 185 | fi |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 186 | pushd $TESTS_DIR >/dev/null |
| 187 | |
Anders Roxell | 45929dc | 2013-08-05 21:02:58 +0200 | [diff] [blame] | 188 | # if INSTALL_DIR != top_srcdir assume the individual tests are built and installed. |
| 189 | # So no need to build lib |
| 190 | if [[ -d lib ]]; then |
| 191 | #Only build the library, most of the tests depend upon. |
| 192 | #The Individual tests will be built, just before they run. |
| 193 | pushd lib |
| 194 | make |
| 195 | check_error make |
| 196 | popd |
| 197 | fi |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 198 | |
| 199 | ISLOOP=0 |
| 200 | index=0 |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 201 | while getopts "hl:p:t:" option |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 202 | do |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 203 | case "$option" in |
| 204 | |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 205 | t ) |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 206 | if [ $ISLOOP -eq 1 ]; then |
| 207 | LOOP=1 |
| 208 | tests[$index]=$LOOP |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 209 | : $(( index += 1 )) |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 210 | fi |
| 211 | |
| 212 | tests[$index]="$OPTARG" |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 213 | : $((index += 1 )) |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 214 | TESTCASE="$OPTARG" |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 215 | ISLOOP=1 |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 216 | ;; |
| 217 | |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 218 | l ) |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 219 | ISLOOP=0 |
| 220 | tests[$index]="$OPTARG" |
| 221 | LOOP="$OPTARG" |
| 222 | index=$((index+1)) |
| 223 | ;; |
| 224 | p ) |
| 225 | profile=$OPTARG |
| 226 | ;; |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 227 | h ) |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 228 | usage |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 229 | ;; |
subrata_modak | 1378205 | 2008-02-22 14:43:53 +0000 | [diff] [blame] | 230 | * ) echo "Unrecognized option specified" |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 231 | usage |
| 232 | ;; |
| 233 | esac |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 234 | done |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 235 | i=0 |
| 236 | while [ $i -lt $index ]; do |
subrata_modak | 1ffddf0 | 2008-05-22 12:03:14 +0000 | [diff] [blame] | 237 | find_test "$profile" ${tests[$i]} ${tests[$((i+1))]} |
Garrett Cooper | ead440f | 2010-11-01 23:58:28 -0700 | [diff] [blame] | 238 | : $(( i += 2 )) |
subrata_modak | 6acdc8e | 2007-12-26 11:11:45 +0000 | [diff] [blame] | 239 | done |