Update the test script for BSP test case

1. Don't use $ROOT to locate BSP directory, $TMP_DIR instead
2. Change the invoke sequence of variables (NUM_FAIL_CPU/NUM_PASS_CPU)
   to avoid any complaint.

Signed-off-by: Shaoyong Wang <shaoyongx.wang@intel.com>
Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
diff --git a/cases/function/bsp/bsp-test.sh b/cases/function/bsp/bsp-test.sh
index 7c80cd1..5627c30 100755
--- a/cases/function/bsp/bsp-test.sh
+++ b/cases/function/bsp/bsp-test.sh
@@ -12,6 +12,10 @@
 
 EOF
 
+export ROOT=`(cd ../../../; pwd)`
+
+. $ROOT/lib/functions.sh
+
 #default cycle to run
 ROUND=10
 
diff --git a/cases/function/bsp/runtest.sh b/cases/function/bsp/runtest.sh
index 9940711..90311f2 100755
--- a/cases/function/bsp/runtest.sh
+++ b/cases/function/bsp/runtest.sh
@@ -35,11 +35,6 @@
 
 EOF
 
-#export ROOT=`(cd ../../../; pwd)`
-export ROOT=`pwd`
-
-. $ROOT/lib/functions.sh
-
 TMP="../../../work"
 TMP_DIR=${TMP_DIR:-$TMP}
 if [ ! -d $TMP_DIR ]; then
@@ -47,15 +42,15 @@
 fi
 export TMP_DIR
 
-export NUM_CPU=`ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l`
-export MAX_CPU=`expr $NUM_CPU - 1`
-export BSP_LOG_DIR=$ROOT/cases/function/bsp/log
+#$TMP_DIR can be absolute/relative path. Utilize it to locate BSP directory
+export BSP_DIR=`(cd $TMP_DIR; cd ../cases/function/bsp; pwd)`
+export BSP_LOG_DIR=$BSP_DIR/log
 export BSP_LOG=$BSP_LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.bsplog
 export OUTPUT_LOG=$BSP_LOG_DIR/$(date +%Y-%m-%d.%H.%M.%S)-`uname -r`.output
-export FAILST=$TMP_DIR/fail.list
 
-NUM_FAIL_CPU=`grep "CPU" $FAILST |wc -l`
-NUM_PASS_CPU=`expr $NUM_CPU - $NUM_FAIL_CPU`
+export NUM_CPU=`ls -d /sys/devices/system/cpu/cpu[0-9]* | wc -l`
+export MAX_CPU=`expr $NUM_CPU - 1`
+export FAILST=$TMP_DIR/fail.list
 
 mkdir -p $BSP_LOG_DIR
 touch $FAILST
@@ -80,6 +75,9 @@
 
 	screen ./bsp-test.sh
 
+	NUM_FAIL_CPU=`grep "CPU" $FAILST |wc -l`
+	NUM_PASS_CPU=`expr $NUM_CPU - $NUM_FAIL_CPU`
+
 	echo "Total CPU Test: $NUM_CPU"
 	echo "Total CPU Pass: $NUM_PASS_CPU"
 	echo "Total CPU Fail: $NUM_FAIL_CPU"