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 # use e-fence - but this will only take effect on configure
344 make configure 2>&1 \
345 || _fail " !!! configure $pkg failed"
347 || _fail " !!! build $pkg failed"
349 _sudo make install install-dev 2>&1 \
350 || _fail " !!! install $pkg failed"
352 # attr and acl now have install-lib targets as well
353 [ "$pkg" = "attr" -o "$pkg" = "acl" ] || continue
354 _sudo make install-lib 2>&1 \
355 || _fail " !!! install $pkg failed"
358 new_state="updatekernel"
363 _update_workarea "$KWORKAREA"
364 new_state="cleankernel"
369 _log " *** clean kernel"
372 || _fail " !!! clean kernel failed"
374 _log " *** install configuration file"
375 cp -f $CONFIG "$KWORKAREA/.config" 2>&1 \
376 || _fail " !!! failed to install config"
378 _log " *** remove version file"
379 rm -f include/linux/version.h 2>&1 \
380 || _fail " !!! failed to clean version"
387 _log " *** reconfig kernel"
389 # we better start from scratch if this fails
390 _change_state "cleankernel"
393 # we want to use default options for any new config options.
394 echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
395 make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
396 || _fail " !!! reconfig oldconfig failed"
397 make EXTRAVERSION=-$EXTRA dep 2>&1 \
398 || _fail " !!! reconfig dep failed"
400 new_state="buildkernel"
405 _log " *** build kernel"
406 _log " --- kernel ($IMAGE)"
407 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
408 _log " --- modules ($MODULES)"
410 _change_state "cleankernel" ; # we better start from scratch if this fails
413 [ -z "$KTARGET" ] && KTARGET=bzImage
414 [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
415 KTARGET="$KTARGET modules"
416 make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
417 || _fail " !!! build $KTARGET failed"
423 _log " *** blat old modules"
424 _sudo rm -rf $MODULES
426 _log " *** install kernel"
430 i386|i686) _i386_install ;;
431 ia64) _ia64_install ;;
438 _log " *** select qa kernel"
441 i386|i686) _i386_restart ;;
442 ia64) _ia64_restart ;;
445 _log " *** prepare to restart"
446 _change_state "restarted"
448 _log " *** restarting"
450 _restart # doesn't return
454 _log " *** QA reentered after restart"
461 _log " *** uname $uname"
463 if [ "$MODULAR" -eq 0 ]; then
471 _log " *** modules dependencies"
472 _sudo depmod -a 2>&1 \
473 || _fail " !!! failed to depmod -a"
475 _log " *** unmounting XFS mounts"
476 _sudo umount -a -t xfs 2>&1
478 _log " *** removing modules"
479 for m in xfsidbg xfs kdbm_pg kdbm_vm
481 _sudo rmmod $m 2> /dev/null
484 _log " *** installing modules"
485 _sudo modprobe xfs 2>&1 \
486 || _fail " !!! failed to modprobe xfs"
493 _log " *** unmounting TEST_DEV"
494 _sudo umount $TEST_DEV 2>&1
496 _log " *** unmounting SCRATCH_DEV"
497 _sudo umount $SCRATCH_DEV 2>&1
499 _log " *** clean TEST_DEV"
500 _test_mkfs_xfs 2>&1 \
501 || _fail " !!! failed to mkfs TEST_DEV"
503 _log " *** mounting TEST_DEV"
505 || _fail " !!! failed to mount"
513 _log " *** run soak test"
514 _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC \
515 || _fail " !!! failed to run soak test"
523 # $BENCHMARK is typically unset, which equates to "all"
525 _log " *** run benchmarks"
526 _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
527 || _fail " !!! failed to run benchmarks"
530 _log " *** send results mail"
531 mail -s "XFS QA benchmark results" $EMAIL < $QADIR/bench.out 2>&1
539 _log " *** run tests ($CHECK_OPTIONS)"
540 _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
543 _log " *** send status mail"
544 mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
550 _log "*** requested QA state transitions complete"
557 _log " *** do nothing"
561 _fail " !!! unknown state $state"
565 _log " *** state $state done (`date`)"
566 [ "$new_state" = "" ] && _fail " !!! no new state set"
568 if [ -n "$stop_state" ]
570 # remove hyphen prefixes
571 s1=`echo $start_state | sed 's/.*-//'`
572 s2=`echo $stop_state | sed 's/.*-//'`
576 # we have been requested to stop here and not go on
581 _change_state $new_state