bugfix: clean results directory error
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Tue, 27 Dec 2016 06:10:50 +0000 (14:10 +0800)
committerSerenaFeng <feng.xiaowei@zte.com.cn>
Tue, 27 Dec 2016 06:15:50 +0000 (14:15 +0800)
change 'rm -rf /home/opnfv/functest' to 'rm -rf /home/opnfv/functest/results'
and extract the clean logic to a common method clean_results_dir

Change-Id: I8aa0b09b58d9c14e53c2d4f2bb39376239e41168
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
run_unit_tests.sh

index 71d21c9..b098f37 100755 (executable)
@@ -2,6 +2,13 @@
 set -o errexit
 set -o pipefail
 
+function clean_results_dir {
+    if [ -d "/home/opnfv/functest/results" ]
+    then
+        sudo rm -rf /home/opnfv/functest/results
+    fi
+}
+
 # ******************************
 # prepare the env for the tests
 # ******************************
@@ -9,10 +16,7 @@ set -o pipefail
 # should be done at the end
 # but in case of crash during unit test
 # clean it anyway
-if [ -d "/home/opnfv/functest/results" ]
-then
-    sudo rm -rf /home/opnfv/functest
-fi
+clean_results_dir
 
 # TODO clean that...
 # Create log dir if needed
@@ -67,9 +71,6 @@ deactivate
 # clean
 # *******
 # Clean useless logs
-if [ -d "/home/opnfv/functest/results" ]
-then
-    sudo rm -rf /home/opnfv/functest/results
-fi
+clean_results_dir
 
 exit $rc