tests: unittest: Add hook function for handle hal backend library 66/276566/2
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 16 Jun 2022 05:36:55 +0000 (14:36 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 22 Jun 2022 03:14:42 +0000 (12:14 +0900)
commit4b40ecdcf3fd62969d9ac42d2bd09224979fe61a
tree0625a6b5e8e5912ca45f180ae8460699be426118
parent00a2bed56471abebba1b419f5ed96a6970452082
tests: unittest: Add hook function for handle hal backend library

The hal-api-common uses the dlopen/dlsym/dlclose to load/unload
the shared library of hal backend and find symbol from hal backend library.
For testing hal-api-common functions when building time, re-implement
dlopen/dlsym/dlclose for hooking.By implementing the hooking functions,
be able to verify the internal logic of hal-api-common functions.

Following fucntions are re-implemented for hooking:
- void *dlopen(const char *filename, int flags)
- int dlclose(void *handle)
- void *dlsym(void *handle, const char *symbol)
- int access(const char *pathname, int mode)

And hal-backend-[module] (e.g., tbm/tdm/audio/camera/devcie/power etc)
have to contain the their own hal_backend structure to implement
the h/w device-dependent hal backend. Instead of adding the each hal_backend
structure for all hal modules, use the common 'hal_backend_module_data'
regardless of hal module name.

Change-Id: Icbcba49a654f9ed1a287233c9cc0e3efcca508df
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
tests/unittest/hal-api-common-hook.c [new file with mode: 0644]