tizen 2.3 release
[framework/web/wearable/wrt-security.git] / tests / geolocation_security / wrt-tests-security-geolocation.sh
1 #/bin/sh
2
3 TEST_RESULT_DIR=
4 TEST_TYPE="text"
5
6 while getopts "o:d:" opts
7 do
8     case "$opts" in
9         d)  echo "Output directory: $OPTARG"
10             TEST_RESULT_DIR="$OPTARG" ;;
11         o)  echo "Output type: $OPTARG"
12             TEST_TYPE="$OPTARG" ;;
13         [?])echo "Usage $0 [-o output_type] [-d output_directory]"
14             exit 1;;
15     esac
16 done
17
18 result=`rpm -qa | grep wrt-extra`
19 if [ -z "$result" ]; then
20     echo "You must install wrt-extra before run this script";
21     exit;
22 fi
23
24 export DPL_USE_OLD_STYLE_LOGS=0
25 export DPL_TEST_OUTPUT="$TEST_TYPE"
26
27 wrt_reset_all.sh
28 if [ -e /usr/etc/ace/WAC2.0Policy.back ]; then
29     echo "Policy backup already exists";
30 else
31     mv /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.back
32 fi
33
34 echo "Set up policy file"
35 cp /usr/etc/ace/GeolocationPolicyTest1 /usr/etc/ace/WAC2.0Policy.xml
36
37 echo "Reset policy settings in daemon"
38 wrt_security_change_policy.sh
39
40 function move_result(){
41     source=`pwd`
42     echo "Function move_resutl. Source: $source"
43     if [ "x$TEST_RESULT_DIR" = "x" ]; then
44         return
45     fi
46
47     if [ "x$TEST_TYPE" != "x" ]; then
48         echo "Move: mv results.xml $TEST_RESULT_DIR/$1.$TEST_TYPE"
49         mv results.xml "$TEST_RESULT_DIR/$1.$TEST_TYPE"
50     fi
51 }
52
53 function run_widget(){
54     uid=`echo $1 | awk -F ": " '{print $2}'`
55     if echo $uid | egrep -q '^[0-9]+$'; then
56         echo "Second widget id: $uid"
57         DPL_TEST_OUTPUT=text wrt-client -l $uid
58     else
59         echo "Result: $1"
60     fi
61     move_result "geolocation_$1"
62 }
63
64 echo "Widget installation"
65 result1=`wrt-installer -if /opt/apps/widget/tests/geolocation/geolocationSecurityTest1.wgt`
66 result2=`wrt-installer -if /opt/apps/widget/tests/geolocation/geolocationSecurityTest2.wgt`
67
68 run_widget "$result1"
69
70 echo "Set up policy file"
71 cp /usr/etc/ace/GeolocationPolicyTest2 /usr/etc/WAC2.0Policy.xml
72 echo "Reset policy setting in daemon."
73 wrt_security_change_policy.sh
74
75 run_widget "$result2"
76
77 echo "Restore original policy"
78 cp /usr/etc/ace/WAC2.0Policy.back /usr/etc/ace/WAC2.0Policy.xml
79 echo "Reset policy settings in daemon"
80 wrt_security_change_policy.sh
81
82