|
|
1.1 ! root 1: #!/bin/bash ! 2: # ! 3: # Copyright (C) 2009 Red Hat, Inc. ! 4: # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved. ! 5: # ! 6: # This program is free software; you can redistribute it and/or ! 7: # modify it under the terms of the GNU General Public License as ! 8: # published by the Free Software Foundation. ! 9: # ! 10: # This program is distributed in the hope that it would be useful, ! 11: # but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 13: # GNU General Public License for more details. ! 14: # ! 15: # You should have received a copy of the GNU General Public License ! 16: # along with this program. If not, see <http://www.gnu.org/licenses/>. ! 17: # ! 18: # ! 19: # common procedures for QA scripts ! 20: # ! 21: ! 22: _setenvironment() ! 23: { ! 24: MSGVERB="text:action" ! 25: export MSGVERB ! 26: } ! 27: ! 28: here=`pwd` ! 29: rm -f $here/$iam.out ! 30: _setenvironment ! 31: ! 32: check=${check-true} ! 33: ! 34: diff="diff -u" ! 35: verbose=false ! 36: group=false ! 37: xgroup=false ! 38: imgopts=false ! 39: showme=false ! 40: sortme=false ! 41: expunge=true ! 42: have_test_arg=false ! 43: randomize=false ! 44: rm -f $tmp.list $tmp.tmp $tmp.sed ! 45: ! 46: export IMGFMT=raw ! 47: export IMGPROTO=file ! 48: export IMGOPTS="" ! 49: export QEMU_IO_OPTIONS="" ! 50: ! 51: for r ! 52: do ! 53: ! 54: if $group ! 55: then ! 56: # arg after -g ! 57: group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ ! 58: s/ .*//p ! 59: }'` ! 60: if [ -z "$group_list" ] ! 61: then ! 62: echo "Group \"$r\" is empty or not defined?" ! 63: exit 1 ! 64: fi ! 65: [ ! -s $tmp.list ] && touch $tmp.list ! 66: for t in $group_list ! 67: do ! 68: if grep -s "^$t\$" $tmp.list >/dev/null ! 69: then ! 70: : ! 71: else ! 72: echo "$t" >>$tmp.list ! 73: fi ! 74: done ! 75: group=false ! 76: continue ! 77: ! 78: elif $xgroup ! 79: then ! 80: # arg after -x ! 81: [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null ! 82: group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ ! 83: s/ .*//p ! 84: }'` ! 85: if [ -z "$group_list" ] ! 86: then ! 87: echo "Group \"$r\" is empty or not defined?" ! 88: exit 1 ! 89: fi ! 90: numsed=0 ! 91: rm -f $tmp.sed ! 92: for t in $group_list ! 93: do ! 94: if [ $numsed -gt 100 ] ! 95: then ! 96: sed -f $tmp.sed <$tmp.list >$tmp.tmp ! 97: mv $tmp.tmp $tmp.list ! 98: numsed=0 ! 99: rm -f $tmp.sed ! 100: fi ! 101: echo "/^$t\$/d" >>$tmp.sed ! 102: numsed=`expr $numsed + 1` ! 103: done ! 104: sed -f $tmp.sed <$tmp.list >$tmp.tmp ! 105: mv $tmp.tmp $tmp.list ! 106: xgroup=false ! 107: continue ! 108: ! 109: elif $imgopts ! 110: then ! 111: IMGOPTS="$r" ! 112: imgopts=false ! 113: continue ! 114: ! 115: fi ! 116: ! 117: xpand=true ! 118: case "$r" ! 119: in ! 120: ! 121: -\? | -h | --help) # usage ! 122: echo "Usage: $0 [options] [testlist]"' ! 123: ! 124: common options ! 125: -v verbose ! 126: ! 127: check options ! 128: -raw test raw (default) ! 129: -cow test cow ! 130: -qcow test qcow ! 131: -qcow2 test qcow2 ! 132: -qed test qed ! 133: -vdi test vdi ! 134: -vpc test vpc ! 135: -vmdk test vmdk ! 136: -rbd test rbd ! 137: -sheepdog test sheepdog ! 138: -xdiff graphical mode diff ! 139: -nocache use O_DIRECT on backing file ! 140: -misalign misalign memory allocations ! 141: -n show me, do not run tests ! 142: -o options -o options to pass to qemu-img create/convert ! 143: -T output timestamps ! 144: -r randomize test order ! 145: ! 146: testlist options ! 147: -g group[,group...] include tests from these groups ! 148: -x group[,group...] exclude tests from these groups ! 149: NNN include test NNN ! 150: NNN-NNN include test range (eg. 012-021) ! 151: ' ! 152: exit 0 ! 153: ;; ! 154: ! 155: -raw) ! 156: IMGFMT=raw ! 157: xpand=false ! 158: ;; ! 159: ! 160: -cow) ! 161: IMGFMT=cow ! 162: xpand=false ! 163: ;; ! 164: ! 165: -qcow) ! 166: IMGFMT=qcow ! 167: xpand=false ! 168: ;; ! 169: ! 170: -qcow2) ! 171: IMGFMT=qcow2 ! 172: xpand=false ! 173: ;; ! 174: ! 175: -qed) ! 176: IMGFMT=qed ! 177: xpand=false ! 178: ;; ! 179: ! 180: -vdi) ! 181: IMGFMT=vdi ! 182: xpand=false ! 183: ;; ! 184: ! 185: -vmdk) ! 186: IMGFMT=vmdk ! 187: xpand=false ! 188: ;; ! 189: ! 190: -vpc) ! 191: IMGFMT=vpc ! 192: xpand=false ! 193: ;; ! 194: ! 195: -rbd) ! 196: IMGPROTO=rbd ! 197: xpand=false ! 198: ;; ! 199: ! 200: -sheepdog) ! 201: IMGPROTO=sheepdog ! 202: xpand=false ! 203: ;; ! 204: ! 205: -nocache) ! 206: QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache" ! 207: xpand=false ! 208: ;; ! 209: ! 210: -misalign) ! 211: QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign" ! 212: xpand=false ! 213: ;; ! 214: ! 215: -g) # -g group ... pick from group file ! 216: group=true ! 217: xpand=false ! 218: ;; ! 219: ! 220: -xdiff) # graphical diff mode ! 221: xpand=false ! 222: ! 223: if [ ! -z "$DISPLAY" ] ! 224: then ! 225: which xdiff >/dev/null 2>&1 && diff=xdiff ! 226: which gdiff >/dev/null 2>&1 && diff=gdiff ! 227: which tkdiff >/dev/null 2>&1 && diff=tkdiff ! 228: which xxdiff >/dev/null 2>&1 && diff=xxdiff ! 229: fi ! 230: ;; ! 231: ! 232: -n) # show me, don't do it ! 233: showme=true ! 234: xpand=false ! 235: ;; ! 236: -o) ! 237: imgopts=true ! 238: xpand=false ! 239: ;; ! 240: -r) # randomize test order ! 241: randomize=true ! 242: xpand=false ! 243: ;; ! 244: ! 245: -T) # turn on timestamp output ! 246: timestamp=true ! 247: xpand=false ! 248: ;; ! 249: ! 250: -v) ! 251: verbose=true ! 252: xpand=false ! 253: ;; ! 254: -x) # -x group ... exclude from group file ! 255: xgroup=true ! 256: xpand=false ! 257: ;; ! 258: '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]') ! 259: echo "No tests?" ! 260: status=1 ! 261: exit $status ! 262: ;; ! 263: ! 264: [0-9]*-[0-9]*) ! 265: eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'` ! 266: ;; ! 267: ! 268: [0-9]*-) ! 269: eval `echo $r | sed -e 's/^/start=/' -e 's/-//'` ! 270: end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'` ! 271: if [ -z "$end" ] ! 272: then ! 273: echo "No tests in range \"$r\"?" ! 274: status=1 ! 275: exit $status ! 276: fi ! 277: ;; ! 278: ! 279: *) ! 280: start=$r ! 281: end=$r ! 282: ;; ! 283: ! 284: esac ! 285: ! 286: # get rid of leading 0s as can be interpreted as octal ! 287: start=`echo $start | sed 's/^0*//'` ! 288: end=`echo $end | sed 's/^0*//'` ! 289: ! 290: if $xpand ! 291: then ! 292: have_test_arg=true ! 293: $AWK_PROG </dev/null ' ! 294: BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ ! 295: | while read id ! 296: do ! 297: if grep -s "^$id " group >/dev/null ! 298: then ! 299: # in group file ... OK ! 300: echo $id >>$tmp.list ! 301: else ! 302: if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null ! 303: then ! 304: # expunged ... will be reported, but not run, later ! 305: echo $id >>$tmp.list ! 306: else ! 307: # oops ! 308: echo "$id - unknown test, ignored" ! 309: fi ! 310: fi ! 311: done ! 312: fi ! 313: ! 314: done ! 315: ! 316: # Set default options for qemu-img create -o if they were not specified ! 317: _set_default_imgopts ! 318: ! 319: if [ -s $tmp.list ] ! 320: then ! 321: # found some valid test numbers ... this is good ! 322: : ! 323: else ! 324: if $have_test_arg ! 325: then ! 326: # had test numbers, but none in group file ... do nothing ! 327: touch $tmp.list ! 328: else ! 329: # no test numbers, do everything from group file ! 330: sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list ! 331: fi ! 332: fi ! 333: ! 334: # should be sort -n, but this did not work for Linux when this ! 335: # was ported from IRIX ! 336: # ! 337: list=`sort $tmp.list` ! 338: rm -f $tmp.list $tmp.tmp $tmp.sed ! 339: ! 340: if $randomize ! 341: then ! 342: list=`echo $list | awk -f randomize.awk` ! 343: fi ! 344: ! 345: [ "$QEMU" = "" ] && _fatal "qemu not found" ! 346: [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found" ! 347: [ "$QEMU_IO" = "" ] && _fatal "qemu-img not found"
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.