1 #initial attempt at an automation script: ltprun 2 # 3/12/02 William Jay Huie (creation) 3 # 3/28/02 William Jay Huie minor updates 4 #this will be kicked off by ltp_master from the master control machine which 5 #uploads this script and then telnets into each machine and kick this script off 6 #perhaps by passing a uniq ID to name the LTP_OUTPUT_TAR file by, or 7 #allowing the script to create a unique name itself (reccommended for now) 8 #Check ltp_master for details 9 #FIXME: One problem is that the tests need to be run as root and this script 10 # doesn't as of yet su 11 # 12 #CHANGEME: 13 LTP_HOST=ltp_host.somewhere.org 14 #This is the user to get the ltp.tgz file from, not who we're running as, 15 # that's ocntrolled by ltp_master 16 LTP_USER=ltp 17 LTP_PASS=ltp 18 LTP_TARFILE=ltp.tgz 19 LTP_RUNALL_OUT=runall.output 20 LTP_LOGFILE=ltp-logfile 21 LTP_RUN_OUTPUT=ltprun.out 22 SAR_OUTFILE=sar.data 23 24 #This script passes the -l ~/ltp/ltp-logfile option to runalltests.sh 25 26 if [ -z $1 ]; then 27 SHORT_HOSTNAME=`hostname | perl -e 'while(<>){ m/(\w+)[.\\$]?/ && print $1;}'` 28 TIMESTAMP=`date +%s` 29 LTP_OUTPUT_TAR="$SHORT_HOSTNAME-$TIMESTAMP-ltpoutput.tgz" 30 else 31 LTP_OUTPUT_TAR=$1 32 fi 33 34 download_ltp() 35 { 36 echo "Attempting to download the LTP testcases"; 37 cd ~ 38 rm -Rf ltp $LTP_TARFILE 39 ftp -n $LTP_HOST << END_GET 40 user $LTP_USER $LTP_PASS 41 bin 42 get $LTP_TARFILE 43 bye 44 END_GET 45 46 if [ -s $LTP_TARFILE ]; then 47 echo " downloaded sucessfully"; 48 else 49 echo "FAILED download of LTP Testcases"; return 0; 50 fi 51 return 1; 52 } 53 54 untar_ltp() 55 { 56 echo "Untarring $LTP_TARFILE now"; 57 cd ~ 58 tar -zxf $LTP_TARFILE &> /dev/null 59 if [ $? != "0" ]; then 60 echo "Problems untarring the archive"; return 0; 61 else 62 echo " successfully untarred $LTP_TARFILE"; 63 fi 64 return 1; 65 } 66 67 build_ltp() 68 { 69 cd ~/ltp 70 echo "Building LTP Testsuite version: `cat VERSION`"; 71 make clean install &> /dev/null 72 if [ $? != "0" ]; then 73 echo "FAILED LTP Testsuite compilation"; return 0; 74 else 75 echo " LTP Testsuite compilation successful" 76 fi 77 return 1; 78 } 79 80 run_ltp() 81 { 82 cd ~/ltp 83 rm -f $LTP_RUNALL_OUT $LTP_LOGFILE $SAR_OUTFILE 84 echo "Trying to start sar" 85 sar -o $SAR_OUTFILE 60 0 & 86 echo "Running LTP testsuite" 87 ./runalltests.sh -l ~/ltp/$LTP_LOGFILE &> $LTP_RUNALL_OUT 88 echo "Done running tests" 89 killall -9 sadc 90 echo "Killing sar if it is running" 91 return 1; 92 } 93 94 #FIXME: 95 #collect results has a hack to copy the &>ltprun file into the ~/ltp dir then 96 #tar it up with everything else, but this seems to work so far. 97 collect_results() 98 { 99 echo "Collecting LTP output" 100 cd ~/ltp 101 cp ~/$LTP_RUN_OUTPUT . 102 tar --ignore-failed-read -czf ~/$LTP_OUTPUT_TAR $LTP_RUNALL_OUT $LTP_LOGFILE $LTP_RUN_OUTPUT $SAR_OUTFILE 103 104 if [ -s ~/$LTP_OUTPUT_TAR ]; then 105 echo "LTP output tarfile created sucessfully"; 106 else 107 echo "FAILED tar of LTP results"; return 0; 108 fi 109 return 1; 110 } 111 112 upload_results() 113 { 114 echo "Uploading LTP output" 115 cd ~ 116 ftp -n $LTP_HOST << END_PUT 117 user $LTP_USER $LTP_PASS 118 bin 119 put $LTP_OUTPUT_TAR 120 bye 121 END_PUT 122 #FIXME! Right now don't have a way to verify the upload worked, but 123 #we'd like to know so we can delete the OUTPUT_TAR file 124 # rm -f $LTP_OUTPUT_TAR 125 rm -f $LTP_TARFILE 126 } 127 128 #Start the work! 129 130 download_ltp 131 if [ $? = 1 ]; then 132 untar_ltp 133 if [ $? = 1 ]; then 134 build_ltp 135 if [ $? = 1 ]; then 136 run_ltp 137 fi 138 fi 139 fi 140 141 #Want to upload results even if things didn't run 142 collect_results 143 upload_results 144 145 echo "Done" 146