From: Youngjae Cho Date: Thu, 20 Jun 2024 03:55:32 +0000 (+0900) Subject: tool: hal-compatibility-checker: Fix --skip-if-result-exist to work X-Git-Tag: accepted/tizen/unified/20240625.163203~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3ff8f597efe476cb0e74c8e6962a07f9d7436e3;p=platform%2Fhal%2Fapi%2Fcommon.git tool: hal-compatibility-checker: Fix --skip-if-result-exist to work To prevent checking repeatedly for every booting, the option skips checking if there was result file. Change-Id: If55a3a59c12765591e33c5c2899028af86452907 Signed-off-by: Youngjae Cho --- diff --git a/tools/hal-compatibility-checker/main.c b/tools/hal-compatibility-checker/main.c index 679913c..bb89e22 100644 --- a/tools/hal-compatibility-checker/main.c +++ b/tools/hal-compatibility-checker/main.c @@ -28,8 +28,9 @@ #include #include -#define DEFAULT_PLATFORM_MANIFEST_DIR "/etc/hal" +#define DEFAULT_PLATFORM_MANIFEST_DIR "/etc/hal" #define DEFAULT_HAL_INFO_INI "/hal/etc/hal-info.ini" +#define DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH "/opt/etc/hal/.hal-backend-compatibility" #define HCC_BUF_MAX (256) #define BOLD(STR) "\e[1m"STR"\e[m" @@ -87,11 +88,9 @@ static int get_tizen_hal_version(int *major, int *minor) return found ? 0 : -EINVAL; } -// check result is exist, return true on exist. -static bool result_exist(const char *dir) +static bool result_exist(const char *path) { - // check result exists based on the directory 'dir'. - return false; + return (access(path, F_OK) == 0); } static void show_help(void) @@ -106,9 +105,9 @@ static void show_help(void) "\t-h, --help\n" "\t\tshow this help.\n" "\n" - "\t--skip-if-result-exist[=DIRECTORY]\n" + "\t--skip-if-result-exist[=FILE]\n" "\t\tskip compatibility check if there exists a result of compatibility.\n" - "\t\tif DIRECTORY is given, locate a result based on the given DIRECTORY.\n" + "\t\tif FILE is given, locate a result based on the given FILE.\n" "\n" "\t--reset\n" "\t\tremove the existing result file.\n" @@ -122,7 +121,7 @@ int main(int argc, char *argv[]) int index; bool skip_if_result_exist = false; bool reset_file = false; - const char *skip_if_result_exist_dir = NULL; + const char *skip_if_result_exist_path = NULL; const char *platform_manifest_dir = NULL; for (;;) { @@ -139,7 +138,7 @@ int main(int argc, char *argv[]) switch (index) { case OPT_SKIP_IF_RESULT_EXIST: skip_if_result_exist = true; - skip_if_result_exist_dir = optarg; + skip_if_result_exist_path = optarg ? : DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH; break; case OPT_RESET: reset_file = true; @@ -160,13 +159,14 @@ int main(int argc, char *argv[]) return 0; } - if (skip_if_result_exist && result_exist(skip_if_result_exist_dir)) { - printf("hal-compatibility-checker: skip checking\n"); + if (reset_file) { + unlink(DEFAULT_HAL_BACKEND_COMPATIBILITY_PATH); return 0; } - if (reset_file) { - unlink("/opt/etc/hal/.hal-backend-compatibility"); + if (skip_if_result_exist && result_exist(skip_if_result_exist_path)) { + dlog_print(DLOG_DEBUG, LOG_TAG_HAL_COMPATIBILITY_CHECKER, + "hal-compatibility-checker: skip checking\n"); return 0; }