3 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms 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,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # automatic qa system. 31/08/00 dxm@sgi.com
21 # Usage: auto_qa start-state [stop-state]
22 # Do auto_qa from start-state up to stop-state inclusive
23 # or if no stop-state given then do it until reach "done" state.
35 if [ "$started" = "1" ]
37 echo "auto-qa stopped" | wall
43 # send special email if a cron'd qa run fails
47 mail -s "XFS QA status report" $EMAIL < $LOG 2>&1
57 [ -x "$KWORKAREA" ] || return
58 [ -r "$KWORKAREA/Makefile" ] \
59 || _fail "can't read kernel makefile $KWORKAREA/Makefile"
62 BEGIN { FS = "[ \t=]+" }
64 /^PATCHLEVEL =/ { b=$2 }
65 /^SUBLEVEL =/ { c=$2 }
66 /^EXTRAVERSION =/ { d=$2 }
68 print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
70 ' < $KWORKAREA/Makefile`
73 # this should be constant
77 if [ ! -z "$CVSROOT" ]; then
78 export WORKAREA="$ROOT/xfs-cmds"
80 [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/xfs-cmds"
84 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
86 QADIR="$WORKAREA/xfstests"
88 CONFIG="$ROOT/$HOST.config"
89 COMMON_CONFIG="$QADIR/common/config"
93 # do some cleanup on exit
97 umount $SCRATCH_DEV &> /dev/null
98 umount $TEST_DEV &> /dev/null
101 echo "auto-qa stopped" | wall
106 trap "_cleanup; exit \$status" 0 1 2 3 15
131 # if have state XXXX-state then preserve XXXX-newstate
142 _set_state `echo $state | sed "s/-.*$/-$new/"`
154 $ROOT/su -c "$*" < /dev/null ;# HACK - we need a hacked su at the mo
159 exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
164 if [ -z "$CVSROOT" ]; then
165 _log " *** p_tupdate"
167 WORKAREA="$1" p_tupdate 2>&1 \
168 || _fail " !!! p_tupdate failed"
170 _log " *** non-trunk files"
172 WORKAREA="$1" p_list -c 2>&1 \
173 || _fail " !!! p_list failed"
175 _log " *** cvs update"
184 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
185 TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
186 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
187 TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
188 _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
190 if [ "$USE_BIG_LOOPFS" = yes ]; then
191 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
192 _sudo $QADIR/tools/ag-wipe -q -r $RETAIN_AG_BYTES $TEST_DEV
200 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
201 TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
202 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
203 TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
204 _sudo mount -t xfs $TEST_OPTIONS $MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
209 _sudo cp -f "$KWORKAREA/arch/i386/boot/bzImage" "$IMAGE" 2>&1 \
210 || _fail " !!! install kernel failed"
211 _sudo cp -f "$KWORKAREA/System.map" "$SYSTEMMAP" 2>&1 \
212 || _fail " !!! install kernel failed"
213 if [ -z "$KMODULES" -o "$KMODULES" = yes ]; then
214 _sudo make EXTRAVERSION=-$EXTRA modules_install 2>&1 \
215 || _fail " !!! install modules failed"
219 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
220 _log " *** reinit lilo"
221 _sudo /sbin/lilo 2>&1 \
222 || _fail " !!! reinit lilo failed"
228 if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
229 _sudo /sbin/lilo -R $EXTRA $KERNEL_OPTIONS 2>&1 \
230 || _fail " !!! lilo failed"
236 echo not yet implemented
241 echo not yet implemented
246 [ -d "$KWORKAREA" ] || _fail " !!! QA kernel workarea \"$KWORKAREA\" not found"
247 [ -r "$CONFIG" ] || _fail " !!! Can't read config file $CONFIG"
251 _log "*** XFS QA (`date`)"
255 # check preconditions for starting state
264 _fail " !!! cron-init while not in \"*done\" state"
269 # we don't auto restart after reboot, but cron the restart
270 # to happen a bit later - it's much easier and safer that way
271 if [ "$state" != "cron-restarted" ]
273 _fail " !!! cron-restarted while not in \"cron-restarted\" state"
278 [ -n "$1" ] && _set_state $1
279 [ -n "$2" ] && stop_state=$2
281 [ "$UID" -eq 0 ] && _fail " !!! QA most be run as a normal user"
282 [ -d "$ROOT" ] || _fail " !!! QA root \"$ROOT\" not found"
283 [ -d "$WORKAREA" ] || _fail " !!! QA workarea \"$WORKAREA\" not found"
285 . "$COMMON_CONFIG" || _fail " !!! Couldn't source $COMMON_CONFIG"
288 IMAGE="$BOOT/vmlinuz-$EXTRA"
289 SYSTEMMAP="$BOOT/System.map-$VERSION-$EXTRA"
290 MODULES="/lib/modules/$SVERSION"
295 echo "auto-qa started" | wall
301 _log " *** state $state start (`date`)"
302 _log " (user=$USER, host=$HOST)"
310 echo "" > $ROOT/qa.log
311 echo "" > $ROOT/qa.full
312 _log "******************************************************"
313 _log "QA init $VERSION (`date`)"
314 _log "******************************************************"
315 new_state="updatetools"
319 _update_workarea "$WORKAREA"
320 new_state="cleantools"
324 # we need to configure or else we might fail to clean
325 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
327 [ -d $WORKAREA/$pkg ] || continue
329 _log " *** clean $pkg tools"
330 make realclean 2>&1 \
331 || _fail " !!! clean $pkg failed"
333 new_state="buildtools"
337 _log " *** build and install tools"
338 for pkg in attr acl xfsprogs dmapi xfsdump xfstests
340 [ -d $WORKAREA/$pkg ] || continue
343 make configure 2>&1 \
344 || _fail " !!! configure $pkg failed"
346 || _fail " !!! build $pkg failed"
348 _sudo make install install-dev 2>&1 \
349 || _fail " !!! install $pkg failed"
351 # attr and acl now have install-lib targets as well
352 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
353 _sudo make install-lib 2>&1 \
354 || _fail " !!! install $pkg failed"
357 new_state="updatekernel"
362 _update_workarea "$KWORKAREA"
363 new_state="cleankernel"
368 _log " *** clean kernel"
371 || _fail " !!! clean kernel failed"
373 _log " *** install configuration file"
374 cp -f $CONFIG "$KWORKAREA/.config" 2>&1 \
375 || _fail " !!! failed to install config"
377 _log " *** remove version file"
378 rm -f include/linux/version.h 2>&1 \
379 || _fail " !!! failed to clean version"
386 _log " *** reconfig kernel"
388 # we better start from scratch if this fails
389 _change_state "cleankernel"
392 # we want to use default options for any new config options.
393 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
394 make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
395 || _fail " !!! reconfig oldconfig failed"
396 make EXTRAVERSION=-$EXTRA dep 2>&1 \
397 || _fail " !!! reconfig dep failed"
399 new_state="buildkernel"
404 _log " *** build kernel"
405 _log " --- kernel ($IMAGE)"
406 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
407 _log " --- modules ($MODULES)"
409 _change_state "cleankernel" ; # we better start from scratch if this fails
412 [ -z "$KTARGET" ] && KTARGET=bzImage
413 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
414 KTARGET="$KTARGET modules"
415 make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
416 || _fail " !!! build $KTARGET failed"
422 _log " *** blat old modules"
423 _sudo rm -rf $MODULES
425 _log " *** install kernel"
429 i386|i686) _i386_install ;;
430 ia64) _ia64_install ;;
437 _log " *** select qa kernel"
440 i386|i686) _i386_restart ;;
441 ia64) _ia64_restart ;;
444 _log " *** prepare to restart"
445 _change_state "restarted"
447 _log " *** restarting"
449 _restart # doesn't return
453 _log " *** QA reentered after restart"
460 _log " *** uname $uname"
462 if [ "$MODULAR" -eq 0 ]; then
470 _log " *** modules dependencies"
471 _sudo depmod -a 2>&1 \
472 || _fail " !!! failed to depmod -a"
474 _log " *** unmounting XFS mounts"
475 _sudo umount -a -t xfs 2>&1
477 _log " *** removing modules"
478 for m in xfsidbg xfs kdbm_pg kdbm_vm
480 _sudo rmmod $m 2> /dev/null
483 _log " *** installing modules"
484 _sudo modprobe xfs 2>&1 \
485 || _fail " !!! failed to modprobe xfs"
492 _log " *** unmounting TEST_DEV"
493 _sudo umount $TEST_DEV 2>&1
495 _log " *** unmounting SCRATCH_DEV"
496 _sudo umount $SCRATCH_DEV 2>&1
498 _log " *** clean TEST_DEV"
499 _test_mkfs_xfs 2>&1 \
500 || _fail " !!! failed to mkfs TEST_DEV"
502 _log " *** mounting TEST_DEV"
504 || _fail " !!! failed to mount"
512 _log " *** run soak test"
513 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
514 || _fail " !!! failed to run soak test"
522 # $BENCHMARK is typically unset, which equates to "all"
524 _log " *** run benchmarks"
525 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
526 || _fail " !!! failed to run benchmarks"
529 _log " *** send results mail"
530 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
538 _log " *** run tests ($CHECK_OPTIONS)"
539 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
542 _log " *** send status mail"
543 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
549 _log "*** requested QA state transitions complete"
556 _log " *** do nothing"
560 _fail " !!! unknown state $state"
564 _log " *** state $state done (`date`)"
565 [ "$new_state" = "" ] && _fail " !!! no new state set"
567 if [ -n "$stop_state" ]
569 # remove hyphen prefixes
570 s1=`echo $start_state | sed 's/.*-//'`
571 s2=`echo $stop_state | sed 's/.*-//'`
575 # we have been requested to stop here and not go on
580 _change_state $new_state