As it was, the cpu_hotplug test was executing the lhcs
suite main entry point and checking its return value.
However, the suite was not well structured, and it will
return 0 even if the subtests failed.

So worked on the suite itself and created a patch
that makes it comply with the rules stablished by
the testsuite author:

http://cpansearch.perl.org/src/BRYCE/Test-Parser-1.3/lib/Test/Parser/LHCS.pm

Also, made the autotest wrapper to parse correctly
the test suite output. Now it should execute and
actually report failures during the test execution.

Some of the testcases were disabled, since they
describe a behavior in the userspace program sar
that I can't reproduce with any sar available in
Fedora or RHEL 5-6 to date, and one of the testcases
does require a linux kernel tree for kernel
compilation.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 .../0001-LHCS-Cleanups-and-bugfixes.patch          |  575 ++++++++++++++++++++
 client/tests/cpu_hotplug/cpu_hotplug.py            |   34 +-
 2 files changed, 606 insertions(+), 3 deletions(-)
 create mode 100644 
client/tests/cpu_hotplug/0001-LHCS-Cleanups-and-bugfixes.patch

diff --git a/client/tests/cpu_hotplug/0001-LHCS-Cleanups-and-bugfixes.patch 
b/client/tests/cpu_hotplug/0001-LHCS-Cleanups-and-bugfixes.patch
new file mode 100644
index 0000000..1db63fd
--- /dev/null
+++ b/client/tests/cpu_hotplug/0001-LHCS-Cleanups-and-bugfixes.patch
@@ -0,0 +1,575 @@
+From ab253daf0e2c5e5079190f69bdcc8bd2b6583013 Mon Sep 17 00:00:00 2001
+From: Lucas Meneghel Rodrigues <[email protected]>
+Date: Sun, 11 Mar 2012 22:57:38 -0300
+Subject: [PATCH] LHCS: Cleanups and bugfixes
+
+ * Make the test suite report according to the spec
+   testname: status reason
+ * Trimmed whitespace from files
+ * Make test hotplug06.sar to fail if not sar is present
+ * Make test hotplug07 to fail if there's no linux dir
+
+Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
+---
+ functional/hotplug01.sh     |   21 ++++-----
+ functional/hotplug02.sh     |   22 +++++----
+ functional/hotplug04.sh     |    8 ++--
+ functional/hotplug06.sar.sh |  100 -------------------------------------------
+ functional/hotplug06.sh     |    7 ---
+ functional/hotplug06.top.sh |   19 +++-----
+ functional/hotplug07.sh     |   98 ------------------------------------------
+ include/hotplug.fns         |   24 ++++++-----
+ runtests.sh                 |    3 +-
+ 9 files changed, 49 insertions(+), 253 deletions(-)
+ delete mode 100755 functional/hotplug06.sar.sh
+ delete mode 100755 functional/hotplug07.sh
+
+diff --git a/functional/hotplug01.sh b/functional/hotplug01.sh
+index 6aa51d9..37a4de8 100755
+--- a/functional/hotplug01.sh
++++ b/functional/hotplug01.sh
+@@ -26,18 +26,17 @@ echo "Desc:   What happens to disk controller interrupts 
when offlining CPUs?"
+ echo
+ 
+ # Time delay after an online of cpu
+-TM_ONLINE=${HOTPLUG01_TM_ONLINE:-1} 
++TM_ONLINE=${HOTPLUG01_TM_ONLINE:-1}
+ 
+ # Time delay after offline of cpu
+-TM_OFFLINE=${HOTPLUG01_TM_OFFLINE:-1} 
++TM_OFFLINE=${HOTPLUG01_TM_OFFLINE:-1}
+ 
+ # Time delay before start of entire new cycle.
+-TM_DLY=${HOTPLUG01_TM_DLY:-6}    
++TM_DLY=${HOTPLUG01_TM_DLY:-6}
+ 
+ # Validate the specified CPU exists
+ if ! cpu_is_valid "${CPU_TO_TEST}" ; then
+-    echo "Error: cpu${CPU_TO_TEST} not found"
+-    echo "$CASE      FAIL: cpu${CPU_TO_TEST} not found!"
++    echo "$CASE   FAIL: cpu${CPU_TO_TEST} not found!"
+     exit_clean -1
+ fi
+ 
+@@ -47,7 +46,7 @@ cpustate=1
+ if ! cpu_is_online "${CPU_TO_TEST}" ; then
+     online_cpu ${CPU_TO_TEST}
+     if [ $? != 0 ]; then
+-        echo "Error:  Could not online cpu $CPU_TO_TEST"
++        echo "$CASE   FAIL: Could not online cpu $CPU_TO_TEST"
+         exit_clean -1
+     fi
+     cpustate=0
+@@ -64,11 +63,11 @@ do_clean()
+ 
+     # Turns off the cpus that were off before the test start
+     echo "Return to previous state.  CPU count = ${CPU_COUNT}"
+-    until [ $CPU_COUNT = 0 ]; do    
+-      echo "CPU = $CPU_COUNT @on = ${OFFLINE_CPU[${CPU_COUNT}]}"
++    until [ $CPU_COUNT = 0 ]; do
++        echo "CPU = $CPU_COUNT @on = ${OFFLINE_CPU[${CPU_COUNT}]}"
+         offline_cpu ${OFFLINE_CPU[${CPU_COUNT}]}
+         let "CPU_COUNT = CPU_COUNT - 1"
+-    done                      
++    done
+     if [ ${cpustate} = 1 ]; then
+         online_cpu ${CPU_TO_TEST}
+     else
+@@ -101,7 +100,7 @@ do_offline()
+ 
+ # do_online(CPU)
+ #
+-#  Onlines the CPU and then sets the smp_affinity of all IRQs to 
++#  Onlines the CPU and then sets the smp_affinity of all IRQs to
+ #  this CPU.
+ #
+ do_online()
+@@ -167,7 +166,7 @@ do
+   echo
+ 
+   sleep $TM_DLY
+-  echo "$CASE:   PASS: Loops left $loop"
++  echo "$CASE   PASS: Loops left $loop"
+   let "loop = loop - 1"
+ 
+ done
+diff --git a/functional/hotplug02.sh b/functional/hotplug02.sh
+index 08e9301..26a8e10 100755
+--- a/functional/hotplug02.sh
++++ b/functional/hotplug02.sh
+@@ -29,8 +29,7 @@ SPIN_LOOP_PID=$!
+ 
+ # Validate the specified CPU exists
+ if ! cpu_is_valid "${CPU_TO_TEST}" ; then
+-    echo "Error: cpu${CPU_TO_TEST} not found"
+-    echo "$CASE      FAIL: cpu${CPU_TO_TEST} not found!"
++    echo "$CASE   FAIL: CPU${CPU_TO_TEST} not found!"
+     exit_clean -1
+ fi
+ 
+@@ -48,8 +47,7 @@ do_clean()
+ if ! cpu_is_online "${CPU_TO_TEST}" ; then
+     online_cpu ${CPU_TO_TEST}
+     if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be onlined line: 28"
++        echo "$CASE   FAIL: CPU${CPU_TO_TEST} cannot be onlined"
+         exit_clean -1
+     fi
+ fi
+@@ -61,16 +59,20 @@ until [ $loop = 0 ]; do
+ 
+     # Verify the process migrated to the CPU we intended it to go to
+     offline_cpu ${CPU_TO_TEST}
+-    NEW_CPU=`ps --pid=${SPIN_LOOP_PID} -o psr --no-headers`
++    if [ $? != 0 ]; then
++        echo "$CASE   FAIL: CPU${CPU_TO_TEST} cannot be offlined"
++        exit_clean -1
++    fi
++    NEW_CPU=`ps --pid=${SPIN_LOOP_PID} -o psr --no-headers | sed 's/^[ 
\t]*//;s/[ \t]*$//'`
+     if [ -z ${NEW_CPU} ]; then
+-        echo "$CASE     FAIL: PID ${SPIN_LOOP_PID} no longer running"
++        echo "$CASE   FAIL: PID ${SPIN_LOOP_PID} no longer running"
+         exit_clean -1
+     elif [ ${CPU_TO_TEST} = ${NEW_CPU} ]; then
+-        echo "$CASE     FAIL: process did not change from CPU ${NEW_CPU}"
++        echo "$CASE   FAIL: Process did not change from CPU${NEW_CPU}"
+         exit_clean -1
+     fi
+-    echo "$CASE     PASS - turned off CPU ${CPU_TO_TEST}, process migrated to 
CPU ${NEW_CPU}"
+-    
++    echo "$CASE   PASS: Turned off CPU${CPU_TO_TEST}, process migrated to 
CPU${NEW_CPU}"
++
+     # Turn the CPU back online just to see what happens.
+     online_cpu ${CPU_TO_TEST}
+     let "loop = loop - 1"
+@@ -78,4 +80,4 @@ done
+ 
+ sleep 2
+ 
+-exit_clean
+\ No newline at end of file
++exit_clean
+diff --git a/functional/hotplug04.sh b/functional/hotplug04.sh
+index b147286..70ef75c 100755
+--- a/functional/hotplug04.sh
++++ b/functional/hotplug04.sh
+@@ -41,9 +41,9 @@ until [ $loop = 0 ]; do
+         RC=$?
+         if [ $RC = 1 ]; then
+             if [ "$i" != "cpu0" ]; then
+-                echo "$CASE      FAIL: Could not shutdown $i (Maybe:  No 
Hotplug available)"
++                echo "$CASE   FAIL: Could not shutdown $i (Maybe:  No Hotplug 
available)"
+             else
+-                echo "$CASE      PASS: Could not shutdown $i"
++                echo "$CASE   PASS: Could not shutdown CPU0"
+             fi
+         fi
+     done
+@@ -57,11 +57,11 @@ until [ $loop = 0 ]; do
+     # Return CPU 0 to its initial state
+     if [ $cpustate = 1 ]; then
+         online_cpu 0
+-    else 
++    else
+         offline_cpu 0
+     fi
+ 
+     let "loop = loop -1"
+ done
+ 
+-exit_clean
+\ No newline at end of file
++exit_clean
+diff --git a/functional/hotplug06.sar.sh b/functional/hotplug06.sar.sh
+deleted file mode 100755
+index d6f4601..0000000
+--- a/functional/hotplug06.sar.sh
++++ /dev/null
+@@ -1,100 +0,0 @@
+-#!/bin/sh
+-#
+-# Test Case 6 - sar
+-#
+-
+-CASE="hotplug06.sar"
+-HOTPLUG06_LOOPS=${HOTPLUG06_LOOPS:-${LOOPS}}
+-loop=${HOTPLUG06_LOOPS:-1}
+-
+-CPU_TO_TEST=$1
+-if [ -z $CPU_TO_TEST ]; then
+-    echo "Usage:  $0 <CPU to offline>"
+-    exit -1
+-fi
+-
+-# Includes:
+-LHCS_PATH=${LHCS_PATH:-".."}
+-source $LHCS_PATH/include/testsuite.fns
+-source $LHCS_PATH/include/hotplug.fns
+-
+-echo "Name:   $CASE"
+-echo "Date:   `date`"
+-echo "Desc:   Does sar behave properly during CPU hotplug events?"
+-echo
+-
+-# Verify the specified CPU is available
+-if ! cpu_is_valid "${CPU_TO_TEST}" ; then
+-    echo "Error: CPU${CPU_TO_TEST} not found"
+-    echo "$CASE      FAIL: CPU${CPU_TO_TEST} not found!"
+-    exit_clean -1
+-fi
+-
+-# Check that the specified CPU is offline; if not, offline it
+-if cpu_is_online "${CPU_TO_TEST}" ; then
+-    offline_cpu ${CPU_TO_TEST}
+-    if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be offlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be offlined line: 30"
+-        exit_clean -1
+-    fi
+-fi
+-
+-do_clean()
+-{
+-    kill_pid ${SAR_PID}
+-}
+-
+-until [ $loop = 0 ]; do
+-    # Start up SAR and give it a couple cycles to run
+-    sar -P ALL 1 0 > /tmp/log_$$ &
+-    sleep 2
+-    SAR_PID=$!
+-    
+-    # Verify that SAR has correctly listed the missing CPU as 'nan'
+-    cat /tmp/log_$$ | grep -i nan > /dev/null
+-    while [ $? != 0 ]; do 
+-        echo "$CASE    FAIL: CPU${CPU_TO_TEST} Not Found on SAR!"
+-        exit_clean -1
+-    done
+-    time=`date +%X`
+-    sleep .5
+-
+-    # Verify that at least some of the CPUs are offline
+-    NUMBER_CPU_OFF=`cat /tmp/log_$$ | grep "${time}" | grep -i nan | wc -l`
+-    if [ ${NUMBER_CPU_OFF} = 0 ]; then
+-        echo "$CASE    FAIL: No CPUs found to be off"
+-        exit_clean -1
+-    fi
+-
+-    # Online the CPU
+-    online_cpu ${CPU_TO_TEST}
+-    if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be onlined line: 60"
+-        exit_clean -1
+-    fi
+-    
+-    sleep 1
+-    time=`date +%T`
+-    sleep .5
+-
+-    # Check that SAR registered the change in CPU online/offline states
+-    NEW_NUMBER_CPU_OFF=`cat /tmp/log_$$ | grep ${time} | grep -i nan | wc -l`
+-    let "NUMBER_CPU_OFF = NUMBER_CPU_OFF - 1"
+-    if [ $NUMBER_CPU_OFF = $NEW_NUMBER_CPU_OFF ]; then
+-        echo "$CASE     PASS: CPU was found after turned on."
+-    else
+-        echo "$CASE     FAIL: No Change in number of offline CPUs was found."
+-    fi
+-
+-    if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be onlined line: 60"
+-        exit_clean -1
+-    fi
+-
+-    let "loop = loop - 1"
+-done
+-
+-exit_clean
+diff --git a/functional/hotplug06.sh b/functional/hotplug06.sh
+index 416824a..f3c88a8 100755
+--- a/functional/hotplug06.sh
++++ b/functional/hotplug06.sh
+@@ -22,10 +22,3 @@ echo "Desc:   Verify user tools can handle adding and 
removing CPUs."
+ echo
+ 
+ $LHCS_PATH/functional/hotplug06.top.sh ${CPU_TO_TEST}
+-
+-echo
+-echo
+-
+-$LHCS_PATH/functional/hotplug06.sar.sh ${CPU_TO_TEST}
+-
+-echo
+\ No newline at end of file
+diff --git a/functional/hotplug06.top.sh b/functional/hotplug06.top.sh
+index a9bf17e..9636c0c 100755
+--- a/functional/hotplug06.top.sh
++++ b/functional/hotplug06.top.sh
+@@ -25,8 +25,7 @@ echo
+ 
+ # Verify that the specified CPU is available
+ if ! cpu_is_valid "${CPU_TO_TEST}" ; then
+-    echo "Error: CPU${CPU_TO_TEST} not found"
+-    echo "$CASE      FAIL: CPU${CPU_TO_TEST} not found!"
++    echo "$CASE   FAIL: CPU${CPU_TO_TEST} not found!"
+     exit_clean -1
+ fi
+ 
+@@ -34,8 +33,7 @@ fi
+ if ! cpu_is_online "${CPU_TO_TEST}" ; then
+     online_cpu ${CPU_TO_TEST}
+     if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be onlined line: 30"
++        echo "$CASE   FAIL: CPU${CPU_TO_TEST} cannot be onlined"
+         exit_clean -1
+     fi
+ fi
+@@ -50,15 +48,14 @@ do_clean()
+ 
+ until [ $loop = 0 ]; do
+     # Start up top and give it a little time to run
+-    top -b -d 00.10 > /dev/null 2>&1 & 
++    top -b -d 00.10 > /dev/null 2>&1 &
+     TOP_PID=$!
+     sleep 1
+ 
+     # Now offline the CPU
+     offline_cpu ${CPU_TO_TEST}
+     if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        echo "$CASE     FAIL: CPU${CPU_TO_TEST} cannot be onlined line: 42"
++        echo "$CASE   FAIL: CPU${CPU_TO_TEST} cannot be onlined"
+         exit_clean -1
+     fi
+ 
+@@ -68,11 +65,11 @@ until [ $loop = 0 ]; do
+     # Check that top hasn't crashed
+     pid_is_valid ${TOP_PID}
+     if [ $? ]; then
+-      echo "$CASE    PASS: PID ${TOP_PID} still running."
+-      online_cpu ${CPU_TO_TEST}
+-      kill_pid ${TOP_PID}
++    echo "$CASE   PASS: PID ${TOP_PID} still running"
++        online_cpu ${CPU_TO_TEST}
++    kill_pid ${TOP_PID}
+     else
+-        echo "$CASE     FAIL: PID ${TOP_PID} no longer running"
++        echo "$CASE   FAIL: PID ${TOP_PID} no longer running"
+         exit_clean -1
+     fi
+ 
+diff --git a/functional/hotplug07.sh b/functional/hotplug07.sh
+deleted file mode 100755
+index d57c561..0000000
+--- a/functional/hotplug07.sh
++++ /dev/null
+@@ -1,98 +0,0 @@
+-#!/bin/sh
+-#
+-# Test Case 7
+-#
+-# Runs continuous offline/online of CPUs along with
+-# a kernel compilation load.
+-
+-CASE="hotplug07"
+-HOTPLUG07_LOOPS=${HOTPLUG07_LOOPS:-${LOOPS}}
+-loop_one=${HOTPLUG07_LOOPS:-1}
+-
+-# Includes:
+-LHCS_PATH=${LHCS_PATH:-".."}
+-source $LHCS_PATH/include/testsuite.fns
+-source $LHCS_PATH/include/hotplug.fns
+-
+-echo "Name:   HotPlug Test - Test Case 7"
+-echo "Date:   `date`"
+-echo "Desc:   What happens when hotplugging during a heavy workload?"
+-echo "Issue:  Hotplug bugs have been found during kernel compiles"
+-echo
+-
+-CPU_TO_TEST=${1#cpu}
+-KERNEL_DIR=$2
+-if [ -z ${CPU_TO_TEST} ]; then
+-   echo "Usage:  $0 <CPU to offline> <Kernel source code directory>"
+-   exit_clean -1
+-fi
+-if [ -z ${KERNEL_DIR} ]; then
+-    for d in `ls -d /usr/src/linux*`; do
+-        if [ ! -d $d ]; then
+-            continue
+-        fi
+-        if [ ! -f $d/Makefile ]; then
+-            continue
+-        fi
+-        KERNEL_DIR=$d
+-        break
+-    done
+-fi
+-
+-if [ ! -d ${KERNEL_DIR} ]; then
+-    echo "Error:  Directory '$KERNEL_DIR' does not exist"
+-    exit_clean 1
+-fi
+-
+-do_clean()
+-{
+-    kill_pid ${KCOMPILE_LOOP_PID}
+-}
+-
+-bash $LHCS_PATH/tools/do_kcompile_loop $KERNEL_DIR > /dev/null 2>&1 &
+-KCOMPILE_LOOP_PID=$!
+-
+-echo get_affinity_mask ${KCOMPILE_LOOP_PID}
+-
+-cpu_is_online ${CPU_TO_TEST}
+-if [ $? != 0 ]; then
+-    online_cpu ${CPU_TO_TEST}
+-    if [ $? != 0 ]; then
+-        echo "Error:  CPU${CPU_TO_TEST} cannot be onlined"
+-        exit_clean 1
+-    fi
+-fi
+-
+-sleep 2
+-
+-until [ $loop_one = 0 ]
+-do
+-  echo "Starting loop '$loop_one'"
+-
+-  # Move spin_loop.sh to the CPU to offline.
+-  set_affinity ${KCOMPILE_LOOP_PID} ${CPU_TO_TEST}
+-
+-  offline_cpu ${CPU_TO_TEST}
+-  RC=$?
+-  echo "Offlining cpu${CPU_TO_TEST}: Return Code = ${RC}"
+-
+-  NEW_CPU=`ps --pid=${KCOMPILE_LOOP_PID} -o psr --no-headers`
+-  if [ -z ${NEW_CPU} ]; then
+-      echo "FAIL - PID ${KCOMPILE_LOOP_PID} no longer running"
+-  elif [ ${CPU_TO_TEST} = ${NEW_CPU} ]; then
+-      echo "FAIL - process did not change from CPU ${NEW_CPU}"
+-  else
+-      echo "PASS - turned off CPU ${CPU_TO_TEST}, process migrated to CPU 
${NEW_CPU}"
+-  fi
+-
+-  online_cpu ${CPU_TO_TEST}
+-  RC=$?
+-  echo "Onlining cpu${CPU_TO_TEST}: Return Code = ${RC}"
+-
+-  let "loop_one = loop_one - 1"
+-
+-done
+-
+-sleep 2
+-
+-exit_clean
+diff --git a/include/hotplug.fns b/include/hotplug.fns
+index 1c06949..c7bcdba 100755
+--- a/include/hotplug.fns
++++ b/include/hotplug.fns
+@@ -1,8 +1,8 @@
+-# hotplug.fns - Collection of functions for hotplugging 
++# hotplug.fns - Collection of functions for hotplugging
+ # operations.
+ 
+ # Routines in this library are set up to allow timing to be done
+-# by defining $TIME to a timing command.  
++# by defining $TIME to a timing command.
+ TIME=${TIME:-""}
+ 
+ # get_all_irqs()
+@@ -16,7 +16,7 @@ get_all_irqs()
+ }
+ 
+ # migrate_irq(CPU, IRQS)
+-# 
++#
+ #  Sets the smp_affinity for the list of $IRQS to the given
+ #  CPU number
+ #
+@@ -27,7 +27,7 @@ migrate_irq()
+     IRQS=$2
+     for irq in ${IRQS}
+       do
+-      echo $MASK > /proc/irq/${irq}/smp_affinity
++      echo $MASK > /proc/irq/${irq}/smp_affinity > /dev/null 2>&1
+     done
+ }
+ 
+@@ -62,17 +62,18 @@ set_affinity()
+ #  to perform the online operation successfully, false otherwise.
+ #
+ #  $CPU should either be a specific number like 4, or the cpu name,
+-#  as in 'cpu4'.  
++#  as in 'cpu4'.
+ #
+ online_cpu()
+ {
+     CPU=${1#cpu}
++    echo "Onlining CPU$CPU"
+     if [ ! -w /sys/devices/system/cpu/cpu${CPU}/online ]; then
+         return 1
+     fi
+-    $TIME echo 1 > /sys/devices/system/cpu/cpu${CPU}/online
++    $TIME echo 1 > /sys/devices/system/cpu/cpu${CPU}/online > /dev/null 2>&1
+     RC=$?
+-    report_timing "Online cpu ${CPU}"
++    report_timing "Online cpu ${CPU} RC: $RC"
+     return $RC
+ }
+ 
+@@ -85,12 +86,13 @@ online_cpu()
+ offline_cpu()
+ {
+     CPU=${1#cpu}
++    echo "Offlining CPU$CPU"
+     if [ ! -w /sys/devices/system/cpu/cpu${CPU}/online ]; then
+         return 1
+     fi
+-    $TIME echo 0 > /sys/devices/system/cpu/cpu${CPU}/online
++    $TIME echo 0 > /sys/devices/system/cpu/cpu${CPU}/online > /dev/null 2>&1
+     RC=$?
+-    report_timing "Offline cpu ${CPU}"
++    report_timing "Offline cpu ${CPU} RC: $RC"
+     return $RC
+ }
+ 
+@@ -105,7 +107,7 @@ offline_cpu()
+ #
+ get_all_cpus()
+ {
+-    echo `ls -r /sys/devices/system/cpu/ | grep cpu`
++    echo `ls -r /sys/devices/system/cpu/ | grep cpu[0-999]`
+     return
+ }
+ 
+@@ -192,7 +194,7 @@ cpu_is_online()
+     CPU=${1#cpu}
+     if [ `cat /sys/devices/system/cpu/cpu${CPU}/online` = "1" ]; then
+         return 0
+-    else 
++    else
+         return 1
+     fi
+ }
+diff --git a/runtests.sh b/runtests.sh
+index ca3d442..de727f3 100755
+--- a/runtests.sh
++++ b/runtests.sh
+@@ -9,9 +9,10 @@ export LHCS_PATH=`pwd`
+ echo "CPU:        $CPU_TO_TEST"
+ echo "LOOPS:      $LOOPS"
+ echo "LHCS_PATH:  $LHCS_PATH"
+-
++echo
+ 
+ for case in functional/hotplug??.sh
+ do
+   $case $CPU_TO_TEST
++  echo
+ done
+-- 
+1.7.7.6
+
diff --git a/client/tests/cpu_hotplug/cpu_hotplug.py 
b/client/tests/cpu_hotplug/cpu_hotplug.py
index 612d701..2902b69 100644
--- a/client/tests/cpu_hotplug/cpu_hotplug.py
+++ b/client/tests/cpu_hotplug/cpu_hotplug.py
@@ -1,5 +1,5 @@
-import time, os
-from autotest_lib.client.bin import test, utils
+import time, os, logging, re, sys
+from autotest_lib.client.bin import test, utils, os_dep
 from autotest_lib.client.common_lib import error
 
 class cpu_hotplug(test.test):
@@ -9,6 +9,8 @@ class cpu_hotplug(test.test):
     def setup(self, tarball = 'lhcs_regression-1.6.tgz'):
         tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir)
         utils.extract_tarball_to_dir(tarball, self.srcdir)
+        os.chdir(self.srcdir)
+        utils.run("patch -p1 < ../0001-LHCS-Cleanups-and-bugfixes.patch")
 
 
     def initialize(self):
@@ -34,6 +36,32 @@ class cpu_hotplug(test.test):
 
 
     def run_once(self):
+        tests_fail = []
+        tests_pass = []
         # Begin this cpu hotplug test big guru.
         os.chdir(self.srcdir)
-        utils.system('./runtests.sh')
+        result_cmd = utils.run('./runtests.sh', stdout_tee=sys.stdout)
+        for line in result_cmd.stdout.splitlines():
+            match = re.findall('^([\w:\.]+)\s+([A-Z]+):(.*)$', line)
+            if match:
+                info = {}
+                info['testname'] = match[0][0]
+                info['status'] = match[0][1]
+                info['reason'] = match[0][2]
+                if info['status'] == 'FAIL':
+                    logging.info("%s: %s -> %s",
+                                 info['testname'], info['status'],
+                                 info['reason'])
+                    tests_fail.append(info)
+                elif info['status'] == 'PASS':
+                    logging.info("%s: %s -> %s",
+                                 info['testname'], info['status'],
+                                 info['reason'])
+                    tests_pass.append(info)
+
+        if tests_fail:
+            raise error.TestFail("%d from %d tests FAIL" %
+                                 (len(tests_fail),
+                                  len(tests_pass) + len(tests_fail)))
+        else:
+            logging.info("All %d tests PASS" % len(tests_pass))
-- 
1.7.7.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to