[AudioManager] Changed handle type to marshal from unmanaged (#1027)
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / test.sh
1 #!/bin/bash
2
3 TARGET_USER=owner
4 TARGET_DIR=/home/$TARGET_USER/elmsharp_test
5 TARGET_RES_DIR=$TARGET_DIR/res
6
7 TO_COPY_FILES="bin/Debug"
8
9 exit_on_error() {
10   if [ $1 -ne "0" ]
11   then
12     exit $1
13   fi
14 }
15
16 sdb_cmd() {
17   sdb shell su -l $TARGET_USER -c "$1"
18 }
19
20 usage() {
21   echo "Usage: $0 [options] [testcase]"
22   echo "    Options:"
23   echo "        -h, --help         Show this usages message"
24   echo "        -i, --install      Install test cases to target device"
25   echo "        -r, --install-res  Install resource files for test cases to target device"
26   echo "        -m, --use-mono     Execute test case by using mono instead of corerun"
27 }
28
29 install() {
30   echo "install"
31   sdb root on
32   sdb_cmd "rm -fr $TARGET_DIR"
33   sdb_cmd "mkdir -p $TARGET_DIR"
34   sdb push $TO_COPY_FILES/Tizen*.dll $TARGET_DIR
35   sdb push $TO_COPY_FILES/ElmSharp*.dll $TARGET_DIR
36   sdb push $TO_COPY_FILES/ElmSharp*.exe $TARGET_DIR
37   exit_on_error $?
38 }
39
40 install_res() {
41   sdb root on
42   sdb_cmd "rm -fr $TARGET_RES_DIR"
43   sdb_cmd "mkdir -p $TARGET_RES_DIR"
44   sdb push $TO_COPY_FILES/res $TARGET_RES_DIR
45   exit_on_error $?
46 }
47
48 run() {
49   sdb root on
50   sdb_cmd "/usr/share/tizen.net/corerun $TARGET_DIR/ElmSharp.Test.exe $1"
51   exit_on_error $?
52 }
53
54 run_mono() {
55   sdb root on
56   sdb_cmd "MONO_TRACE_LISTENER=Console.Error mono $TARGET_DIR/ElmSharp.Test.exe $1"
57   exit_on_error $?
58 }
59
60 OPTS=`getopt -o hirm --long help,install,install-res,use-mono -n 'test' -- "$@"`
61 if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; usage; exit 1 ; fi
62 eval set -- "$OPTS"
63
64 FLAG_HELP=false
65 FLAG_INSTALL=false
66 FLAG_INSTALL_RES=false
67 FLAG_USE_MONO=false
68
69 while true; do
70   case "$1" in
71     -h|--help) FLAG_HELP=true; shift ;;
72     -i|--install) FLAG_INSTALL=true; shift ;;
73     -r|--install-res) FLAG_INSTALL_RES=true; shift ;;
74     -m|--use-mono) FLAG_USE_MONO=true; shift ;;
75     --) shift; break ;;
76     *) break ;;
77   esac
78 done
79
80 if $FLAG_HELP; then usage; exit 1; fi
81
82 if $FLAG_INSTALL; then install; fi
83 if $FLAG_INSTALL_RES; then install_res; fi
84 if $FLAG_USE_MONO; then run_mono $@; else run $@; fi