3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include <sync_agent.h>
23 POSITIVE_TC_IDX = 0x01,
27 static void startup(void);
28 static void cleanup(void);
30 void (*tet_startup) (void) = startup;
31 void (*tet_cleanup) (void) = cleanup;
33 #define TEST_FW_CONFIG_FILE "../../../testcase/fw-test-cfg/test_fw_config.xml"
35 #define API_NAME_SYNC_START_UP "startup"
37 #define API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT "sync_agent_alloc_param_spec_int"
38 #define API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE "sync_agent_alloc_param_spec_structure"
40 #define API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE "sync_agent_create_queuing_rule_spec_outline"
41 #define API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT "sync_agent_add_progress_blocking_element"
43 #define API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC "sync_agent_alloc_simple_task_spec"
45 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p(void);
46 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n(void);
47 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p(void);
48 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n(void);
49 static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p(void);
50 static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n(void);
51 static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p(void);
52 static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n(void);
53 static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p(void);
54 static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n(void);
56 struct tet_testlist tet_testlist[] = {
57 {utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p, POSITIVE_TC_IDX},
58 {utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n, NEGATIVE_TC_IDX},
59 {utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p, POSITIVE_TC_IDX},
60 {utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n, NEGATIVE_TC_IDX},
62 {utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p, POSITIVE_TC_IDX},
63 {utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n, NEGATIVE_TC_IDX},
64 {utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p, POSITIVE_TC_IDX},
65 {utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n, NEGATIVE_TC_IDX},
67 {utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p, POSITIVE_TC_IDX},
68 {utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n, NEGATIVE_TC_IDX},
73 #define EC_MSG_TYPE_SIMPLE_TASK 1
74 #define EC_MSG_TYPE_NAME_SIMPLE_TASK "simple_task"
76 sync_agent_ec_task_error_e simple_task(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
79 return SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
82 static void startup(void)
85 sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
86 if (init_error != SYNC_AGENT_INIT_SUCCESS) {
87 dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
88 dts_fail(API_NAME_SYNC_START_UP);
90 dts_pass(API_NAME_SYNC_START_UP);
94 static void cleanup(void)
99 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_p(void)
101 char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT;
102 sync_agent_ec_param_spec_s *param_spec = NULL;
104 param_spec = sync_agent_alloc_param_spec_int("param_int", true, false, false, 0, 0, false, 0, false, 0, 0);
105 if (param_spec != NULL) {
108 dts_message(api_name, "sync_agent_alloc_param_spec_int");
113 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_int_n(void)
115 char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_INT;
116 sync_agent_ec_param_spec_s *param_spec = NULL;
118 param_spec = sync_agent_alloc_param_spec_int(NULL, true, false, false, 0, 0, false, 0, false, 0, 0);
119 if (param_spec == NULL) {
122 dts_message(api_name, "sync_agent_alloc_param_spec_int");
127 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_p(void)
129 char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE;
130 sync_agent_ec_param_spec_s *param_spec = NULL;
132 param_spec = sync_agent_alloc_param_spec_structure("param_struct", NULL, NULL, true, false, false, NULL, false, NULL, false, NULL);
133 if (param_spec != NULL) {
136 dts_message(api_name, "sync_agent_alloc_param_spec_structure");
141 static void utc_sync_agent_framework_sync_agent_alloc_param_spec_structure_n(void)
143 char *api_name = API_NAME_SYNC_AGENT_ALLOC_PARAM_SPEC_STRUCTURE;
144 sync_agent_ec_param_spec_s *param_spec = NULL;
146 param_spec = sync_agent_alloc_param_spec_structure(NULL, NULL, NULL, true, false, false, NULL, false, NULL, false, NULL);
147 if (param_spec == NULL) {
150 dts_message(api_name, "sync_agent_alloc_param_spec_structure");
155 static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_p(void)
157 char *api_name = API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE;
158 sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
160 queuing_rule = sync_agent_create_queuing_rule_spec_outline("queuing_rule_name");
161 if (queuing_rule != NULL) {
164 dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
169 static void utc_sync_agent_framework_sync_agent_create_queuing_rule_spec_outline_n(void)
171 char *api_name = API_NAME_SYNC_AGENT_CREATE_QUEUING_RULE_SPEC_OUTLINE;
172 sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
174 queuing_rule = sync_agent_create_queuing_rule_spec_outline(NULL);
175 if (queuing_rule == NULL) {
178 dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
183 static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_p(void)
185 char *api_name = API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT;
186 sync_agent_ec_error_e ec_err = SYNC_AGENT_EC_OK;
187 sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
188 sync_agent_ec_task_spec_s *task_spec = NULL;
190 sync_agent_ec_param_spec_s *param_spec = sync_agent_alloc_param_spec_int("param", true, false, false, 0, 0, false, 0, false, 0, 0);
191 if (param_spec == NULL) {
192 dts_message(api_name, "sync_agent_alloc_param_spec_int");
196 sync_agent_ec_param_spec_s *param_spec_array[1] = { param_spec };
198 task_spec = sync_agent_alloc_simple_task_spec("simple_task", simple_task, NULL, NULL, 1, param_spec_array);
199 if (task_spec == NULL) {
200 dts_message(api_name, "sync_agent_alloc_simple_task_spec");
204 sync_agent_unref_param_spec(param_spec);
206 queuing_rule = sync_agent_create_queuing_rule_spec_outline("queuing_rule_name");
207 if (queuing_rule == NULL) {
208 dts_message(api_name, "sync_agent_create_queuing_rule_spec_outline");
212 ec_err = sync_agent_add_progress_blocking_element(queuing_rule, EC_MSG_TYPE_SIMPLE_TASK, task_spec, 0);
213 if (ec_err == SYNC_AGENT_EC_OK) {
216 dts_message(api_name, "sync_agent_add_progress_blocking_element");
221 static void utc_sync_agent_framework_sync_agent_add_progress_blocking_element_n(void)
223 char *api_name = API_NAME_SYNC_AGENT_ADD_PROGRESS_BLOCKING_ELEMENT;
224 sync_agent_ec_error_e ec_err = SYNC_AGENT_EC_OK;
225 sync_agent_ec_queuing_rule_spec_s *queuing_rule = NULL;
226 sync_agent_ec_task_spec_s *task_spec = NULL;
228 ec_err = sync_agent_add_progress_blocking_element(queuing_rule, EC_MSG_TYPE_SIMPLE_TASK, task_spec, 0);
229 if (ec_err != SYNC_AGENT_EC_OK) {
232 dts_message(api_name, "sync_agent_add_progress_blocking_element");
237 static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_p(void)
239 char *api_name = API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC;
240 sync_agent_ec_task_spec_s *task_spec = NULL;
242 sync_agent_ec_param_spec_s *param_spec = sync_agent_alloc_param_spec_int("param", true, false, false, 0, 0, false, 0, false, 0, 0);
243 if (param_spec == NULL) {
244 dts_message(api_name, "sync_agent_alloc_param_spec_int");
248 sync_agent_ec_param_spec_s *param_spec_array[1] = { param_spec };
250 task_spec = sync_agent_alloc_simple_task_spec("simple_task", simple_task, NULL, NULL, 1, param_spec_array);
251 if (task_spec != NULL) {
254 dts_message(api_name, "sync_agent_alloc_simple_task_spec");
259 static void utc_sync_agent_framework_sync_agent_alloc_simple_task_spec_n(void)
261 char *api_name = API_NAME_SYNC_AGENT_ALLOC_SIMPLE_TASK_SPEC;
262 sync_agent_ec_task_spec_s *task_spec = NULL;
264 task_spec = sync_agent_alloc_simple_task_spec(NULL, NULL, NULL, NULL, 1, NULL);
265 if (task_spec == NULL) {
268 dts_message(api_name, "sync_agent_alloc_simple_task_spec");