3 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like. Any license provided herein, whether implied or
16 # otherwise, applies only to this software file. Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA 94043, or:
29 # For further information regarding this notice, see:
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 # automatic qa system. 31/08/00 dxm@sgi.com
36 # Usage: auto_qa start-state [stop-state]
37 # Do auto_qa from start-state up to stop-state inclusive
38 # or if no stop-state given then do it until reach "done" state.
50 if [ "$started" = "1" ]
52 echo "auto-qa stopped" | wall
58 # send special email if a cron'd qa run fails
62 mail -s "XFS QA status report" $EMAIL < $LOG 2>&1
72 [ -x "$KWORKAREA" ] || return
73 [ -r "$KWORKAREA/Makefile" ] \
74 || _fail "can't read kernel makefile $KWORKAREA/Makefile"
77 BEGIN { FS = "[ \t=]+" }
79 /^PATCHLEVEL =/ { b=$2 }
80 /^SUBLEVEL =/ { c=$2 }
81 /^EXTRAVERSION =/ { d=$2 }
83 print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
85 ' < $KWORKAREA/Makefile`
88 # this should be constant
92 if [ ! -z "$CVSROOT" ]; then
93 export WORKAREA="$ROOT/xfs-cmds"
95 [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/xfs-cmds"
99 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
101 QADIR="$WORKAREA/xfstests"
103 CONFIG="$ROOT/$HOST.config"
104 COMMON_CONFIG="$QADIR/common.config"
108 # do some cleanup on exit
112 umount $SCRATCH_DEV &> /dev/null
113 umount $TEST_DEV &> /dev/null
114 if [ "$started" = 1 ]
116 echo "auto-qa stopped" | wall
121 trap "_cleanup; exit \$status" 0 1 2 3 15
146 # if have state XXXX-state then preserve XXXX-newstate
157 _set_state `echo $state | sed "s/-.*$/-$new/"`
169 $ROOT/su -c "$*" < /dev/null ;# HACK - we need a hacked su at the mo
174 exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
179 if [ -z "$CVSROOT" ]; then
180 _log " *** p_tupdate"
182 WORKAREA="$1" p_tupdate 2>&1 \
183 || _fail " !!! p_tupdate failed"
185 _log " *** non-trunk files"
187 WORKAREA="$1" p_list -c 2>&1 \
188 || _fail " !!! p_list failed"
190 _log " *** cvs update"
199 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
200 TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
201 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
202 TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
203 _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
205 if [ "$USE_BIG_LOOPFS" = yes ]; then
206 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
207 _sudo $QADIR/tools/ag-wipe -q -r $RETAIN_AG_BYTES $TEST_DEV
215 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
216 TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
217 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
218 TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
219 _sudo mount -t xfs $TEST_OPTIONS $* $TEST_DEV $TEST_DIR
224 _sudo cp -f "$KWORKAREA/arch/i386/boot/bzImage" "$IMAGE" 2>&1 \
225 || _fail " !!! install kernel failed"
226 _sudo cp -f "$KWORKAREA/System.map" "$SYSTEMMAP" 2>&1 \
227 || _fail " !!! install kernel failed"
228 if [ -z "$KMODULES" -o "$KMODULES" = yes ]; then
229 _sudo make EXTRAVERSION=-$EXTRA modules_install 2>&1 \
230 || _fail " !!! install modules failed"
234 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
235 _log " *** reinit lilo"
236 _sudo /sbin/lilo 2>&1 \
237 || _fail " !!! reinit lilo failed"
243 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
244 _sudo /sbin/lilo -R $EXTRA $KERNEL_OPTIONS 2>&1 \
245 || _fail " !!! lilo failed"
251 echo not yet implemented
256 echo not yet implemented
261 [ -d "$KWORKAREA" ] || _fail " !!! QA kernel workarea \"$KWORKAREA\" not found"
262 [ -r "$CONFIG" ] || _fail " !!! Can't read config file $CONFIG"
266 _log "*** XFS QA (`date`)"
270 # check preconditions for starting state
279 _fail " !!! cron-init while not in \"*done\" state"
284 # we don't auto restart after reboot, but cron the restart
285 # to happen a bit later - it's much easier and safer that way
286 if [ "$state" != "cron-restarted" ]
288 _fail " !!! cron-restarted while not in \"cron-restarted\" state"
293 [ -n "$1" ] && _set_state $1
294 [ -n "$2" ] && stop_state=$2
296 [ "$UID" -eq 0 ] && _fail " !!! QA most be run as a normal user"
297 [ -d "$ROOT" ] || _fail " !!! QA root \"$ROOT\" not found"
298 [ -d "$WORKAREA" ] || _fail " !!! QA workarea \"$WORKAREA\" not found"
300 . "$COMMON_CONFIG" || _fail " !!! Couldn't source $COMMON_CONFIG"
303 IMAGE="$BOOT/vmlinuz-$EXTRA"
304 SYSTEMMAP="$BOOT/System.map-$VERSION-$EXTRA"
305 MODULES="/lib/modules/$SVERSION"
310 echo "auto-qa started" | wall
316 _log " *** state $state start (`date`)"
317 _log " (user=$USER, host=$HOST)"
325 echo "" > $ROOT/qa.log
326 echo "" > $ROOT/qa.full
327 _log "******************************************************"
328 _log "QA init $VERSION (`date`)"
329 _log "******************************************************"
330 new_state="updatetools"
334 _update_workarea "$WORKAREA"
335 new_state="cleantools"
339 # we need to configure or else we might fail to clean
340 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
342 [ -d $WORKAREA/$pkg ] || continue
344 _log " *** clean $pkg tools"
345 make realclean 2>&1 \
346 || _fail " !!! clean $pkg failed"
348 new_state="buildtools"
352 _log " *** build and install tools"
353 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
355 [ -d $WORKAREA/$pkg ] || continue
358 # use e-fence - but this will only take effect on configure
359 make configure 2>&1 \
360 || _fail " !!! configure $pkg failed"
362 || _fail " !!! build $pkg failed"
364 _sudo make install install-dev 2>&1 \
365 || _fail " !!! install $pkg failed"
367 # attr and acl now have install-lib targets as well
368 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
369 _sudo make install-lib 2>&1 \
370 || _fail " !!! install $pkg failed"
373 new_state="updatekernel"
378 _update_workarea "$KWORKAREA"
379 new_state="cleankernel"
384 _log " *** clean kernel"
387 || _fail " !!! clean kernel failed"
389 _log " *** install configuration file"
390 cp -f $CONFIG "$KWORKAREA/.config" 2>&1 \
391 || _fail " !!! failed to install config"
393 _log " *** remove version file"
394 rm -f include/linux/version.h 2>&1 \
395 || _fail " !!! failed to clean version"
402 _log " *** reconfig kernel"
404 # we better start from scratch if this fails
405 _change_state "cleankernel"
408 # we want to use default options for any new config options.
409 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
410 make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
411 || _fail " !!! reconfig oldconfig failed"
412 make EXTRAVERSION=-$EXTRA dep 2>&1 \
413 || _fail " !!! reconfig dep failed"
415 new_state="buildkernel"
420 _log " *** build kernel"
421 _log " --- kernel ($IMAGE)"
422 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
423 _log " --- modules ($MODULES)"
425 _change_state "cleankernel" ; # we better start from scratch if this fails
428 [ -z "$KTARGET" ] && KTARGET=bzImage
429 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
430 KTARGET="$KTARGET modules"
431 make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
432 || _fail " !!! build $KTARGET failed"
438 _log " *** blat old modules"
439 _sudo rm -rf $MODULES
441 _log " *** install kernel"
445 i386|i686) _i386_install ;;
446 ia64) _ia64_install ;;
453 _log " *** select qa kernel"
456 i386|i686) _i386_restart ;;
457 ia64) _ia64_restart ;;
460 _log " *** prepare to restart"
461 _change_state "restarted"
463 _log " *** restarting"
465 _restart # doesn't return
469 _log " *** QA reentered after restart"
476 _log " *** uname $uname"
478 if [ "$MODULAR" -eq 0 ]; then
486 _log " *** modules dependencies"
487 _sudo depmod -a 2>&1 \
488 || _fail " !!! failed to depmod -a"
490 _log " *** unmounting XFS mounts"
491 _sudo umount -a -t xfs 2>&1
493 _log " *** removing modules"
494 for m in xfsidbg xfs kdbm_pg kdbm_vm
496 _sudo rmmod $m 2> /dev/null
499 _log " *** installing modules"
500 _sudo modprobe xfs 2>&1 \
501 || _fail " !!! failed to modprobe xfs"
508 _log " *** unmounting TEST_DEV"
509 _sudo umount $TEST_DEV 2>&1
511 _log " *** unmounting SCRATCH_DEV"
512 _sudo umount $SCRATCH_DEV 2>&1
514 _log " *** clean TEST_DEV"
515 _test_mkfs_xfs 2>&1 \
516 || _fail " !!! failed to mkfs TEST_DEV"
518 _log " *** mounting TEST_DEV"
520 || _fail " !!! failed to mount"
528 _log " *** run soak test"
529 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
530 || _fail " !!! failed to run soak test"
538 # $BENCHMARK is typically unset, which equates to "all"
540 _log " *** run benchmarks"
541 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
542 || _fail " !!! failed to run benchmarks"
545 _log " *** send results mail"
546 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
554 _log " *** run tests ($CHECK_OPTIONS)"
555 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
558 _log " *** send status mail"
559 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
565 _log "*** requested QA state transitions complete"
572 _log " *** do nothing"
576 _fail " !!! unknown state $state"
580 _log " *** state $state done (`date`)"
581 [ "$new_state" = "" ] && _fail " !!! no new state set"
583 if [ -n "$stop_state" ]
585 # remove hyphen prefixes
586 s1=`echo $start_state | sed 's/.*-//'`
587 s2=`echo $stop_state | sed 's/.*-//'`
591 # we have been requested to stop here and not go on
596 _change_state $new_state