CI script corrections. accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix tizen_5.5_tv accepted/tizen/5.5/unified/20191031.004626 accepted/tizen/5.5/unified/mobile/hotfix/20201027.061021 accepted/tizen/unified/20191015.012051 submit/tizen/20191014.221258 submit/tizen_5.5/20191031.000009 submit/tizen_5.5_mobile_hotfix/20201026.1851010 submit/tizen_5.5_mobile_hotfix/20201027.114301 tizen_5.5.m2_release
authorMikhail Kurinnoi <m.kurinnoi@samsung.net>
Fri, 11 Oct 2019 13:18:02 +0000 (16:18 +0300)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Mon, 14 Oct 2019 21:59:56 +0000 (06:59 +0900)
test-suite/sdb_run_tests.sh

index f2e7769939ed4a9d23968bc67333cd3633b1d91b..3de3753157b1509d8e5c501ed3fb70527378ff46 100755 (executable)
@@ -1,5 +1,21 @@
 #!/bin/bash
 
+print_help()
+{
+    echo "Usage: sdb_run_tests.sh [OPTION]... [TEST NAME]..."
+    echo "Run functional tests on Tizen target device."
+    echo ""
+    echo "  -s, --sdb         sdb binary, \"sdb\" by default"
+    echo "  -p, --port        local tcp port, \"4712\" by default"
+    echo "  -d, --dotnet      dotnet binary, \"dotnet\" by default"
+    echo "      --repeat      repeat tests, \"1\" by default"
+    echo "  -g, --gbsroot     path to GBS root folder, \"\$HOME/GBS-ROOT\" by default"
+    echo "  -p, --tools_path  path to tools dir on target,"
+    echo "                    \"/home/owner/share/tmp/sdk_tools\" by default"
+    echo "  -r, --rpm         path to netcordbg rmp file"
+    echo "      --help        display this help and exit"
+}
+
 ALL_TEST_NAMES=(
     "MIExampleTest"
     "MITestBreakpoint"
@@ -27,30 +43,72 @@ ALL_TEST_NAMES=(
     "VSCodeTestStepping"
 )
 
+SDB=${SDB:-sdb}
+PORT=${PORT:-4712}
+DOTNET=${DOTNET:-dotnet}
+REPEAT=${REPEAT:-1}
+GBSROOT=${GBSROOT:-$HOME/GBS-ROOT}
+TOOLS_ABS_PATH=${TOOLS_ABS_PATH:-/home/owner/share/tmp/sdk_tools}
+SCRIPTDIR=$(dirname $(readlink -f $0))
+
+for i in "$@"
+do
+case $i in
+    -s=*|--sdb=*)
+    SDB="${i#*=}"
+    shift
+    ;;
+    -p=*|--port=*)
+    PORT="${i#*=}"
+    shift
+    ;;
+    -d=*|--dotnet=*)
+    DOTNET="${i#*=}"
+    shift
+    ;;
+    --repeat=*)
+    REPEAT="${i#*=}"
+    shift
+    ;;
+    -g=*|--gbsroot=*)
+    GBSROOT="${i#*=}"
+    shift
+    ;;
+    -p=*|--tools_path=*)
+    TOOLS_ABS_PATH="${i#*=}"
+    shift
+    ;;
+    -r=*|--rpm=*)
+    RPMFILE="${i#*=}"
+    shift
+    ;;
+    -h|--help)
+    print_help
+    exit 0
+    ;;
+    *)
+        TEST_NAMES="$TEST_NAMES *"
+    ;;
+esac
+done
+
 TEST_NAMES="$@"
 
 if [[ -z $TEST_NAMES ]]; then
     TEST_NAMES="${ALL_TEST_NAMES[@]}"
 fi
 
+if [[ -z $RPMFILE ]]; then
+    # Detect target arch
+    if   $SDB shell lscpu | grep -q armv7l;  then ARCH=armv7l;
+    elif $SDB shell lscpu | grep -q aarch64; then ARCH=armv7l;
+    elif $SDB shell lscpu | grep -q i686;    then ARCH=i686;
+    else echo "Unknown target architecture"; exit 1; fi
 
-SDB=${SDB:-sdb}
-
-GBSROOT=$HOME/GBS-ROOT
-TOOLS_ABS_PATH=/home/owner/share/tmp/sdk_tools
-
-SCRIPTDIR=$(dirname $(readlink -f $0))
-
-# Detect target arch
-
-if   $SDB shell lscpu | grep -q armv7l;  then ARCH=armv7l;
-elif $SDB shell lscpu | grep -q aarch64; then ARCH=armv7l;
-elif $SDB shell lscpu | grep -q i686;    then ARCH=i686;
-else echo "Unknown target architecture"; exit 1; fi
-
-# The following command assumes that GBS build was performed on a clean system (or in Docker),
-# which means only one such file exists.
-RPMFILE=$(find $GBSROOT/local/repos/ -type f -name netcoredbg-[0-9]\*$ARCH.rpm -print -quit)
+    # The following command assumes that GBS build was performed on a clean system (or in Docker),
+    # which means only one such file exists.
+    RPMFILE=$(find $GBSROOT/local/repos/ -type f -name netcoredbg-[0-9]\*$ARCH.rpm -print -quit)
+fi
 
 # Repackage RPM file as TGZ
 
