Introduce an option for testing binary API
[one.git] / tests / data_plane / vpp_lite_topo / run.sh
index 59bae1c..f57e4a2 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+source odl_utils.sh
+
 TESTS_DIR=tests
 
 function help
@@ -8,12 +10,17 @@ function help
   echo
   echo This must be run with superuser privileges.
   echo "Usage:"
-  echo " ./run.sh [vh]"
+  echo " ./run.sh [vhc] [--config-method vat|cli]"
   echo
   echo "  -v : verbose output"
+  echo "  -c : clean"
   echo "  -h : show help"
+  echo "  --config-method : select configuration method. Default is VAT."
 }
 
+export CFG_METHOD=vat
+source config.sh
+
 verbose=0
 
 while [ $# -gt 0 ] ; do
@@ -25,6 +32,22 @@ while [ $# -gt 0 ] ; do
   elif [ $arg == "-h" ] ; then
     help
     exit 0
+  elif [ $arg == "-c" ] ; then
+    clean_all
+    exit 0
+  elif [ $arg == "--config-method" ] ; then
+    type=$1
+    shift
+    if [ $type != "vat" -a $type != "cli"  ] ; then
+      echo "ERROR: expected one of 'cli' or 'vat' "
+      help
+      exit 1
+    fi
+    export CFG_METHOD=$type
+  else
+    echo "parse error"
+    help
+    exit 1
   fi
 done
 
@@ -37,25 +60,37 @@ passed_num=0
 
 start_time=`date +%s`
 
+# sudo?
+if [[ $(id -u) != 0 ]]; then
+  echo "Superuser privileges needed!"
+  exit 1
+fi
+
+# check whether ODL is running
+check_odl_running
+
+
 # count tests
-test_num=`ls -l $TESTS_DIR/test_* | wc -l`
+test_num=`ls -l "$TESTS_DIR"/test_* | wc -l`
 
 echo
 echo "Running VPP lite test suite."
 echo
+echo "Config method: $CFG_METHOD"
+echo
 
-for test_case in $TESTS_DIR/test_*
+for test_case in "$TESTS_DIR"/test_*
 do
   let "count=$count + 1"
 
   # run the test case
-  base_name=`basename -a $test_case`
-  printf "*** %d/%d : %-45s" $count $test_num $base_name
+  base_name=`basename -a "$test_case"`
+  printf "*** %2d/%d : %-45s" $count $test_num "$base_name"
 
   if [ $verbose -ne 0 ] ; then
-    $test_case
+    "$test_case"
   else
-    $test_case &> /dev/null
+    "$test_case" &> /dev/null
   fi
   rc=$?