3 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
5 # automatic qa system. 31/08/00 dxm@sgi.com
7 # Usage: auto_qa start-state [stop-state]
8 # Do auto_qa from start-state up to stop-state inclusive
9 # or if no stop-state given then do it until reach "done" state.
21 if [ "$started" = "1" ]
23 echo "auto-qa stopped" | wall
29 # send special email if a cron'd qa run fails
33 mail -s "XFS QA status report" $EMAIL < $LOG 2>&1
43 [ -x "$KWORKAREA" ] || return
44 [ -r "$KWORKAREA/Makefile" ] \
45 || _fail "can't read kernel makefile $KWORKAREA/Makefile"
48 BEGIN { FS = "[ \t=]+" }
50 /^PATCHLEVEL =/ { b=$2 }
51 /^SUBLEVEL =/ { c=$2 }
52 /^EXTRAVERSION =/ { d=$2 }
54 print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
56 ' < $KWORKAREA/Makefile`
59 # this should be constant
63 if [ ! -z "$CVSROOT" ]; then
64 export WORKAREA="$ROOT/xfs-cmds"
66 [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/xfs-cmds"
70 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
72 QADIR="$WORKAREA/xfstests"
74 CONFIG="$ROOT/$HOST.config"
75 COMMON_CONFIG="$QADIR/common.config"
79 # do some cleanup on exit
83 umount $SCRATCH_DEV &> /dev/null
84 umount $TEST_DEV &> /dev/null
87 echo "auto-qa stopped" | wall
92 trap "_cleanup; exit \$status" 0 1 2 3 15
117 # if have state XXXX-state then preserve XXXX-newstate
128 _set_state `echo $state | sed "s/-.*$/-$new/"`
140 $ROOT/su -c "$*" < /dev/null ;# HACK - we need a hacked su at the mo
145 exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
150 if [ -z "$CVSROOT" ]; then
151 _log " *** p_tupdate"
153 WORKAREA="$1" p_tupdate 2>&1 \
154 || _fail " !!! p_tupdate failed"
156 _log " *** non-trunk files"
158 WORKAREA="$1" p_list -c 2>&1 \
159 || _fail " !!! p_list failed"
161 _log " *** cvs update"
170 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
171 TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
172 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
173 TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
174 _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
176 if [ "$USE_BIG_LOOPFS" = yes ]; then
177 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
178 _sudo $QADIR/tools/ag-wipe -q -r $RETAIN_AG_BYTES $TEST_DEV
186 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
187 TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
188 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
189 TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
190 _sudo mount -t xfs $TEST_OPTIONS $MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
195 _sudo cp -f "$KWORKAREA/arch/i386/boot/bzImage" "$IMAGE" 2>&1 \
196 || _fail " !!! install kernel failed"
197 _sudo cp -f "$KWORKAREA/System.map" "$SYSTEMMAP" 2>&1 \
198 || _fail " !!! install kernel failed"
199 if [ -z "$KMODULES" -o "$KMODULES" = yes ]; then
200 _sudo make EXTRAVERSION=-$EXTRA modules_install 2>&1 \
201 || _fail " !!! install modules failed"
205 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
206 _log " *** reinit lilo"
207 _sudo /sbin/lilo 2>&1 \
208 || _fail " !!! reinit lilo failed"
214 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
215 _sudo /sbin/lilo -R $EXTRA $KERNEL_OPTIONS 2>&1 \
216 || _fail " !!! lilo failed"
222 echo not yet implemented
227 echo not yet implemented
232 [ -d "$KWORKAREA" ] || _fail " !!! QA kernel workarea \"$KWORKAREA\" not found"
233 [ -r "$CONFIG" ] || _fail " !!! Can't read config file $CONFIG"
237 _log "*** XFS QA (`date`)"
241 # check preconditions for starting state
250 _fail " !!! cron-init while not in \"*done\" state"
255 # we don't auto restart after reboot, but cron the restart
256 # to happen a bit later - it's much easier and safer that way
257 if [ "$state" != "cron-restarted" ]
259 _fail " !!! cron-restarted while not in \"cron-restarted\" state"
264 [ -n "$1" ] && _set_state $1
265 [ -n "$2" ] && stop_state=$2
267 [ "$UID" -eq 0 ] && _fail " !!! QA most be run as a normal user"
268 [ -d "$ROOT" ] || _fail " !!! QA root \"$ROOT\" not found"
269 [ -d "$WORKAREA" ] || _fail " !!! QA workarea \"$WORKAREA\" not found"
271 . "$COMMON_CONFIG" || _fail " !!! Couldn't source $COMMON_CONFIG"
274 IMAGE="$BOOT/vmlinuz-$EXTRA"
275 SYSTEMMAP="$BOOT/System.map-$VERSION-$EXTRA"
276 MODULES="/lib/modules/$SVERSION"
281 echo "auto-qa started" | wall
287 _log " *** state $state start (`date`)"
288 _log " (user=$USER, host=$HOST)"
296 echo "" > $ROOT/qa.log
297 echo "" > $ROOT/qa.full
298 _log "******************************************************"
299 _log "QA init $VERSION (`date`)"
300 _log "******************************************************"
301 new_state="updatetools"
305 _update_workarea "$WORKAREA"
306 new_state="cleantools"
310 # we need to configure or else we might fail to clean
311 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
313 [ -d $WORKAREA/$pkg ] || continue
315 _log " *** clean $pkg tools"
316 make realclean 2>&1 \
317 || _fail " !!! clean $pkg failed"
319 new_state="buildtools"
323 _log " *** build and install tools"
324 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
326 [ -d $WORKAREA/$pkg ] || continue
329 # use e-fence - but this will only take effect on configure
330 make configure 2>&1 \
331 || _fail " !!! configure $pkg failed"
333 || _fail " !!! build $pkg failed"
335 _sudo make install install-dev 2>&1 \
336 || _fail " !!! install $pkg failed"
338 # attr and acl now have install-lib targets as well
339 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
340 _sudo make install-lib 2>&1 \
341 || _fail " !!! install $pkg failed"
344 new_state="updatekernel"
349 _update_workarea "$KWORKAREA"
350 new_state="cleankernel"
355 _log " *** clean kernel"
358 || _fail " !!! clean kernel failed"
360 _log " *** install configuration file"
361 cp -f $CONFIG "$KWORKAREA/.config" 2>&1 \
362 || _fail " !!! failed to install config"
364 _log " *** remove version file"
365 rm -f include/linux/version.h 2>&1 \
366 || _fail " !!! failed to clean version"
373 _log " *** reconfig kernel"
375 # we better start from scratch if this fails
376 _change_state "cleankernel"
379 # we want to use default options for any new config options.
380 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
381 make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
382 || _fail " !!! reconfig oldconfig failed"
383 make EXTRAVERSION=-$EXTRA dep 2>&1 \
384 || _fail " !!! reconfig dep failed"
386 new_state="buildkernel"
391 _log " *** build kernel"
392 _log " --- kernel ($IMAGE)"
393 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
394 _log " --- modules ($MODULES)"
396 _change_state "cleankernel" ; # we better start from scratch if this fails
399 [ -z "$KTARGET" ] && KTARGET=bzImage
400 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
401 KTARGET="$KTARGET modules"
402 make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
403 || _fail " !!! build $KTARGET failed"
409 _log " *** blat old modules"
410 _sudo rm -rf $MODULES
412 _log " *** install kernel"
416 i386|i686) _i386_install ;;
417 ia64) _ia64_install ;;
424 _log " *** select qa kernel"
427 i386|i686) _i386_restart ;;
428 ia64) _ia64_restart ;;
431 _log " *** prepare to restart"
432 _change_state "restarted"
434 _log " *** restarting"
436 _restart # doesn't return
440 _log " *** QA reentered after restart"
447 _log " *** uname $uname"
449 if [ "$MODULAR" -eq 0 ]; then
457 _log " *** modules dependencies"
458 _sudo depmod -a 2>&1 \
459 || _fail " !!! failed to depmod -a"
461 _log " *** unmounting XFS mounts"
462 _sudo umount -a -t xfs 2>&1
464 _log " *** removing modules"
465 for m in xfsidbg xfs kdbm_pg kdbm_vm
467 _sudo rmmod $m 2> /dev/null
470 _log " *** installing modules"
471 _sudo modprobe xfs 2>&1 \
472 || _fail " !!! failed to modprobe xfs"
479 _log " *** unmounting TEST_DEV"
480 _sudo umount $TEST_DEV 2>&1
482 _log " *** unmounting SCRATCH_DEV"
483 _sudo umount $SCRATCH_DEV 2>&1
485 _log " *** clean TEST_DEV"
486 _test_mkfs_xfs 2>&1 \
487 || _fail " !!! failed to mkfs TEST_DEV"
489 _log " *** mounting TEST_DEV"
491 || _fail " !!! failed to mount"
499 _log " *** run soak test"
500 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
501 || _fail " !!! failed to run soak test"
509 # $BENCHMARK is typically unset, which equates to "all"
511 _log " *** run benchmarks"
512 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
513 || _fail " !!! failed to run benchmarks"
516 _log " *** send results mail"
517 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
525 _log " *** run tests ($CHECK_OPTIONS)"
526 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
529 _log " *** send status mail"
530 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
536 _log "*** requested QA state transitions complete"
543 _log " *** do nothing"
547 _fail " !!! unknown state $state"
551 _log " *** state $state done (`date`)"
552 [ "$new_state" = "" ] && _fail " !!! no new state set"
554 if [ -n "$stop_state" ]
556 # remove hyphen prefixes
557 s1=`echo $start_state | sed 's/.*-//'`
558 s2=`echo $stop_state | sed 's/.*-//'`
562 # we have been requested to stop here and not go on
567 _change_state $new_state