4 * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@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.
21 #ifndef __UTIL_COMMON_H__
22 #define __UTIL_COMMON_H__
25 * Generate default TC for no-additional-parameter type API
27 * - positive case ('utc_' prefix)
30 * check user_data validation in callback
31 * not check result and data (modem state dependancy)
34 * - negative case ('utc_fail_' prefix)
35 * - invalid handle (NULL)
38 * DO(tel_get_network_band)
40 * struct tet_testlist tet_testlist[] = {
42 * { utc_tel_get_network_band, 1 },
43 * { utc_fail_tel_get_network_band, 1 },
49 static void on_##func (TapiHandle *handle, int result, void *data, void *user_data) \
51 int *value = user_data; \
53 async_flag = ASYNC_DONE; \
56 if (*value != 0xC0FFEE) { \
57 dts_fail(#func, "Callback userdata crashed"); \
62 static void utc_##func (void) \
65 int value = 0xC0FFEE; \
70 async_flag = ASYNC_READY; \
71 ret = func (handle, on_##func, &value); \
72 if (ret != TAPI_API_SUCCESS) { \
73 dts_fail(#func, "Unexpected return"); \
79 if (async_flag != ASYNC_DONE) { \
80 dts_fail(#func, "Callback not invoked"); \
83 /* without callback */ \
84 ret = func (handle, NULL, NULL); \
85 if (ret != TAPI_API_SUCCESS) { \
86 dts_fail(#func, "Unexpected return"); \
93 static void utc_fail_##func (void) \
97 ret = func (NULL, NULL, NULL); \
98 dts_check_ne(#func, ret, TAPI_API_SUCCESS, "Unexpected return"); \
106 void util_init_loop ();
107 void util_free_loop ();
109 void util_start_loop ();
110 void util_stop_loop ();