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 # 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 < $LOG 2>&1
70 || _fail "can't access workarea $WORKAREA"
71 [ -r "$WORKAREA/linux/Makefile" ] \
72 || _fail "can't read makefile $WORKAREA/linux/Makefile"
75 BEGIN { FS = "[ \t=]+" }
77 /^PATCHLEVEL =/ { b=$2 }
78 /^SUBLEVEL =/ { c=$2 }
79 /^EXTRAVERSION =/ { d=$2 }
81 print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
83 ' < $WORKAREA/linux/Makefile`
86 # this should be constant
90 if [ ! -z "$CVSROOT" ]; then
91 export WORKAREA="$ROOT/linux-2.4-xfs"
93 [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/linux-xfs"
97 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
99 QADIR="$WORKAREA/cmd/xfstests"
101 CONFIG="$ROOT/$HOST.config"
102 COMMON_CONFIG="$WORKAREA/cmd/xfstests/common.config"
106 # do some cleanup on exit
110 umount $SCRATCH_DEV &> /dev/null
111 umount $TEST_DEV &> /dev/null
112 if [ "$started" = 1 ]
114 echo "auto-qa stopped" | wall
119 trap "_cleanup; exit \$status" 0 1 2 3 15
153 _set_state `echo $state | sed "s/-.*$/-$new/"`
165 $ROOT/su -c "$*" < /dev/null ;# HACK - we need a hacked su at the mo
170 exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
173 _update_autoqa_file()
176 SELF_UPDATE="cmd/xfstests/tools/auto-qa"
177 if [ -z "$CVSROOT" ]; then
178 cmd="p_tupdate $SELF_UPDATE"
180 cmd="cvs -z3 update $SELF_UPDATE"
182 exec $SH -c "cd $WORKAREA ; $cmd; chmod +x $SELF_UPDATE ; exec $SELF"
187 if [ -z "$CVSROOT" ]; then
188 _log " *** p_tupdate"
191 || _fail " !!! p_tupdate failed"
193 _log " *** p_check/p_purge"
195 p_check -s | p_purge -yiu 2>&1 \
196 || _fail " !!! p_check/p_purge failed"
198 _log " *** non-trunk files"
201 || _fail " !!! p_list failed"
203 _log " *** cvs update"
212 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
213 TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
214 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
215 TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
216 _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
218 if [ "$USE_BIG_LOOPFS" = yes ]; then
219 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
220 _sudo $QADIR/tools/ag-wipe -q -r $RETAIN_AG_BYTES $TEST_DEV
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
237 _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
238 || _fail " !!! install kernel failed"
239 _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
240 || _fail " !!! install kernel failed"
241 if [ -z "$KMODULES" -o "$KMODULES" = yes ]; then
242 _sudo make EXTRAVERSION=-$EXTRA modules_install 2>&1 \
243 || _fail " !!! install modules failed"
246 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
247 _log " *** reinit lilo"
248 _sudo /sbin/lilo 2>&1 \
249 || _fail " !!! reinit lilo failed"
255 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
256 _sudo /sbin/lilo -R $EXTRA $KERNEL_OPTIONS 2>&1 \
257 || _fail " !!! lilo failed"
263 echo not yet implemented
268 echo not yet implemented
272 _log "*** linux-xfs QA (`date`)"
276 # check preconditions for starting state
285 _fail " !!! cron-init while not in \"*done\" state"
290 # we don't auto restart after reboot, but cron the restart
291 # to happen a bit later - it's much easier and safer that way
292 if [ "$state" != "cron-restarted" ]
294 _fail " !!! cron-restarted while not in \"cron-restarted\" state"
304 [ "$UID" -eq 0 ] && _fail " !!! QA most be run as a normal user"
305 [ -d "$ROOT" ] || _fail " !!! QA root \"$ROOT\" not found"
306 [ -d "$WORKAREA" ] || _fail " !!! QA workarea \"$WORKAREA\" not found"
307 [ -r "$CONFIG" ] || _fail " !!! Can't read config file $CONFIG"
308 . "$COMMON_CONFIG" || _fail " !!! Couldn't source $COMMON_CONFIG"
311 IMAGE="$BOOT/vmlinuz-$EXTRA"
312 SYSTEMMAP="$BOOT/System.map-$VERSION-$EXTRA"
313 MODULES="/lib/modules/$SVERSION"
318 echo "auto-qa started" | wall
324 _log " *** state $state start (`date`)"
325 _log " (user=$USER, host=$HOST)"
331 echo "" > $ROOT/qa.log
332 echo "" > $ROOT/qa.full
333 _log "******************************************************"
334 _log "QA init $VERSION (`date`)"
335 _log "******************************************************"
336 _log "--- kernel ($IMAGE)"
337 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
338 _log "--- modules ($MODULES)"
340 _change_state "inited"
345 _log " *** QA initialized"
351 new_state="cleantools"
355 # we need to configure or else we might fail to clean
356 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
358 [ -d $WORKAREA/cmd/$pkg ] || continue
359 cd $WORKAREA/cmd/$pkg
360 _log " *** clean $pkg tools"
361 make realclean 2>&1 \
362 || _fail " !!! clean $pkg failed"
364 new_state="buildtools"
368 _log " *** build and install tools"
369 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
371 [ -d $WORKAREA/cmd/$pkg ] || continue
372 cd $WORKAREA/cmd/$pkg
374 # use e-fence - but this will only take effect on configure
375 make configure 2>&1 \
376 || _fail " !!! configure $pkg failed"
378 || _fail " !!! build $pkg failed"
380 _sudo make install install-dev 2>&1 \
381 || _fail " !!! install $pkg failed"
383 # attr and acl now have install-lib targets as well
384 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
385 _sudo make install-lib 2>&1 \
386 || _fail " !!! install $pkg failed"
389 new_state="cleankernel"
393 _log " *** clean linux"
396 || _fail " !!! clean linux failed"
398 _log " *** install configuration file"
399 cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
400 || _fail " !!! failed to install config"
402 _log " *** remove version file"
403 rm -f include/linux/version.h 2>&1 \
404 || _fail " !!! failed to clean version"
411 _log " *** reconfig kernel"
413 # we better start from scratch if this fails
414 _change_state "cleankernel"
417 # we want to use default options for any new config options.
418 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
419 make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
420 || _fail " !!! reconfig oldconfig failed"
421 make EXTRAVERSION=-$EXTRA dep 2>&1 \
422 || _fail " !!! reconfig dep failed"
424 new_state="buildkernel"
428 _log " *** build kernel"
430 _change_state "clean" ; # we better start from scratch if this fails
433 [ -z "$KTARGET" ] && KTARGET=bzImage
434 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
435 KTARGET="$KTARGET modules"
436 make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
437 || _fail " !!! build $KTARGET failed"
442 _log " *** blat old modules"
443 _sudo rm -rf $MODULES
445 _log " *** install kernel"
449 i386|i686) _i386_install ;;
450 ia64) _ia64_install ;;
453 if [ -z "$KRESTART" -o "$KRESTART" = yes ]; then
461 _log " *** select qa kernel"
464 i386|i686) _i386_restart ;;
465 ia64) _ia64_restart ;;
468 _log " *** prepare to restart"
469 _change_state "restarted"
471 _log " *** restarting"
473 _restart # doesn't return
477 _log " *** QA reentered after restart"
484 _log " *** uname $uname"
486 [ -n "/boot/*$EXTRA*" ] && \
487 ls -l /boot/*$EXTRA* 2>&1
488 _log " *** kernel modules"
489 [ -d /lib/modules/$SVERSION-$EXTRA/kernel/fs/xfs ] && \
490 ls -l /lib/modules/$SVERSION-$EXTRA/kernel/fs/xfs/*
492 if [ "$MODULAR" -eq 0 ]; then
500 _log " *** modules dependencies"
501 _sudo depmod -a 2>&1 \
502 || _fail " !!! failed to depmod -a"
504 _log " *** unmounting XFS mounts"
505 _sudo umount -a -t xfs 2>&1
507 _log " *** removing modules"
508 for m in xfsidbg xfs kdbm_pg kdbm_vm
510 _sudo rmmod $m 2> /dev/null
513 _log " *** installing modules"
514 _sudo modprobe xfs 2>&1 \
515 || _fail " !!! failed to modprobe xfs"
522 _log " *** unmounting TEST_DEV"
523 _sudo umount $TEST_DEV 2>&1
525 _log " *** unmounting SCRATCH_DEV"
526 _sudo umount $SCRATCH_DEV 2>&1
528 _log " *** clean TEST_DEV"
529 _test_mkfs_xfs 2>&1 \
530 || _fail " !!! failed to mkfs TEST_DEV"
532 _log " *** mounting TEST_DEV"
534 || _fail " !!! failed to mount"
542 _log " *** run soak test"
543 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
544 || _fail " !!! failed to run soak test"
552 # $BENCHMARK is typically unset, which equates to "all"
554 _log " *** run benchmarks"
555 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
556 || _fail " !!! failed to run benchmarks"
559 _log " *** send results mail"
560 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
568 _log " *** run tests ($CHECK_OPTIONS)"
569 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
572 _log " *** send status mail"
573 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
579 _log "*** QA run complete"
586 _log " *** do nothing"
590 _fail " !!! unknown state $state"
594 _log " *** state $state done (`date`)"
595 [ "$new_state" = "" ] && _fail " !!! no new state set"
596 _change_state $new_state