4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
38 typedef struct _test_func_t{
45 void __set_bundle_from_args(bundle * kb)
52 char *category = NULL;
56 while( (opt = getopt(gargc,gargv,"d:o:m:u:p:c:")) != -1){
64 mime = strdup(optarg);
72 package = strdup(optarg);
76 category = strdup(optarg);
81 key = strtok(optarg,",");
84 val_array[i] = strtok(NULL,",");
85 if(val_array[i] == NULL)
90 appsvc_add_data(kb, key, val_array[0]);
92 appsvc_add_data_array(kb, key, (const char **)val_array, i);
99 appsvc_set_operation(kb,op);
103 appsvc_set_mime(kb,mime);
107 appsvc_set_uri(kb,uri);
111 appsvc_set_appid(kb,package);
115 appsvc_set_category(kb,category);
124 kb = bundle_create();
127 printf("bundle creation fail\n");
130 printf("[run_svc test]\n");
132 __set_bundle_from_args(kb);
134 ret = appsvc_run_service(kb,0,NULL, NULL, getuid());
137 printf("open service success\n");
146 printf("open service fail\n");
156 static void prt_recvd_bundle(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
160 size_t *array_item_size;
166 if(bundle_keyval_type_is_array((bundle_keyval_t *)kv) > 0) {
167 bundle_keyval_get_array_val((bundle_keyval_t *)kv,
168 (void ***)&array_val, (unsigned int *)&array_len,
171 for (i=0;i<array_len;i++)
173 printf("recvd - key: %s[%d], value: %s\n", key, i, array_val[i]);
177 bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&val, &size);
178 printf("recvd - key: %s, value: %s\n",key,val);
182 static void cb_func(bundle *kb, int request_code, appsvc_result_val result, void *data)
187 if(result == APPSVC_RES_CANCEL){
188 printf("==== %d : canceled(preemptted) my request ===\n",num);
191 printf("==== %d : result packet === result %d\n",num, (int)result);
192 //bundle_iterate(kb, prt_recvd_bundle, NULL);
194 bundle_foreach(kb, prt_recvd_bundle, NULL);
198 if(strcmp(cmd,"run_svc_res")==0){
199 printf("==== end of appsvc_run() ====\n");
200 ecore_main_loop_quit();
210 kb = bundle_create();
213 printf("bundle creation fail\n");
217 printf("[run_svc_res test]\n");
219 __set_bundle_from_args(kb);
221 ret = appsvc_run_service(kb, 0, cb_func, (void*)num, getuid());
224 printf("open service success\n");
233 printf("open service fail\n");
244 static test_func_t test_func[] = {
247 {"run_svc", run_svc, "run_svc test",
248 "[usage] run_svc -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
249 {"run_svc_res", run_svc_res, "run_svc_res test",
250 "[usage] run_svc_res -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
254 int callfunc(char* testname)
260 for(i=0; i<sizeof(test_func)/sizeof(test_func_t); i++)
263 if(strcmp(testname,tmp->name)==0){
265 if(strcmp(testname,"all")){
267 printf("... test failed\n");
269 printf("... test successs ret = %d\n", res);
277 void print_usage(char* progname)
282 printf("[usage] %s <cmd> ...\n",progname);
283 printf(" - available cmd list\n");
285 for(i=0; i<sizeof(test_func)/sizeof(test_func_t); i++)
288 printf("\t%s : %s\n",tmp->name, tmp->desc);
289 printf("\t\t%s\n",tmp->usage);
295 static Eina_Bool run_func(void *data)
299 if(strcmp(cmd,"run_svc_res") == 0 )
302 ecore_main_loop_quit();
308 int main(int argc, char** argv)
311 print_usage(argv[0]);
320 apn_pid = atoi(argv[2]);
322 aul_launch_init(NULL,NULL);
324 //aul_listen_app_dead_signal(dead_tracker,NULL);
325 //aul_listen_app_dead_signal(NULL,NULL);
327 ecore_idler_add(run_func, NULL);
329 ecore_main_loop_begin();