2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include "test_main.h"
23 #include "test_debug.h"
24 #include "test_query.h"
26 int _print_errors(int argc, char **argv)
28 DBG("CONTACTS_ERROR_NONE (%d)", CONTACTS_ERROR_NONE);
29 DBG("CONTACTS_ERROR_OUT_OF_MEMORY (%d)", CONTACTS_ERROR_OUT_OF_MEMORY);
30 DBG("CONTACTS_ERROR_INVALID_PARAMETER (%d)", CONTACTS_ERROR_INVALID_PARAMETER);
31 DBG("CONTACTS_ERROR_FILE_NO_SPACE (%d)", CONTACTS_ERROR_FILE_NO_SPACE);
32 DBG("CONTACTS_ERROR_PERMISSION_DENIED (%d)", CONTACTS_ERROR_PERMISSION_DENIED);
33 DBG("CONTACTS_ERROR_NOT_SUPPORTED (%d)", CONTACTS_ERROR_NOT_SUPPORTED);
34 DBG("CONTACTS_ERROR_NO_DATA (%d)", CONTACTS_ERROR_NO_DATA);
35 DBG("CONTACTS_ERROR_DB_LOCKED (%d)", CONTACTS_ERROR_DB_LOCKED);
36 DBG("CONTACTS_ERROR_DB (%d)", CONTACTS_ERROR_DB);
37 DBG("CONTACTS_ERROR_IPC_NOT_AVALIABLE (%d)", CONTACTS_ERROR_IPC_NOT_AVALIABLE);
38 DBG("CONTACTS_ERROR_IPC (%d)", CONTACTS_ERROR_IPC);
39 DBG("CONTACTS_ERROR_SYSTEM (%d)", CONTACTS_ERROR_SYSTEM);
40 DBG("CONTACTS_ERROR_INTERNAL (%d)", CONTACTS_ERROR_INTERNAL);
45 static const func _func[] = {
50 bool test_main_is_selected(int argc, char **argv, int depth, const func test_func[], int count)
55 int select = atoi(argv[depth]);
57 if (0 <= select && select < count)
58 test_func[select](argc, argv);
60 ERR("no test func (%d)", select);
66 * With no argument, all cases are tested.
67 * If argument, specific case could be tested.
68 * ex> to test all cases,
69 * # /usr/bin/calendar-service-test
71 * # /usr/bin/calendar-service-test 4
73 * NOTICE: each case could be tested independently.
74 * create resource -> test -> delete resource.
77 int main(int argc, char **argv)
81 DBG("argc(%d)", argc);
83 int count = sizeof(_func) / sizeof(func);
84 if (true == test_main_is_selected(argc, argv, 1, _func, count))
88 for (i = 0; i < count; i++) {
89 if (_func[i](argc, argv) < 0)