Enhancing STC and scenarios.

Change-Id: I57a4d25b7fb726a1242073055474ff5c7c3c1087
diff --git a/tools/test/bin/ogroup-opts b/tools/test/bin/ogroup-opts
index e9b030c..3b4248c 100644
--- a/tools/test/bin/ogroup-opts
+++ b/tools/test/bin/ogroup-opts
@@ -1,14 +1,43 @@
-# tab completion settings for onos-group.
 
-# options available to onos-group
-GOPTS='install kill patch-vm push-keys uninstall'
-
+# Tab completion settings for onos-group.
 function _ogroup-opts () {
   local cur=${COMP_WORDS[COMP_CWORD]}
-
   if [ $COMP_CWORD -eq 1 ]; then
-    COMPREPLY=( $( compgen -W "$GOPTS help" -- $cur ) )
+    COMPREPLY=( $( compgen -W "install kill patch-vm push-keys uninstall help" -- $cur ) )
   fi
 }
 
 complete -F _ogroup-opts onos-group
+
+
+# Tab completion settings for stc
+function _stc-opts () {
+  local cur=${COMP_WORDS[COMP_CWORD]}
+  if [ $COMP_CWORD -eq 1 ]; then
+    COMPREPLY=( $( compgen -W "$(cd $ONOS_ROOT/tools/test/scenarios && ls -1 | sed 's/.xml//g')" -- $cur ) )
+  fi
+}
+
+complete -F _stc-opts stc
+
+
+# Tab completion settings for cell
+function _cell-opts () {
+  local cur=${COMP_WORDS[COMP_CWORD]}
+  if [ $COMP_CWORD -eq 1 ]; then
+    COMPREPLY=( $( compgen -W "$(cd $ONOS_ROOT/tools/test/cells && ls -1)" -- $cur ) )
+  fi
+}
+
+complete -F _cell-opts cell
+
+
+# Tab completion settings for onos-create-app.
+function _ocapp-opts () {
+  local cur=${COMP_WORDS[COMP_CWORD]}
+  if [ $COMP_CWORD -eq 1 ]; then
+    COMPREPLY=( $( compgen -W "bundle ui cli" -- $cur ) )
+  fi
+}
+
+complete -F _ocapp-opts onos-create-app
diff --git a/tools/test/bin/onos-check-bits b/tools/test/bin/onos-check-bits
index 0cf5fe5..0423c34 100755
--- a/tools/test/bin/onos-check-bits
+++ b/tools/test/bin/onos-check-bits
@@ -6,4 +6,4 @@
 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
 . $ONOS_ROOT/tools/build/envDefaults
 
-test -f $ONOS_TAR
+ls -l $ONOS_TAR && cksum $ONOS_TAR
diff --git a/tools/test/bin/onos-check-components b/tools/test/bin/onos-check-components
index 38fb9a3..f4c2df2 100755
--- a/tools/test/bin/onos-check-components
+++ b/tools/test/bin/onos-check-components
@@ -8,4 +8,10 @@
 
 onos ${1:-$OCI} scr:list > $aux
 cat $aux
-grep -q UNSATISFIED $aux && exit 1 || exit 0
+grep -q UNSATISFIED $aux && exit 1
+
+if [ -n "$2" ]; then
+    echo "Searching for ACTIVE $2"
+    egrep "ACTIVE.*$2" $aux || exit 1
+fi
+exit 0
\ No newline at end of file
diff --git a/tools/test/bin/stc b/tools/test/bin/stc
index 9dfa38f..fd201b6 100755
--- a/tools/test/bin/stc
+++ b/tools/test/bin/stc
@@ -3,11 +3,14 @@
 #   System Test Coordinator
 #-------------------------------------------------------------------------------
 
-STC_ROOT=${STC_ROOT:-$(dirname $0)/..}
-cd $STC_ROOT
 VER=1.2.0-SNAPSHOT
+JAR=~/.m2/repository/org/onosproject/onlab-stc/$VER/onlab-stc-$VER.jar
+SCENARIOS=$ONOS_ROOT/tools/test/scenarios
 
-PATH=$PWD/bin:$PATH
+scenario=${1:-smoke}
 
-java -jar ~/.m2/repository/org/onosproject/onlab-stc/$VER/onlab-stc-$VER.jar \
-    "${@:-$ONOS_ROOT/tools/test/scenarios/smoke.xml}"
+[ ! -f $scenario ] && scenario=$SCENARIOS/$scenario
+[ ! -f $scenario ] && scenario=$scenario.xml
+[ ! -f $scenario ] && echo "Scenario $scenario file not found" && exit 1
+
+java -jar $JAR $scenario
diff --git a/tools/test/bin/stc-launcher b/tools/test/bin/stc-launcher
index 3ef661e..d5da4f1 100755
--- a/tools/test/bin/stc-launcher
+++ b/tools/test/bin/stc-launcher
@@ -2,4 +2,22 @@
 #-------------------------------------------------------------------------------
 #   System Test Coordinator process launcher
 #-------------------------------------------------------------------------------
+
+env=$1 && shift
+cwd=$1 && shift
+
+if [ $env != "-" -a $env != "~" ]; then
+    [ ! -f $env ] && echo "$env file not found" && exit 1
+    source $env
+fi
+
+if [ $cwd != "-" ]; then
+    [ ! -d $cwd ] && echo "$cwd directory not found" && exit 1
+    cd $cwd
+fi
+
 "$@" 2>&1
+status=$?
+
+[ $env != "~" ] && exit $status
+exit 0