3 # Copyright (c) 2000-2002 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 # configuration (you could tune this)
47 if [ "$started" = "1" ]
49 echo "auto-qa stopped" | wall
55 # send special email if a cron'd qa run fails
59 mail -s "XFS QA status report" $EMAIL \
71 || _fail "can't access workarea $WORKAREA"
72 [ -r "$WORKAREA/linux/Makefile" ] \
73 || _fail "can't read makefile $WORKAREA/linux/Makefile"
76 BEGIN { FS = "[ \t=]+" }
78 /^PATCHLEVEL =/ { b=$2 }
79 /^SUBLEVEL =/ { c=$2 }
80 /^EXTRAVERSION =/ { d=$2 }
82 print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
84 ' < $WORKAREA/linux/Makefile`
87 # this should be constant
91 if [ ! -z "$CVSROOT" ]; then
92 WORKAREA="$ROOT/linux-2.4-xfs"
94 [ -z "$WORKAREA" ] && WORKAREA="$ROOT/linux-xfs"
99 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
101 QADIR="$WORKAREA/cmd/xfstests"
103 CONFIG="$ROOT/$HOST.config"
104 COMMON_CONFIG="$WORKAREA/cmd/xfstests/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
155 _set_state `echo $state | sed "s/-.*$/-$new/"`
167 $ROOT/su -c "$*" < /dev/null ;# HACK - we need a hacked su at the mo
172 exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
175 _update_autoqa_file()
178 SELF_UPDATE="cmd/xfstests/tools/auto-qa"
179 if [ -z "$CVSROOT" ]; then
180 cmd="p_tupdate $SELF_UPDATE"
182 cmd="cvs -z3 update $SELF_UPDATE"
184 exec $SH -c "cd $WORKAREA ; $cmd; chmod +x $SELF_UPDATE ; exec $SELF"
189 if [ -z "$CVSROOT" ]; then
190 _log " *** p_tupdate"
193 || _fail " !!! p_tupdate failed"
195 _log " *** p_check/p_purge"
197 p_check -s | p_purge -yiu 2>&1 \
198 || _fail " !!! p_check/p_purge failed"
200 _log " *** non-trunk files"
203 || _fail " !!! p_list failed"
205 _log " *** cvs update"
214 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
215 TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
216 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
217 TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
218 _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
220 [ "$USE_BIG_LOOPFS" = yes ] && \
221 _sudo $QADIR/tools/ag-wipe -c $TEST_DEV >/dev/null
228 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
229 TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
230 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
231 TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
232 _sudo mount -t xfs $TEST_OPTIONS $* $TEST_DEV $TEST_DIR
236 _log "*** linux-xfs QA (`date`)"
240 # check preconditions for starting state
249 _fail " !!! cron-init while not in \"*done\" state"
254 # we don't auto restart after reboot, but cron the restart
255 # to happen a bit later - it's much easier and safer that way
256 if [ "$state" != "cron-restarted" ]
258 _fail " !!! cron-restarted while not in \"cron-restarted\" state"
268 [ "$UID" -eq 0 ] && _fail " !!! QA most be run as a normal user"
269 [ -d "$ROOT" ] || _fail " !!! QA root \"$ROOT\" not found"
270 [ -d "$WORKAREA" ] || _fail " !!! QA workarea \"$WORKAREA\" not found"
271 [ -r "$CONFIG" ] || _fail " !!! Can't read config file $CONFIG"
272 . "$COMMON_CONFIG" || _fail " !!! Couldn't source $COMMON_CONFIG"
275 IMAGE="$BOOT/vmlinuz$EXTRA"
276 SYSTEMMAP="$BOOT/System.map-$VERSION$EXTRA"
277 MODULES="/lib/modules/$SVERSION"
282 echo "auto-qa started" | wall
288 _log " *** state $state start (`date`)"
289 _log " (user=$USER, host=$HOST)"
295 echo "" > $ROOT/qa.log
296 echo "" > $ROOT/qa.full
297 _log "******************************************************"
298 _log "QA init $VERSION (`date`)"
299 _log "******************************************************"
300 _log "--- kernel ($IMAGE)"
301 _log "--- modules ($MODULES)"
303 _change_state "inited"
308 _log " *** QA initialized"
318 # we need to configure or else we might fail to clean
319 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
321 cd $WORKAREA/cmd/$pkg
322 _log " *** clean $pkg tools"
323 make realclean 2>&1 \
324 || _fail " !!! clean $pkg failed"
327 _log " *** clean linux"
330 || _fail " !!! clean linux failed"
332 _log " *** install configuration file"
333 cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
334 || _fail " !!! failed to install config"
336 _log " *** remove version file"
337 rm -f include/linux/version.h 2>&1 \
338 || _fail " !!! failed to clean version"
345 _log " *** reconfig kernel"
347 _change_state "clean" ; # we better start from scratch if this fails
350 # we want to use default options for any new config options.
351 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
352 make EXTRAVERSION=$EXTRA oldconfig 2>&1 \
353 || _fail " !!! reconfig oldconfig failed"
354 make EXTRAVERSION=$EXTRA dep 2>&1 \
355 || _fail " !!! reconfig dep failed"
357 new_state="buildtools"
361 _log " *** build and install tools"
362 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
364 cd $WORKAREA/cmd/$pkg
366 # use e-fence - but this will only take effect on configure
367 make configure 2>&1 \
368 || _fail " !!! configure $pkg failed"
370 || _fail " !!! build $pkg failed"
372 _sudo make install install-dev 2>&1 \
373 || _fail " !!! install $pkg failed"
375 # attr and acl now have install-lib targets as well
376 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
377 _sudo make install-lib 2>&1 \
378 || _fail " !!! install $pkg failed"
381 new_state="buildkernel"
385 _log " *** build kernel"
387 _change_state "clean" ; # we better start from scratch if this fails
390 make -j4 EXTRAVERSION=$EXTRA bzImage modules 2>&1 \
391 || _fail " !!! build bzImage/modules failed"
396 _log " *** blat old modules"
398 _sudo rm -rf $MODULES
400 _log " *** install kernel"
402 _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
403 || _fail " !!! install kernel failed"
404 _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
405 || _fail " !!! install kernel failed"
406 _sudo make EXTRAVERSION=$EXTRA modules_install 2>&1 \
407 || _fail " !!! install modules failed"
409 _log " *** reinit lilo"
410 _sudo /sbin/lilo 2>&1 \
411 || _fail " !!! reinit lilo failed"
416 _log " *** select qa kernel"
417 _sudo /sbin/lilo -R linux-xfs-qa $KERNEL_OPTIONS 2>&1 \
418 || _fail " !!! lilo failed"
420 _log " *** prepare to restart"
421 _change_state "restarted"
423 _log " *** restarting"
425 _restart # doesn't return
429 _log " *** QA reentered after restart"
436 _log " *** uname $uname"
438 ls -l /boot/*$EXTRA* 2>&1
439 _log " *** kernel modules"
440 [ -d /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs ] && \
441 ls -l /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs/*
443 if [ "$MODULAR" -eq 0 ]
452 _log " *** modules dependencies"
454 _sudo depmod -a 2>&1 \
455 || _fail " !!! failed to depmod -a"
457 _log " *** unmounting XFS mounts"
459 _sudo umount -a -t xfs 2>&1
461 _log " *** removing modules"
463 for m in xfsidbg xfs kdbm_pg kdbm_vm
465 _sudo rmmod $m 2> /dev/null
468 _log " *** installing modules"
470 _sudo modprobe xfs 2>&1 \
471 || _fail " !!! failed to modprobe xfs"
478 _log " *** unmounting TEST_DEV"
480 _sudo umount $TEST_DEV 2>&1
482 _log " *** unmounting SCRATCH_DEV"
484 _sudo umount $SCRATCH_DEV 2>&1
486 _log " *** clean TEST_DEV"
488 _test_mkfs_xfs 2>&1 \
489 || _fail " !!! failed to mkfs TEST_DEV"
491 _log " *** mounting TEST_DEV"
494 || _fail " !!! failed to mount"
502 _log " *** run soak test"
503 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
504 || _fail " !!! failed to run soak test"
512 # $BENCHMARK is typically unset, which equates to "all"
514 _log " *** run benchmarks"
515 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
516 || _fail " !!! failed to run benchmarks"
519 _log " *** send results mail"
520 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
528 _log " *** run tests ($CHECK_OPTIONS)"
529 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
532 _log " *** send status mail"
533 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
539 _log "*** QA run complete"
546 _log " *** do nothing"
550 _fail " !!! unknown state $state"
554 _log " *** state $state done (`date`)"
555 [ "$new_state" = "" ] && _fail " !!! no new state set"
556 _change_state $new_state