@@ -70,7 +128,6 @@ cd ..
 
 REMOTETESTDIR=$TOOLS_ABS_PATH/netcoredbg-tests
 
-$SDB root on
 $SDB shell rm -rf "$TOOLS_ABS_PATH/netcoredbg"
 $SDB shell mkdir -p $TOOLS_ABS_PATH/on-demand
 $SDB push $TARGZNAME $TOOLS_ABS_PATH/on-demand
@@ -81,18 +138,20 @@ $SDB shell mkdir $REMOTETESTDIR
 NETCOREDBG=$TOOLS_ABS_PATH/netcoredbg/netcoredbg
 
 # Prepare
-dotnet build $SCRIPTDIR/TestRunner
-sdb forward tcp:4712 tcp:4711
+$DOTNET build $SCRIPTDIR/TestRunner
+$SDB forward --remove tcp:$PORT
+$SDB forward tcp:$PORT tcp:4711
 
 test_pass=0
 test_fail=0
 test_list=""
 
+for i in $(eval echo {1..$REPEAT}); do
 # Build, push and run tests
 for TEST_NAME in $TEST_NAMES; do
     HOSTTESTDIR=$SCRIPTDIR/$TEST_NAME
-    dotnet build $HOSTTESTDIR
-    sdb push $HOSTTESTDIR/bin/Debug/netcoreapp2.1/$TEST_NAME.{dll,pdb} $REMOTETESTDIR
+    $DOTNET build $HOSTTESTDIR
+    $SDB push $HOSTTESTDIR/bin/Debug/netcoreapp2.1/$TEST_NAME.{dll,pdb} $REMOTETESTDIR
 
     SOURCE_FILES=$(find $HOSTTESTDIR \! -path "$HOSTTESTDIR/obj/*" -type f -name "*.cs" -printf '%p;')
 
@@ -101,11 +160,13 @@ for TEST_NAME in $TEST_NAMES; do
         PROTO="vscode"
 
         # change $HOME to $REMOTETESTDIR in order to prevent /root/nohup.out creation
-        sdb shell HOME=$REMOTETESTDIR nohup $NETCOREDBG --server --interpreter=$PROTO -- \
-            /usr/bin/dotnet-launcher $REMOTETESTDIR/$TEST_NAME.dll
+        $SDB root on
+        $SDB shell HOME=$REMOTETESTDIR nohup $NETCOREDBG --server --interpreter=$PROTO -- \
+             /usr/bin/dotnet-launcher $REMOTETESTDIR/$TEST_NAME.dll
+        $SDB root off
 
-        dotnet run --project TestRunner -- \
-            --tcp localhost 4712 \
+        $DOTNET run --project TestRunner -- \
+            --tcp localhost $PORT \
             --proto $PROTO \
             --test $TEST_NAME \
             --sources $SOURCE_FILES
@@ -113,10 +174,12 @@ for TEST_NAME in $TEST_NAMES; do
         PROTO="mi"
 
         # change $HOME to /tmp in order to prevent /root/nohup.out creation
-        sdb shell HOME=$REMOTETESTDIR nohup $NETCOREDBG --server --interpreter=$PROTO
+        $SDB root on
+        $SDB shell HOME=$REMOTETESTDIR nohup $NETCOREDBG --server --interpreter=$PROTO
+        $SDB root off
 
-        dotnet run --project TestRunner -- \
-            --tcp localhost 4712 \
+        $DOTNET run --project TestRunner -- \
+            --tcp localhost $PORT \
             --dotnet /usr/bin/dotnet-launcher \
             --proto $PROTO \
             --test $TEST_NAME \
@@ -124,7 +187,6 @@ for TEST_NAME in $TEST_NAMES; do
             --assembly $REMOTETESTDIR/$TEST_NAME.dll
     fi
 
-
     if [ "$?" -ne "0" ]; then
         test_fail=$(($test_fail + 1))
         test_list="$test_list$TEST_NAME ... failed\n"
@@ -133,10 +195,10 @@ for TEST_NAME in $TEST_NAMES; do
         test_list="$test_list$TEST_NAME ... passed\n"
     fi
 done
-
-# Leave
-sdb root off
+done # REPEAT
 
 echo ""
 echo -e $test_list
 echo "Total tests: $(($test_pass + $test_fail)). Passed: $test_pass. Failed: $test_fail."
+
+exit $test_fail