2 * Copyright (c) 2020 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.
19 #include <gtest/gtest.h>
20 #include <gmock/gmock.h>
25 #include "hal-common.h"
26 #include "hal-common-interface.h"
28 #include "../../src/hal-api-conf.h"
29 #include "../../src/common.h"
35 class CommonHaltest : public testing::Test {
38 virtual ~CommonHaltest() {}
39 virtual void SetUp() {}
40 virtual void TearDown() {}
43 TEST(CommonHaltest, test_symbol_name_invalid_module) {
44 char ret_unknown[MAX_BUFF] = {0, };
45 char ret_end[MAX_BUFF] = {0, };
48 ret = hal_common_get_backend_symbol_name(HAL_MODULE_UNKNOWN, ret_unknown, MAX_BUFF);
49 EXPECT_TRUE(ret != TIZEN_ERROR_NONE);
51 ret = hal_common_get_backend_symbol_name(HAL_MODULE_UNKNOWN, ret_end, MAX_BUFF);
52 EXPECT_TRUE(ret != TIZEN_ERROR_NONE);
55 TEST(CommonHaltest, test_check_backend_abi_version_invalid_parameter) {
58 ret = hal_common_check_backend_abi_version(HAL_MODULE_UNKNOWN, HAL_ABI_VERSION_TIZEN_7_0);
59 EXPECT_EQ(ret, TIZEN_ERROR_INVALID_PARAMETER);
61 ret = hal_common_check_backend_abi_version(HAL_MODULE_END, HAL_ABI_VERSION_TIZEN_7_0);
62 EXPECT_EQ(ret, TIZEN_ERROR_INVALID_PARAMETER);
64 ret = hal_common_check_backend_abi_version(HAL_MODULE_TBM, HAL_ABI_VERSION_UNKNOWN);
65 EXPECT_EQ(ret, TIZEN_ERROR_INVALID_PARAMETER);
67 ret = hal_common_check_backend_abi_version(HAL_MODULE_TBM, HAL_ABI_VERSION_END);
68 EXPECT_EQ(ret, TIZEN_ERROR_INVALID_PARAMETER);
71 TEST(CommonHaltest, get_backend_library_name_unknown) {
72 char ret_name[MAX_BUFF] = {0, };
73 int ret = hal_common_get_backend_library_name(HAL_MODULE_UNKNOWN, ret_name, MAX_BUFF);
74 EXPECT_TRUE(ret != TIZEN_ERROR_NONE);
79 enum hal_module module_;
80 enum hal_group group_;
81 enum hal_license license_;
82 const char *module_name_;
83 const char *library_name_;
84 const char *library_name_64bit_;
85 const char *symbol_name_;
86 vector<struct hal_abi_version_match> versions_;
88 HalInfo(enum hal_module module, enum hal_group group, enum hal_license license,
89 const char *module_name, const char *library_name, const char *library_name_64bit,
90 const char *symbol_name, vector<struct hal_abi_version_match> versions) :
91 module_(module), group_(group), license_(license),
92 module_name_(module_name), library_name_(library_name),
93 library_name_64bit_(library_name_64bit), symbol_name_(symbol_name),
94 versions_(versions) {}
97 class HalInfoMatchedTest : public ::testing::TestWithParam<HalInfo> {};
99 INSTANTIATE_TEST_CASE_P(CommonHaltest,
102 HalInfo(HAL_MODULE_TBM, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT,
103 "HAL_MODULE_TBM", "/hal/lib/libhal-backend-tbm.so",
104 "/hal/lib64/libhal-backend-tbm.so", "hal_backend_tbm_data",
105 vector<struct hal_abi_version_match>{{
106 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
107 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
111 HalInfo(HAL_MODULE_TDM, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT,
112 "HAL_MODULE_TDM", "/hal/lib/libhal-backend-tdm.so",
113 "/hal/lib64/libhal-backend-tdm.so", "hal_backend_tdm_data",
114 vector<struct hal_abi_version_match>{{
115 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
116 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
120 HalInfo(HAL_MODULE_COREGL, HAL_GROUP_GRAPHICS, HAL_LICENSE_UNKNOWN,
121 "HAL_MODULE_COREGL", "", "", "", {}),
123 HalInfo(HAL_MODULE_INPUT, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT,
124 "HAL_MODULE_INPUT", "", "", "", {}),
126 HalInfo(HAL_MODULE_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
127 "HAL_MODULE_AUDIO", "/hal/lib/libhal-backend-audio.so",
128 "/hal/lib64/libhal-backend-audio.so", "hal_backend_audio_data",
129 vector<struct hal_abi_version_match>{{
130 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
131 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
135 HalInfo(HAL_MODULE_CAMERA, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
136 "HAL_MODULE_CAMERA", "/hal/lib/libhal-backend-camera.so",
137 "/hal/lib64/libhal-backend-camera.so", "hal_backend_camera_data",
138 vector<struct hal_abi_version_match>{{
139 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
140 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
144 HalInfo(HAL_MODULE_RADIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
145 "HAL_MODULE_RADIO", "/hal/lib/libhal-backend-radio.so",
146 "/hal/lib64/libhal-backend-radio.so", "hal_backend_radio_data",
147 vector<struct hal_abi_version_match>{{
148 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
149 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
153 HalInfo(HAL_MODULE_CODEC, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
154 "HAL_MODULE_CODEC", "", "", "", {}),
156 HalInfo(HAL_MODULE_USB_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
157 "HAL_MODULE_USB_AUDIO", "", "", "", {}),
159 HalInfo(HAL_MODULE_ALSAUCM, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0,
160 "HAL_MODULE_ALSAUCM", "", "", "", {}),
162 HalInfo(HAL_MODULE_BLUETOOTH, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
163 "HAL_MODULE_BLUETOOTH", "/hal/lib/libhal-backend-bluetooth.so",
164 "/hal/lib64/libhal-backend-bluetooth.so", "hal_backend_bluetooth_data",
165 vector<struct hal_abi_version_match>{{
166 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
167 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
171 HalInfo(HAL_MODULE_WIFI, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
172 "HAL_MODULE_WIFI", "/hal/lib/libhal-backend-wifi.so",
173 "/hal/lib64/libhal-backend-wifi.so", "hal_backend_wifi_data",
174 vector<struct hal_abi_version_match>{{
175 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
176 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
180 HalInfo(HAL_MODULE_NAN, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
181 "HAL_MODULE_NAN", "", "", "", {}),
183 HalInfo(HAL_MODULE_NFC, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
184 "HAL_MODULE_NFC", "/hal/lib/libhal-backend-nfc.so",
185 "/hal/lib64/libhal-backend-nfc.so", "hal_backend_nfc_data",
186 vector<struct hal_abi_version_match>{{
187 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
188 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
192 HalInfo(HAL_MODULE_ZIGBEE, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
193 "HAL_MODULE_ZIGBEE", "/hal/lib/libhal-backend-zigbee.so",
194 "/hal/lib64/libhal-backend-zigbee.so", "hal_backend_zigbee_data",
195 vector<struct hal_abi_version_match>{{
196 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
197 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
201 HalInfo(HAL_MODULE_UWB, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
202 "HAL_MODULE_UWB", "/hal/lib/libhal-backend-uwb.so",
203 "/hal/lib64/libhal-backend-uwb.so", "hal_backend_uwb_data",
204 vector<struct hal_abi_version_match>{{
205 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
206 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
210 HalInfo(HAL_MODULE_MTP, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0,
211 "HAL_MODULE_MTP", "", "", "", {}),
213 HalInfo(HAL_MODULE_TELEPHONY, HAL_GROUP_TELEPHONY, HAL_LICENSE_APACHE_2_0,
214 "HAL_MODULE_TELEPHONY", "", "", "", {}),
216 HalInfo(HAL_MODULE_LOCATION, HAL_GROUP_LOCATION, HAL_LICENSE_APACHE_2_0,
217 "HAL_MODULE_LOCATION", "/hal/lib/libhal-backend-location.so",
218 "/hal/lib64/libhal-backend-location.so", "hal_backend_location_data",
219 vector<struct hal_abi_version_match>{{
220 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
221 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
225 HalInfo(HAL_MODULE_COMMON, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
226 "HAL_MODULE_COMMON", "", "", "", {}),
228 HalInfo(HAL_MODULE_POWER, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
229 "HAL_MODULE_POWER", "/hal/lib/libhal-backend-power.so",
230 "/hal/lib64/libhal-backend-power.so", "hal_backend_power_data",
231 vector<struct hal_abi_version_match>{{
232 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
233 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
237 HalInfo(HAL_MODULE_SENSOR, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
238 "HAL_MODULE_SENSOR", "/hal/lib/libhal-backend-sensor.so",
239 "/hal/lib64/libhal-backend-sensor.so", "hal_backend_sensor_data",
240 vector<struct hal_abi_version_match>{{
241 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
242 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
246 HalInfo(HAL_MODULE_PERIPHERAL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
247 "HAL_MODULE_PERIPHERAL", "", "", "", {}),
249 HalInfo(HAL_MODULE_DEVICE_BATTERY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
250 "HAL_MODULE_DEVICE_BATTERY", "/hal/lib/libhal-backend-device-battery.so",
251 "/hal/lib64/libhal-backend-device-battery.so", "hal_backend_device_battery_data",
252 vector<struct hal_abi_version_match>{{
253 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
254 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
258 HalInfo(HAL_MODULE_DEVICE_BEZEL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
259 "HAL_MODULE_DEVICE_BEZEL", "/hal/lib/libhal-backend-device-bezel.so",
260 "/hal/lib64/libhal-backend-device-bezel.so", "hal_backend_device_bezel_data",
261 vector<struct hal_abi_version_match>{{
262 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
263 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
267 HalInfo(HAL_MODULE_DEVICE_DISPLAY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
268 "HAL_MODULE_DEVICE_DISPLAY", "/hal/lib/libhal-backend-device-display.so",
269 "/hal/lib64/libhal-backend-device-display.so", "hal_backend_device_display_data",
270 vector<struct hal_abi_version_match>{{
271 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
272 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
276 HalInfo(HAL_MODULE_DEVICE_IR, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
277 "HAL_MODULE_DEVICE_IR", "/hal/lib/libhal-backend-device-ir.so",
278 "/hal/lib64/libhal-backend-device-ir.so", "hal_backend_device_ir_data",
279 vector<struct hal_abi_version_match>{{
280 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
281 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
285 HalInfo(HAL_MODULE_DEVICE_TOUCHSCREEN, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
286 "HAL_MODULE_DEVICE_TOUCHSCREEN", "/hal/lib/libhal-backend-device-touchscreen.so",
287 "/hal/lib64/libhal-backend-device-touchscreen.so", "hal_backend_device_touchscreen_data",
288 vector<struct hal_abi_version_match>{{
289 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
290 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
294 HalInfo(HAL_MODULE_DEVICE_LED, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
295 "HAL_MODULE_DEVICE_LED", "/hal/lib/libhal-backend-device-led.so",
296 "/hal/lib64/libhal-backend-device-led.so", "hal_backend_device_led_data",
297 vector<struct hal_abi_version_match>{{
298 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
299 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
303 HalInfo(HAL_MODULE_DEVICE_BOARD, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
304 "HAL_MODULE_DEVICE_BOARD", "/hal/lib/libhal-backend-device-board.so",
305 "/hal/lib64/libhal-backend-device-board.so", "hal_backend_device_board_data",
306 vector<struct hal_abi_version_match>{{
307 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
308 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
312 HalInfo(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
313 "HAL_MODULE_DEVICE_EXTERNAL_CONNECTION", "/hal/lib/libhal-backend-device-external-connection.so",
314 "/hal/lib64/libhal-backend-device-external-connection.so", "hal_backend_device_external_connection_data",
315 vector<struct hal_abi_version_match>{{
316 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
317 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
321 HalInfo(HAL_MODULE_DEVICE_THERMAL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
322 "HAL_MODULE_DEVICE_THERMAL", "/hal/lib/libhal-backend-device-thermal.so",
323 "/hal/lib64/libhal-backend-device-thermal.so", "hal_backend_device_thermal_data",
324 vector<struct hal_abi_version_match>{{
325 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
326 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
330 HalInfo(HAL_MODULE_DEVICE_USB_GADGET, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
331 "HAL_MODULE_DEVICE_USB_GADGET", "/hal/lib/libhal-backend-device-usb-gadget.so",
332 "/hal/lib64/libhal-backend-device-usb-gadget.so", "hal_backend_device_usb_gadget_data",
333 vector<struct hal_abi_version_match>{{
334 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
335 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
339 HalInfo(HAL_MODULE_DEVICE_HAPTIC, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
340 "HAL_MODULE_DEVICE_HAPTIC", "/hal/lib/libhal-backend-device-haptic.so",
341 "/hal/lib64/libhal-backend-device-haptic.so", "hal_backend_device_haptic_data",
342 vector<struct hal_abi_version_match>{{
343 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
344 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
348 HalInfo(HAL_MODULE_DEVICE_MEMORY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0,
349 "HAL_MODULE_DEVICE_MEMORY", "/hal/lib/libhal-backend-device-memory.so",
350 "/hal/lib64/libhal-backend-device-memory.so", "hal_backend_device_memory_data",
351 vector<struct hal_abi_version_match>{{
352 .platform_abi_version = HAL_ABI_VERSION_TIZEN_7_0,
353 .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5
358 TEST_P(HalInfoMatchedTest, get_backend_library_name) {
359 char ret_library_name[MAX_BUFF] = {0, };
361 auto info = GetParam();
363 ret = hal_common_get_backend_library_name(info.module_, ret_library_name, MAX_BUFF);
364 EXPECT_TRUE(ret == TIZEN_ERROR_NONE);
365 #if defined(__aarch64__)
366 EXPECT_STREQ(info.library_name_64bit_, ret_library_name) << "module name is " << info.module_name_;
368 EXPECT_STREQ(info.library_name_, ret_library_name) << "module name is " << info.module_name_;
372 TEST_P(HalInfoMatchedTest, test_symbol_name_module_matching) {
373 char ret_symbol_name[MAX_BUFF] = {0, };
375 auto info = GetParam();
377 ret = hal_common_get_backend_symbol_name(info.module_, ret_symbol_name, MAX_BUFF);
378 EXPECT_TRUE(ret == TIZEN_ERROR_NONE);
379 EXPECT_STREQ(ret_symbol_name, info.symbol_name_) << "module name is " << info.module_name_;
382 TEST_P(HalInfoMatchedTest, test_group_module_matching) {
383 struct __hal_module_info *info = NULL;
385 auto result_info = GetParam();
387 _hal_api_conf_init();
388 info = _hal_api_conf_get_module_info(result_info.module_, NULL);
389 ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
390 EXPECT_EQ(info->group, result_info.group_) << "module name is " << result_info.module_name_;
391 _hal_api_conf_exit();
394 TEST_P(HalInfoMatchedTest, test_license_module_matching) {
395 struct __hal_module_info *info = NULL;
397 auto result_info = GetParam();
399 _hal_api_conf_init();
400 info = _hal_api_conf_get_module_info(result_info.module_, NULL);
401 ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
402 EXPECT_EQ(info->license, result_info.license_) << "module name is " << result_info.module_name_;
403 _hal_api_conf_exit();
406 TEST_P(HalInfoMatchedTest, test_module_name_matching) {
407 struct __hal_module_info *info = NULL;
409 auto result_info = GetParam();
411 _hal_api_conf_init();
412 info = _hal_api_conf_get_module_info(result_info.module_, NULL);
413 ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
414 EXPECT_STREQ(info->module_name, result_info.module_name_) << "module name is " << result_info.module_name_;
415 _hal_api_conf_exit();
418 TEST_P(HalInfoMatchedTest, test_check_backend_abi_version) {
419 struct __hal_module_info *info = NULL;
420 auto result_info = GetParam();
422 _hal_api_conf_init();
423 info = _hal_api_conf_get_module_info(result_info.module_, NULL);
424 ASSERT_TRUE(info != nullptr);
426 vector<struct hal_abi_version_match> versions = result_info.versions_;
427 struct hal_abi_version_match *meta_versions = info->abi_versions;
429 for (unsigned int i = 0; i < versions.size(); i++) {
430 struct hal_abi_version_match tmp_version = versions[i];
432 int ret = hal_common_check_backend_abi_version(result_info.module_, tmp_version.platform_abi_version);
433 EXPECT_EQ(ret, TIZEN_ERROR_NONE) << "module name is " << result_info.module_name_;
434 EXPECT_EQ(meta_versions[i].platform_abi_version, tmp_version.platform_abi_version) << "module name is " << result_info.module_name_;;
435 EXPECT_EQ(meta_versions[i].backend_min_abi_version, tmp_version.backend_min_abi_version) << "module name is " << result_info.module_name_;;
437 _hal_api_conf_exit();