6 while getopts "o:d:" opts
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]"
18 result=`rpm -qa | grep wrt-extra`
19 if [ -z "$result" ]; then
20 echo "You must install wrt-extra before run this script";
24 export DPL_USE_OLD_STYLE_LOGS=0
25 export DPL_TEST_OUTPUT="$TEST_TYPE"
30 if [ $status -eq 0 ]; then
31 echo -e "\033[32m$text \033[0m [ \033[32mDONE\033[0m ] ";
33 echo -e "\033[32m$text \033[0m [ \033[31mFAIL\033[0m ] ";
39 echo -e "\031[32m$text\033[0m] ";
42 function set_up_env(){
44 if [ -e /usr/etc/ace/WAC2.0Policy.back ]; then
45 error_msg "Policy backup already exists";
47 mv /usr/etc/ace/WAC2.0Policy.xml /usr/etc/ace/WAC2.0Policy.back
48 task_info "Create policy backup" $?
51 cp /usr/etc/ace/PermitAllPolicy.xml /usr/etc/ace/WAC2.0Policy.xml
52 task_info "Set up test policy file" $?
54 wrt_security_change_policy.sh
55 task_info "Reset policy settings in daemon" $?
58 function set_up_nodevcap_env(){
59 if [ -d /tmp/smack.back ]; then
60 error_msg "Backup directory with smack files already exists.";
62 mkdir -p /tmp/smack.back
63 cp /usr/share/privilege-control/*.smack /tmp/smack.back/
64 task_info "Create smack files backup" $?
65 echo -n > /usr/share/privilege-control/accelerometer.smack
66 echo -n > /usr/share/privilege-control/filesystem.read.smack
67 echo -n > /usr/share/privilege-control/filesystem.write.smack
68 echo -n > /usr/share/privilege-control/orientation.smack
69 echo -n > /usr/share/privilege-control/pim.calendar.read.smack
70 echo -n > /usr/share/privilege-control/pim.calendar.write.smack
71 echo -n > /usr/share/privilege-control/pim.contact.read.smack
72 echo -n > /usr/share/privilege-control/pim.contact.write.smack
73 echo -n > /usr/share/privilege-control/pim.task.read.smack
74 echo -n > /usr/share/privilege-control/pim.task.write.smack
75 task_info "Replace smack files with empty one..." $?
79 function move_result(){
81 echo "Function move_resutl. Source: $source"
82 if [ "x$TEST_RESULT_DIR" = "x" ]; then
86 if [ "x$TEST_TYPE" != "x" ]; then
87 echo "Move: mv results.xml $TEST_RESULT_DIR/$1.$TEST_TYPE"
88 mv results.xml "$TEST_RESULT_DIR/$1.$TEST_TYPE"
92 function run_widget(){
94 uid=`echo $1 | awk -F ": " '{print $2}'`
95 if echo $uid | egrep -q '^[0-9]+$'; then
96 echo "First widget id: $uid"
99 echo "wrt-client exit with code $result_code";
103 move_result "smack_$uid"
106 function run_widget_nosmack(){
108 uid=`echo $1 | awk -F ": " '{print $2}'`
109 if echo $uid | egrep -q '^[0-9]+$'; then
110 echo "First widget id: $uid"
113 echo "wrt-client exit with code $result_code";
114 if [ $result_code -eq 139 ]; then
115 echo "Widget ended with crash (as expected) [ OK ]";
120 move_result "nosmack_$uid"
123 function restore_env(){
124 cp /usr/etc/ace/WAC2.0Policy.back /usr/etc/ace/WAC2.0Policy.xml && rm /usr/etc/ace/WAC2.0Policy.back
125 task_info "Restore policy file and remove backup copy" $?
126 cp /tmp/smack.back/* /usr/share/privilege-control/ && rm /tmp/smack.back -rf
127 task_info "Restore smack file and remove backup copy" $?
128 wrt_security_change_policy.sh
129 task_info "Reset policy settings in daemon" $?
132 if [ "x$1" = "xfix" ]; then
133 echo "I will try to restore evironment";
140 echo "Widget installation"
141 result0=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity0.wgt`
142 task_info "Widget smacksecurity0.wgt installed" $?
143 result1=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity1.wgt`
144 task_info "Widget smacksecurity1.wgt installed" $?
145 result2=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity2.wgt`
146 task_info "Widget smacksecurity2.wgt installed" $?
147 result3=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity3.wgt`
148 task_info "Widget smacksecurity3.wgt installed" $?
149 result4=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity4.wgt`
150 task_info "Widget smacksecurity4.wgt installed" $?
151 result5=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity5.wgt`
152 task_info "Widget smacksecurity5.wgt installed" $?
153 result6=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity6.wgt`
154 task_info "Widget smacksecurity6.wgt installed" $?
155 result7=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity7.wgt`
156 task_info "Widget smacksecurity7.wgt installed" $?
157 result8=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity8.wgt`
158 task_info "Widget smacksecurity8.wgt installed" $?
159 result9=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity9.wgt`
160 task_info "Widget smacksecurity9.wgt installed" $?
161 result10=`wrt-installer -if /opt/apps/widget/tests/smack/smacksecurity10.wgt`
162 task_info "Widget smacksecurity10.wgt installed" $?
164 echo "**************************************************"
165 echo "**************** Start tests *********************"
166 echo "**************************************************"
168 run_widget "$result0"
172 run_widget_nosmack "$result1"
173 run_widget_nosmack "$result2"
174 run_widget_nosmack "$result3"
175 run_widget_nosmack "$result4"
176 run_widget_nosmack "$result5"
177 run_widget_nosmack "$result6"
178 run_widget_nosmack "$result7"
179 run_widget_nosmack "$result8"
180 run_widget_nosmack "$result9"
181 run_widget_nosmack "$result10"