ia64/xen-unstable

changeset 7761:bdb8c00ddb85

merge
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 10 12:05:22 2005 +0100 (2005-11-10)
parents 74737286e9f5 a8b759a40372
children e436e4e93076
files
line diff
     1.1 --- a/tools/xm-test/lib/XmTestLib/Console.py	Thu Nov 10 12:04:29 2005 +0100
     1.2 +++ b/tools/xm-test/lib/XmTestLib/Console.py	Thu Nov 10 12:05:22 2005 +0100
     1.3 @@ -23,13 +23,13 @@
     1.4       a _very_ specific value, set in the PROMPT
     1.5       variable of this script
     1.6  """
     1.7 -import sys;
     1.8 -import os;
     1.9 -import pty;
    1.10 -import tty;
    1.11 -import termios;
    1.12 -import fcntl;
    1.13 -import select;
    1.14 +import sys
    1.15 +import os
    1.16 +import pty
    1.17 +import tty
    1.18 +import termios
    1.19 +import fcntl
    1.20 +import select
    1.21  
    1.22  from Test import *
    1.23  
    1.24 @@ -52,15 +52,15 @@ class XmConsole:
    1.25                              are included in the history buffer
    1.26          """
    1.27  
    1.28 -        self.TIMEOUT          = 30;
    1.29 -        self.PROMPT           = "@%@%> ";
    1.30 -        self.domain           = domain;
    1.31 -        self.historyBuffer    = [];
    1.32 -        self.historyLines     = 0;
    1.33 -        self.historyLimit     = historyLimit;
    1.34 -        self.historySaveAll   = historySaveAll;
    1.35 -        self.historySaveCmds  = historySaveCmds;
    1.36 -        self.debugMe          = False;
    1.37 +        self.TIMEOUT          = 30
    1.38 +        self.PROMPT           = "@%@%> "
    1.39 +        self.domain           = domain
    1.40 +        self.historyBuffer    = []
    1.41 +        self.historyLines     = 0
    1.42 +        self.historyLimit     = historyLimit
    1.43 +        self.historySaveAll   = historySaveAll
    1.44 +        self.historySaveCmds  = historySaveCmds
    1.45 +        self.debugMe          = False
    1.46          self.limit            = None
    1.47  
    1.48          consoleCmd = ["/usr/sbin/xm", "xm", "console", domain]
    1.49 @@ -68,62 +68,62 @@ class XmConsole:
    1.50          if verbose:
    1.51              print "Console executing: " + str(consoleCmd)
    1.52  
    1.53 -        pid, fd = pty.fork();
    1.54 +        pid, fd = pty.fork()
    1.55  
    1.56          if pid == 0:
    1.57 -            os.execvp("/usr/sbin/xm", consoleCmd[1:]);
    1.58 +            os.execvp("/usr/sbin/xm", consoleCmd[1:])
    1.59  
    1.60 -        self.consolePid = pid;
    1.61 -        self.consoleFd  = fd;
    1.62 +        self.consolePid = pid
    1.63 +        self.consoleFd  = fd
    1.64  
    1.65 -        tty.setraw(self.consoleFd, termios.TCSANOW);
    1.66 +        tty.setraw(self.consoleFd, termios.TCSANOW)
    1.67              
    1.68          bytes = self.__chewall(self.consoleFd)
    1.69          if bytes < 0:
    1.70              raise ConsoleError("Console didn't respond")
    1.71  
    1.72      def __addToHistory(self, line):
    1.73 -        self.historyBuffer.append(line);
    1.74 -        self.historyLines += 1;
    1.75 +        self.historyBuffer.append(line)
    1.76 +        self.historyLines += 1
    1.77          if self.historyLines > self.historyLimit:
    1.78 -            self.historyBuffer = self.historyBuffer[1:];
    1.79 -            self.historyLines -= 1;
    1.80 +            self.historyBuffer = self.historyBuffer[1:]
    1.81 +            self.historyLines -= 1
    1.82  
    1.83  
    1.84      def clearHistory(self):
    1.85          """Clear the history buffer"""
    1.86 -        self.historyBuffer = [];
    1.87 -        self.historyLines = 0;
    1.88 +        self.historyBuffer = []
    1.89 +        self.historyLines = 0
    1.90  
    1.91  
    1.92      def getHistory(self):
    1.93          """Returns a string containing the entire history buffer"""
    1.94 -        output = "";
    1.95 +        output = ""
    1.96  
    1.97          for line in self.historyBuffer:
    1.98 -            output += line + "\n";
    1.99 +            output += line + "\n"
   1.100  
   1.101 -        return output;
   1.102 +        return output
   1.103  
   1.104  
   1.105      def setTimeout(self, timeout):
   1.106          """Sets the timeout used to determine if a remote command
   1.107          has blocked"""
   1.108 -        self.TIMEOUT = timeout;
   1.109 +        self.TIMEOUT = timeout
   1.110  
   1.111  
   1.112      def setPrompt(self, prompt):
   1.113          """Sets the string key used to delimit the end of command
   1.114          output"""
   1.115 -        self.PROMPT = prompt;
   1.116 +        self.PROMPT = prompt
   1.117  
   1.118  
   1.119      def __chewall(self, fd):
   1.120 -        timeout = 0;
   1.121 -        bytes   = 0;
   1.122 +        timeout = 0
   1.123 +        bytes   = 0
   1.124          
   1.125          while timeout < 3:
   1.126 -            i, o, e = select.select([fd], [], [], 1);
   1.127 +            i, o, e = select.select([fd], [], [], 1)
   1.128              if fd in i:
   1.129                  try:
   1.130                      foo = os.read(fd, 1)
   1.131 @@ -143,7 +143,7 @@ class XmConsole:
   1.132          if self.debugMe:
   1.133              print "Ignored %i bytes of miscellaneous console output" % bytes
   1.134          
   1.135 -        return bytes;
   1.136 +        return bytes
   1.137  
   1.138  
   1.139      def __runCmd(self, command, saveHistory=True):
   1.140 @@ -152,15 +152,15 @@ class XmConsole:
   1.141          lines  = 0
   1.142          bytes  = 0
   1.143  
   1.144 -        self.__chewall(self.consoleFd);
   1.145 +        self.__chewall(self.consoleFd)
   1.146  
   1.147          if verbose:
   1.148              print "[%s] Sending `%s'" % (self.domain, command)
   1.149  
   1.150 -        os.write(self.consoleFd, "%s\n" % command);
   1.151 +        os.write(self.consoleFd, "%s\n" % command)
   1.152  
   1.153          while 1==1:
   1.154 -            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT);
   1.155 +            i, o, e = select.select([self.consoleFd], [], [], self.TIMEOUT)
   1.156  
   1.157              if self.consoleFd in i:
   1.158                  try:
   1.159 @@ -182,59 +182,59 @@ class XmConsole:
   1.160                  if lines > 0:
   1.161                      output += line + "\n"
   1.162                      if saveHistory:
   1.163 -                        self.__addToHistory(line);
   1.164 +                        self.__addToHistory(line)
   1.165                  elif self.historySaveCmds and saveHistory:
   1.166 -                    self.__addToHistory("*" + line);
   1.167 -                lines += 1;
   1.168 -                line = "";
   1.169 +                    self.__addToHistory("*" + line)
   1.170 +                lines += 1
   1.171 +                line = ""
   1.172              elif str == "\r":
   1.173                  pass # ignore \r's
   1.174              else:
   1.175 -                line += str;
   1.176 +                line += str
   1.177  
   1.178              if line == self.PROMPT:
   1.179 -                break;
   1.180 +                break
   1.181  
   1.182 -        return output;
   1.183 +        return output
   1.184  
   1.185  
   1.186      def runCmd(self, command):
   1.187          """Runs a command on the remote terminal and returns the output
   1.188          as well as the return code.  For example:
   1.189          
   1.190 -        ret = c.runCmd("ls");
   1.191 -        print ret["output"];
   1.192 -        sys.exit(run["return"]);
   1.193 +        ret = c.runCmd("ls")
   1.194 +        print ret["output"]
   1.195 +        sys.exit(run["return"])
   1.196          
   1.197          """
   1.198  
   1.199          # Allow exceptions to bubble up
   1.200 -        realOutput = self.__runCmd(command);
   1.201 -        retOutput  = self.__runCmd("echo $?", saveHistory=False);
   1.202 +        realOutput = self.__runCmd(command)
   1.203 +        retOutput  = self.__runCmd("echo $?", saveHistory=False)
   1.204  
   1.205          try:
   1.206 -            retCode =  int(retOutput);
   1.207 +            retCode =  int(retOutput)
   1.208          except:
   1.209 -            retCode = 255;
   1.210 +            retCode = 255
   1.211          return {
   1.212              "output": realOutput,
   1.213              "return": retCode,
   1.214 -            };
   1.215 +            }
   1.216  
   1.217      def sendInput(self, input):
   1.218          """Sends input to the remote terminal, but doesn't check
   1.219          for a return code"""
   1.220 -        realOutput = self.__runCmd(input);
   1.221 +        realOutput = self.__runCmd(input)
   1.222          return {
   1.223              "output": realOutput,
   1.224              "return": 0,
   1.225 -            };
   1.226 +            }
   1.227  
   1.228      def closeConsole(self):
   1.229          """Closes the console connection and ensures that the console
   1.230          process is killed"""
   1.231 -        os.close(self.consoleFd);
   1.232 -        os.kill(self.consolePid, 2);
   1.233 +        os.close(self.consoleFd)
   1.234 +        os.kill(self.consolePid, 2)
   1.235  
   1.236  
   1.237      def setLimit(self, limit):
   1.238 @@ -254,23 +254,23 @@ if __name__ == "__main__":
   1.239      code as the domU command.
   1.240      """
   1.241  
   1.242 -    verbose = True;
   1.243 +    verbose = True
   1.244      
   1.245      try:
   1.246 -        t = XmConsole(sys.argv[1]);
   1.247 +        t = XmConsole(sys.argv[1])
   1.248      except ConsoleError, e:
   1.249          print "Failed to attach to console (%s)" % str(e)
   1.250          sys.exit(255)
   1.251  
   1.252      try:
   1.253 -        run = t.runCmd(sys.argv[2]);
   1.254 +        run = t.runCmd(sys.argv[2])
   1.255      except ConsoleError, e:
   1.256          print "Console failed (%)" % str(e)
   1.257          sys.exit(255)
   1.258          
   1.259 -    t.closeConsole();
   1.260 +    t.closeConsole()
   1.261      
   1.262 -    print run["output"],;
   1.263 -    sys.exit(run["return"]);
   1.264 +    print run["output"],
   1.265 +    sys.exit(run["return"])
   1.266      
   1.267          
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/xm-test/mergereport	Thu Nov 10 12:05:22 2005 +0100
     2.3 @@ -0,0 +1,25 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +# Dan Smith <danms@us.ibm.com> - 16-Sep-2005
     2.7 +#
     2.8 +# This script takes all the .report files in the current
     2.9 +# directory and generates a summary table, showing the 
    2.10 +# number of PASS, FAIL, XPASS, and XFAIL tests in each 
    2.11 +# report
    2.12 +
    2.13 +
    2.14 +echo "            Platform | PASS | FAIL | XPASS | XFAIL |"
    2.15 +echo "---------------------+------+------+-------+-------+"
    2.16 +
    2.17 +for r in *.report; do
    2.18 +    
    2.19 +    mach=$(basename $r .report)
    2.20 +    pass=$(cat $r | grep '  PASS' | cut -d : -f 2 | sed 's/  *//')
    2.21 +    fail=$(cat $r | grep '  FAIL' | cut -d : -f 2 | sed 's/  *//')
    2.22 +    xpas=$(cat $r | grep ' XPASS' | cut -d : -f 2 | sed 's/  *//')
    2.23 +    xfal=$(cat $r | grep ' XFAIL' | cut -d : -f 2 | sed 's/  *//')
    2.24 +
    2.25 +    printf "%20s | %4s | %4s | %5s | %5s |\n" "$mach" "$pass" \
    2.26 +           "$fail" "$xpas" "$xfal"
    2.27 +
    2.28 +done
     3.1 --- a/tools/xm-test/runtest.sh	Thu Nov 10 12:04:29 2005 +0100
     3.2 +++ b/tools/xm-test/runtest.sh	Thu Nov 10 12:05:22 2005 +0100
     3.3 @@ -1,215 +1,259 @@
     3.4  #!/bin/sh
     3.5  
     3.6 -usage() {
     3.7 -    echo "Usage: $0 [opts] <logfile>"
     3.8 -    echo "  Where opts are:"
     3.9 -    echo "  -d         : do not submit a report for this run"
    3.10 -    echo "  -b         : do not ask any questions (batch mode)"
    3.11 -    echo "  -e <email> : set email address for report"
    3.12 -}
    3.13  ##
    3.14  ## Test driver script
    3.15  ##
    3.16  
    3.17 -#
    3.18 -# Defaults
    3.19 -#
    3.20 -MAXFAIL=10
    3.21 -report=yes
    3.22 -batch=no
    3.23 +usage() {
    3.24 +    echo "Usage: $0 [opts] <report>"
    3.25 +    echo "  Where report is a name that will be used for report files"
    3.26 +    echo ""
    3.27 +    echo "  Where opts are:"
    3.28 +    echo "  -d          : do not submit a report for this run"
    3.29 +    echo "  -b          : do not ask any questions (batch mode)"
    3.30 +    echo "  -q          : run a quick test set"
    3.31 +    echo "  -e <email>  : set email address for report"
    3.32 +    echo "  -s <report> : just submit report <report>"
    3.33 +}
    3.34 +
    3.35 +# Just submit the report
    3.36 +submit_report() {
    3.37  
    3.38 -#
    3.39 -# Resolve options
    3.40 -#
    3.41 -while [ $# -gt 0 ]
    3.42 -do
    3.43 -    case "$1" in
    3.44 -    -d)
    3.45 -        echo "(Skipping report submission)"
    3.46 -        report=no
    3.47 -        ;;
    3.48 -    -b)
    3.49 -        echo "(Batch mode)"
    3.50 -        batch=yes
    3.51 -        ;;
    3.52 -    -e)
    3.53 -        shift
    3.54 -        echo $1 > contact_info
    3.55 -        echo "(Email set to $1)"
    3.56 -        ;;
    3.57 -    *)
    3.58 -        LOGFILE=$1
    3.59 -        break
    3.60 -        ;;
    3.61 -    esac
    3.62 -    shift
    3.63 -done
    3.64 +    reportfile=$1
    3.65 +
    3.66 +    ./lib/XmTestReport/Report.py $reportfile
    3.67 +}
    3.68 +
    3.69 +# Generate XML result report from output file
    3.70 +make_result_report() {
    3.71 +    output=$1
    3.72 +    reportfile=$2
    3.73 +    if ! ./lib/XmTestReport/ResultReport.py $output > $reportfile; then
    3.74 +	echo "Unable to generate clean ResultReport"
    3.75 +	echo "Take a look at $report"
    3.76 +	exit 1
    3.77 +    fi
    3.78 +}
    3.79  
    3.80 -#
    3.81 -# Usage
    3.82 -#
    3.83 -if [ -z $LOGFILE ]; then
    3.84 -	usage
    3.85 +# Collect environment information for XML report
    3.86 +make_environment_report() {
    3.87 +    os=$1
    3.88 +    prog=$2
    3.89 +    if ! ./lib/XmTestReport/OSReport.py > $os; then
    3.90 +	echo "Unable to generate clean OSReport"
    3.91 +	echo "Take a look at $os"
    3.92  	exit 1
    3.93 -fi
    3.94 +    fi
    3.95 +    if ! ./lib/XmTestReport/ProgReport.py > $prog; then
    3.96 +	echo "Unable to generate clean ProgReport"
    3.97 +	echo "Take a look at $prog"
    3.98 +	exit 1
    3.99 +    fi
   3.100 +}
   3.101  
   3.102 -#
   3.103 -# Output files
   3.104 -#
   3.105 -OSREPORTTEMP=${LOGFILE}.os.xml
   3.106 -PROGREPORTTEMP=${LOGFILE}.prog.xml
   3.107 -RESULTREPORTTEMP=${LOGFILE}.result.xml
   3.108 -OUTPUT=${LOGFILE}.output
   3.109 -SUMMARY=${LOGFILE}.summary
   3.110 -PASSFAIL=${LOGFILE}.passfail
   3.111 -REPORT=${LOGFILE}.report
   3.112 -FAILURES=${LOGFILE}.failures
   3.113 -		
   3.114 -#
   3.115 -# Make sure we're root
   3.116 -#
   3.117 -uid=$(id -u)
   3.118 -if [ $uid != 0 ]; then 
   3.119 -    echo "ERROR: I must be run as root!"
   3.120 -    exit 1
   3.121 -fi
   3.122 +# Check conditions needed to actually run the tests
   3.123 +runnable_tests() {	
   3.124 +    # Make sure we're root
   3.125 +    uid=$(id -u)
   3.126 +    if [ $uid != 0 ]; then 
   3.127 +	echo "ERROR: I must be run as root!"
   3.128 +	exit 1
   3.129 +    fi
   3.130  
   3.131 -#
   3.132 -# See if the ramdisk has been built
   3.133 -#
   3.134 -rdsize=$(stat -c %s ramdisk/initrd.img 2>/dev/null)
   3.135 -if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
   3.136 -    echo "Cannot find a valid ramdisk.  You need to run \"make\" or"
   3.137 -    echo "copy in a previously-built ramdisk to the ramdisk/ directory"
   3.138 -    exit 1
   3.139 -fi
   3.140 +    # See if the ramdisk has been built
   3.141 +    rdsize=$(stat -c %s ramdisk/initrd.img 2>/dev/null)
   3.142 +    if [ -z "$rdsize" ] || [ $rdsize -le 16384 ]; then
   3.143 +	echo "Cannot find a valid ramdisk.  You need to run \"make\" or"
   3.144 +	echo "copy in a previously-built ramdisk to the ramdisk/ directory"
   3.145 +	exit 1
   3.146 +    fi
   3.147 +
   3.148 +    # See if xend is running
   3.149 +    if ! xm list >/dev/null 2>&1; then
   3.150 +	echo "'xm list' failed: is xend running?"
   3.151 +	exit 1
   3.152 +    fi
   3.153 +    
   3.154 +}
   3.155  
   3.156 -#
   3.157 -# See if xend is running
   3.158 -#
   3.159 -if ! xm list >/dev/null 2>&1; then
   3.160 -    echo "'xm list' failed: is xend running?"
   3.161 -    exit 1
   3.162 -fi
   3.163 +# Get contact info if needed
   3.164 +get_contact_info() {
   3.165 +    
   3.166 +    if [ ! -f contact_info ]; then
   3.167 +	if [ "$batch" = "yes" ]; then
   3.168 +	    echo "Unable to read contact_info!"
   3.169 +	    echo "Please run me once interactively before using batch mode!"
   3.170 +	    exit 1
   3.171 +	else
   3.172 +	    echo "Please provide your email address so that we can "
   3.173 +	    echo "contact you if we need further information concerning"
   3.174 +	    echo "your results.  Any information provided will be"
   3.175 +	    echo "kept private.  If you wish to remain anonymous, please"
   3.176 +	    echo "hit [ENTER] now."
   3.177 +	    
   3.178 +	    while ! echo "$EMAIL" | grep -q '@'; do
   3.179 +		echo
   3.180 +		echo -n "Your email address: "
   3.181 +		read EMAIL
   3.182 +		if [ -z $EMAIL ]; then
   3.183 +		    EMAIL="anonymous@somewhere.com"
   3.184 +		fi
   3.185 +	    done
   3.186 +	    echo $EMAIL > contact_info
   3.187 +	fi
   3.188 +    fi
   3.189 +}
   3.190  
   3.191 -#
   3.192 -#  Make sure permissions are correct
   3.193 -#
   3.194 -chmod a+x lib/XmTestReport/*
   3.195 -chmod a+x mkreport mergereport
   3.196 +# Run the tests
   3.197 +run_tests() {
   3.198 +    output=$1
   3.199 +    echo Running tests...
   3.200 +    TEST_VERBOSE=1 make -k check > $output 2>&1
   3.201 +}
   3.202  
   3.203 -#
   3.204 -# Get contact info if needed
   3.205 -#
   3.206 -if [ ! -f contact_info ]; then
   3.207 -    if [ "$batch" = "yes" ]; then
   3.208 -	echo "Unable to read contact_info!"
   3.209 -	echo "Please run me once interactively before using batch mode!"
   3.210 -	exit 1
   3.211 -    else
   3.212 -	echo "Please provide your email address so that we can "
   3.213 -	echo "contact you if we need further information concerning"
   3.214 -	echo "your results.  Any information provided will be"
   3.215 -	echo "kept private.  If you wish to remain anonymous, please"
   3.216 -	echo "hit [ENTER] now."
   3.217 -	
   3.218 -	while ! echo "$EMAIL" | grep -q '@'; do
   3.219 -	    echo
   3.220 -	    echo -n "Your email address: "
   3.221 -	    read EMAIL
   3.222 -	    if [ -z $EMAIL ]; then
   3.223 -		EMAIL="anonymous@somewhere.com"
   3.224 -	    fi
   3.225 -	done
   3.226 -	echo $EMAIL > contact_info
   3.227 -    fi
   3.228 -fi
   3.229 +run_tests_quick() {
   3.230 +
   3.231 +    output=$1
   3.232 +
   3.233 +    create_tests="01_create_basic_pos.test 07_create_mem64_pos.test 10_create_fastdestroy.test 14_create_blockroot_pos.test"
   3.234 +    unpause_tests="01_unpause_basic_pos.test"
   3.235 +    memset_tests="01_memset_basic_pos.test 03_memset_random_pos.test"
   3.236 +    help_tests="06_help_allcmds.test"
   3.237 +    testgroups="create unpause memset help"
   3.238 +
   3.239 +    echo "*** Quick test" > $output
   3.240 +    for group in $testgroups; do
   3.241 +	eval $(echo list=\$${group}_tests)
   3.242 +	echo "*** Running tests [$list] from $group"
   3.243 +	(cd tests/$group && TEST_VERBOSE=1 make -k check TESTS="$list") >> $output 2>&1
   3.244 +    done
   3.245 +
   3.246 +}
   3.247  
   3.248 -#
   3.249 -# Collect environment information for XML report
   3.250 -#
   3.251 -if ! ./lib/XmTestReport/OSReport.py > $OSREPORTTEMP; then
   3.252 -    echo "Unable to generate clean OSReport"
   3.253 -    echo "Take a look at $OSREPORTTEMP"
   3.254 -    exit 1
   3.255 -fi
   3.256 -if ! ./lib/XmTestReport/ProgReport.py > $PROGREPORTTEMP; then
   3.257 -    echo "Unable to generate clean ProgReport"
   3.258 -    echo "Take a look at $PROGREPORTTEMP"
   3.259 -    exit 1
   3.260 -fi
   3.261 -
   3.262 -#
   3.263 -# Run the tests
   3.264 -#
   3.265 -export TEST_VERBOSE=1
   3.266 -echo Running tests...
   3.267 -make -k check > $OUTPUT 2>&1
   3.268 -
   3.269 -#
   3.270  # Generate some plain-text reports
   3.271 -#
   3.272 -echo "Making PASS/FAIL report ($PASSFAIL)..."
   3.273 -cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $PASSFAIL
   3.274 -
   3.275 -echo "Making FAIL report ($FAILURES)..."
   3.276 -cat $PASSFAIL | egrep '(REASON|FAIL)' > $FAILURES
   3.277 -
   3.278 -NUMPASS=`grep -c PASS $OUTPUT`
   3.279 -NUMFAIL=`grep -c FAIL $OUTPUT`
   3.280 -NUMXPASS=`grep -c XPASS $OUTPUT`
   3.281 -NUMXFAIL=`grep -c XFAIL $OUTPUT`
   3.282 -cat > $SUMMARY << EOF
   3.283 +make_text_reports() {
   3.284 +    passfail=$1
   3.285 +    failures=$2
   3.286 +    output=$3
   3.287 +    reportfile=$4
   3.288 +    summary=summary.tmp
   3.289 +    echo "Making PASS/FAIL report ($passfail)..."
   3.290 +    cat $OUTPUT | egrep '(REASON|PASS|FAIL|XPASS|XFAIL|SKIP)' | perl -pe 's/^(PASS|FAIL|XPASS|XFAIL)(.+)$/$1$2\n/' > $passfail
   3.291 +    
   3.292 +    echo "Making FAIL report ($failures)..."
   3.293 +    cat $passfail | egrep '(REASON|FAIL)' > $failures
   3.294 +    
   3.295 +    NUMPASS=`grep -c PASS $output`
   3.296 +    NUMFAIL=`grep -c FAIL $output`
   3.297 +    NUMXPASS=`grep -c XPASS $output`
   3.298 +    NUMXFAIL=`grep -c XFAIL $output`
   3.299 +    cat > $summary << EOF
   3.300  Xm-test execution summary:
   3.301    PASS:  $NUMPASS
   3.302    FAIL:  $NUMFAIL
   3.303    XPASS: $NUMXPASS
   3.304    XFAIL: $NUMXFAIL
   3.305  EOF
   3.306 +    
   3.307 +    cat $summary > $reportfile
   3.308 +    
   3.309 +    echo -e '\n\nDetails:\n' >> $reportfile
   3.310 +    
   3.311 +    ./mkreport $passfail >> $reportfile
   3.312  
   3.313 -cat $SUMMARY > $REPORT
   3.314 +    rm $summary
   3.315 +}
   3.316  
   3.317 -echo -e '\n\nDetails:\n' >> $REPORT
   3.318 - 
   3.319 -./mkreport $PASSFAIL >> $REPORT
   3.320 +############
   3.321 +### Main ###
   3.322 +############
   3.323 +
   3.324 +# Defaults
   3.325 +MAXFAIL=10
   3.326 +report=yes
   3.327 +batch=no
   3.328 +run=yes
   3.329  
   3.330 -#
   3.331 -# Check to see if it's worth reporting these results
   3.332 -#
   3.333 -#if  [ "$batch"  =   "no" ] && 
   3.334 -#    [ "$report" =   "yes" ] && 
   3.335 -#    [ $NUMFAIL  -gt $MAXFAIL ]; then
   3.336 -#    echo "NOTE: $NUMFAIL tests failed, which may be erroneous.  It may"
   3.337 -#    echo "be a good idea to review the report before sending.  If you"
   3.338 -#    echo "choose not to submit the report, it will be saved for your review"
   3.339 -#    echo "and later submission."
   3.340 -#    echo
   3.341 -#    echo -n "Submit anyway? [y/n] "
   3.342 -#    read ANSWER
   3.343 -#    if [ "$ANSWER" = "n" ]; then
   3.344 -#	report=no
   3.345 -#    fi
   3.346 -#fi
   3.347 +# Resolve options
   3.348 +while [ $# -gt 0 ]
   3.349 +  do
   3.350 +  case "$1" in
   3.351 +      -d)
   3.352 +	  echo "(Skipping report submission)"
   3.353 +	  report=no
   3.354 +	  ;;
   3.355 +      -b)
   3.356 +	  echo "(Batch mode)"
   3.357 +	  batch=yes
   3.358 +	  ;;
   3.359 +      -e)
   3.360 +	  shift
   3.361 +	  echo $1 > contact_info
   3.362 +	  echo "(Email set to $1)"
   3.363 +	  ;;
   3.364 +      -q)
   3.365 +	  run=quick
   3.366 +	  ;;
   3.367 +      -s)
   3.368 +	  run=no
   3.369 +	  ;;
   3.370 +      *)
   3.371 +	  REPORT=$1
   3.372 +	  break
   3.373 +	  ;;
   3.374 +  esac
   3.375 +  shift
   3.376 +done
   3.377  
   3.378 -#
   3.379 -# Generate the XML result report
   3.380 -#
   3.381 -if ! ./lib/XmTestReport/ResultReport.py $OUTPUT > $RESULTREPORTTEMP; then
   3.382 -    echo "Unable to generate clean ResultReport"
   3.383 -    echo "Take a look at $RESULTREPORTTEMP"
   3.384 -    exit 1
   3.385 +# Usage
   3.386 +if [ -z $REPORT ]; then
   3.387 +	usage
   3.388 +	exit 1
   3.389  fi
   3.390  
   3.391 -#
   3.392 -# Maybe submit report and save the combined XML file
   3.393 -#
   3.394 -if [ "$report" = "yes" ]; then
   3.395 -    echo "Sending report..."
   3.396 -    ./lib/XmTestReport/Report.py -D $OSREPORTTEMP $PROGREPORTTEMP \
   3.397 -                                    $RESULTREPORTTEMP > $1.xml
   3.398 -    echo "Report also saved in $1.xml"
   3.399 -else
   3.400 -    echo "Saving report to $1.xml..."
   3.401 -    ./lib/XmTestReport/Report.py -d $OSREPORTTEMP $PROGREPORTTEMP \
   3.402 -                                    $RESULTREPORTTEMP > $1.xml
   3.403 +# Output files
   3.404 +OSREPORTTEMP=${REPORT}.os.xml
   3.405 +PROGREPORTTEMP=${REPORT}.prog.xml
   3.406 +RESULTREPORTTEMP=${REPORT}.result.xml
   3.407 +XMLREPORT=${REPORT}.xml
   3.408 +OUTPUT=${REPORT}.output
   3.409 +SUMMARY=${REPORT}.summary
   3.410 +PASSFAIL=${REPORT}.passfail
   3.411 +TXTREPORT=${REPORT}.report
   3.412 +FAILURES=${REPORT}.failures
   3.413 +	
   3.414 +#  Make sure permissions are correct
   3.415 +chmod a+x lib/XmTestReport/*
   3.416 +chmod a+x mkreport mergereport
   3.417 +
   3.418 +if [ ! -f contact_info ]; then
   3.419 +    if [ "$batch" = "yes" ]; then
   3.420 +	echo "Unable to read contact_info"
   3.421 +	echo "You must run me interactively once!"
   3.422 +	exit 1
   3.423 +    else
   3.424 +	get_contact_info
   3.425 +    fi
   3.426  fi
   3.427 +
   3.428 +if [ "$run" != "no" ]; then
   3.429 +    runnable_tests
   3.430 +    make_environment_report $OSREPORTTEMP $PROGREPORTTEMP
   3.431 +    if [ "$run" = "yes" ]; then
   3.432 +	run_tests $OUTPUT
   3.433 +    else
   3.434 +	run_tests_quick $OUTPUT
   3.435 +    fi
   3.436 +    make_text_reports $PASSFAIL $FAILURES $OUTPUT $TXTREPORT
   3.437 +    make_result_report $OUTPUT $RESULTREPORTTEMP
   3.438 +    cat $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP > $XMLREPORT
   3.439 +    rm $OSREPORTTEMP $PROGREPORTTEMP $RESULTREPORTTEMP
   3.440 +fi
   3.441 +
   3.442 +if [ "$report" = "yes" ] && [ "$run" = "yes" ]; then
   3.443 +    if [ ! -f "$XMLREPORT" ]; then
   3.444 +	echo "No such file: $XMLREPORT"
   3.445 +	exit 1
   3.446 +    fi
   3.447 +    submit_report $XMLREPORT
   3.448 +fi
     4.1 --- a/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Thu Nov 10 12:04:29 2005 +0100
     4.2 +++ b/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Thu Nov 10 12:05:22 2005 +0100
     4.3 @@ -36,7 +36,9 @@ except ConsoleError, e:
     4.4      saveLog(console.getHistory())
     4.5      FAIL(str(e))
     4.6      
     4.7 -os.system("mkfs.ext2 -F /dev/ram1")
     4.8 +s, o = traceCommand("mke2fs -q -F /dev/ram1")
     4.9 +if s != 0:
    4.10 +    FAIL("mke2fs returned %i != 0" % s)
    4.11  
    4.12  for i in range(10):
    4.13  	status, output = traceCommand("xm block-attach %s phy:ram1 hda1 w" % domain.getName())
     5.1 --- a/tools/xm-test/tests/create/log	Thu Nov 10 12:04:29 2005 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,14 +0,0 @@
     5.4 --- BEGIN XmTest Log @Fri Oct 28 13:00:55 PDT 2005
     5.5 -*input
     5.6 -
     5.7 -
     5.8 -BusyBox v1.01 (2005.10.27-17:34+0000) Built-in shell (ash)
     5.9 -Enter 'help' for a list of built-in commands.
    5.10 -
    5.11 --sh: can't access tty; job control turned off
    5.12 -*ls
    5.13 -CVS         etc         linuxrc     opt         sbin        var
    5.14 -bin         home        lost+found  proc        tmp
    5.15 -dev         lib         mnt         root        usr
    5.16 -
    5.17 --- END XmTest Log
     6.1 --- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Thu Nov 10 12:04:29 2005 +0100
     6.2 +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Thu Nov 10 12:05:22 2005 +0100
     6.3 @@ -5,13 +5,20 @@
     6.4  
     6.5  from XmTestLib import *
     6.6  
     6.7 -domain = XmTestDomain()
     6.8 +import re
     6.9 +
    6.10 +domain = XmTestDomain(extraOpts={"nics":2})
    6.11  
    6.12  domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    6.13 +domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")
    6.14  
    6.15 -s, o = traceCommand("mkfs /dev/ram0")
    6.16 +s, o = traceCommand("mke2fs -q /dev/ram0")
    6.17  if s != 0:
    6.18 -    FAIL("Unable to mkfs /dev/ram0 in dom0")
    6.19 +    FAIL("Unable to mke2fs /dev/ram0 in dom0")
    6.20 +
    6.21 +s, o = traceCommand("mke2fs -q /dev/ram1")
    6.22 +if s != 0:
    6.23 +    FAIL("Unable to mke2fs /dev/ram1 in dom0")
    6.24  
    6.25  try:
    6.26      domain.start()
    6.27 @@ -22,13 +29,38 @@ try:
    6.28      console = XmConsole(domain.getName())
    6.29      console.sendInput("foo")
    6.30  
    6.31 -    run = console.runCmd("mount /dev/hda1 /mnt")
    6.32 +    run = console.runCmd("mkdir /mnt/a /mnt/b")
    6.33 +    if run["return"] != 0:
    6.34 +        FAIL("Unable to mkdir /mnt/a /mnt/b")
    6.35 +
    6.36 +    run = console.runCmd("mount /dev/hda1 /mnt/a")
    6.37      if run["return"] != 0:
    6.38          FAIL("Unable to mount /dev/hda1")
    6.39  
    6.40 -    run = console.runCmd("echo bar > /mnt/foo")
    6.41 +    run = console.runCmd("mount /dev/hdb2 /mnt/b")
    6.42 +    if run["return"] != 0:
    6.43 +        FAIL("Unable to mount /dev/hdb2")
    6.44 +
    6.45 +    run = console.runCmd("echo hda1 > /mnt/a/foo")
    6.46 +    if run["return"] != 0:
    6.47 +        FAIL("Unable to write to block device hda1!")
    6.48 +
    6.49 +    run = console.runCmd("echo hdb2 > /mnt/b/foo")
    6.50      if run["return"] != 0:
    6.51 -        FAIL("Unable to write to block device!")
    6.52 +        FAIL("Unable to write to block device hdb2!")
    6.53 +
    6.54 +    run = console.runCmd("ifconfig eth0 169.254.0.1 netmask 255.255.255.0")
    6.55 +    if run["return"] != 0:
    6.56 +        FAIL("Unable to configure DomU's eth0")
    6.57 +
    6.58 +    run = console.runCmd("ifconfig eth1 169.254.1.1 netmask 255.255.255.0")
    6.59 +    if run["return"] != 0:
    6.60 +        FAIL("Unable to configure DomU's eth1")
    6.61 +
    6.62 +    run = console.runCmd("ifconfig lo 127.0.0.1")
    6.63 +    if run["return"] != 0:
    6.64 +        FAIL("Unable to configure DomU's lo")
    6.65 +
    6.66  
    6.67  except ConsoleError, e:
    6.68      FAIL(str(e))
    6.69 @@ -63,9 +95,31 @@ try:
    6.70      if run["return"] != 0:
    6.71          FAIL("ls failed on restored domain")
    6.72      
    6.73 -    run = console.runCmd("cat /mnt/foo | grep bar")
    6.74 +    run = console.runCmd("cat /mnt/a/foo")
    6.75 +    if run["return"] != 0:
    6.76 +        FAIL("Unable to read from block device hda1")
    6.77 +    if not re.search("hda1", run["output"]):
    6.78 +        FAIL("Failed to read correct data from hda1")
    6.79 +
    6.80 +    run = console.runCmd("cat /mnt/b/foo")
    6.81      if run["return"] != 0:
    6.82 -        FAIL("Unable to read from block device")
    6.83 +        FAIL("Unable to read from block device hdb2")
    6.84 +    if not re.search("hdb2", run["output"]):
    6.85 +        FAIL("Failed to read correct data from hdb2")
    6.86 +
    6.87 +    run = console.runCmd("ifconfig")
    6.88 +    if not re.search("eth0", run["output"]):
    6.89 +        FAIL("DomU's eth0 disappeared")
    6.90 +    if not re.search("169.254.0.1", run["output"]):
    6.91 +        FAIL("DomU's eth0 lost its IP")
    6.92 +    if not re.search("eth1", run["output"]):
    6.93 +        FAIL("DomU's eth1 disappeared")
    6.94 +    if not re.search("169.254.1.1", run["output"]):
    6.95 +        FAIL("DomU's eth1 lost its IP")
    6.96 +    if not re.search("Loopback", run["output"]):
    6.97 +        FAIL("DomU's lo disappeared")
    6.98 +    if not re.search("127.0.0.1", run["output"]):
    6.99 +        FAIL("DomU's lo lost its IP")
   6.100  
   6.101  except ConsoleError, e:
   6.102      FAIL(str(e))