From: Youngjae Cho Date: Mon, 26 Jul 2021 08:54:07 +0000 (+0900) Subject: test: remove api test X-Git-Tag: submit/tizen/20210805.103313~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3860ac39542e194e21d3fd8a1907af3ef57396cc;p=platform%2Fcore%2Fapi%2Fsystem-info.git test: remove api test This is replaced by system-info-tool Change-Id: I9230cf8a3afadb42b8d81a4e6cf2e58a4a6fbc25 Signed-off-by: Youngjae Cho --- diff --git a/packaging/capi-system-info.spec b/packaging/capi-system-info.spec index afd3aa6..18f85bb 100644 --- a/packaging/capi-system-info.spec +++ b/packaging/capi-system-info.spec @@ -137,8 +137,6 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %{_libdir}/libcapi-system-info.so %files test -# API test -%{_bindir}/system_info_test # Init DB test %{_bindir}/system_info_init_db_test # Plugin test diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe263b7..62d8acc 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(TESTS - api init_db plugin ) diff --git a/test/api/CMakeLists.txt b/test/api/CMakeLists.txt deleted file mode 100755 index 1ec0ed8..0000000 --- a/test/api/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -SET(SYSTEM_INFO_TEST "system_info_test") -SET(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/system_info_test.c) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - -FOREACH(flag ${SYSTEM_INFO_TEST_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions -fpie") - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -ADD_EXECUTABLE(${SYSTEM_INFO_TEST} ${SRCS}) -ADD_DEPENDENCIES(${SYSTEM_INFO_TEST} ${fw_name}) -TARGET_LINK_LIBRARIES(${SYSTEM_INFO_TEST} ${SYSTEM_INFO_TEST_pkgs_LDFLAGS} "-L${CMAKE_SOURCE_DIR} -lcapi-system-info") - -INSTALL(TARGETS ${SYSTEM_INFO_TEST} DESTINATION bin) diff --git a/test/api/system_info_test.c b/test/api/system_info_test.c deleted file mode 100755 index 0f308d3..0000000 --- a/test/api/system_info_test.c +++ /dev/null @@ -1,261 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#define SUCCESS 0 - -#define OPT_MAX 16 -#define KEY_MAX 256 - -#define RUNTIME_ENV "RUNTIME_TYPE" - -#define DEFAULT_OPT 0 - -#define CONVERT_ARGUMENT(input_str, input_str_len, output_num, table) \ -{ \ - int __idx; \ - bool __is_converted = false; \ - for (__idx = 0; __idx < sizeof(table) / sizeof(struct str_num_table); __idx++) { \ - if (!strncmp(input_str, table[__idx].str, strlen(table[__idx].str) + 1)) { \ - output_num = table[__idx].num; \ - __is_converted = true; \ - break; \ - } \ - } \ - if (!__is_converted) { \ - if (input_str[0] == '\0') { \ - output_num = table[DEFAULT_OPT].num; \ - strncpy(input_str, table[DEFAULT_OPT].str, input_str_len - 1); \ - input_str[input_str_len - 1] = '\0'; \ - } else { \ - printf("Invalid argument %s\n\n", input_str); \ - show_help(); \ - return EINVAL; \ - } \ - } \ -} - -enum tag { - TAG_PLATFORM, - TAG_CUSTOM, - TAG_MAX -}; - -enum type { - TYPE_BOOL, - TYPE_INT, - TYPE_DOUBLE, - TYPE_STRING, - TYPE_MAX -}; - -enum runtime { - RUNTIME_C, - RUNTIME_WEB, - RUNTIME_DOTNET, - RUNTIME_MAX -}; - -struct str_num_table { - const char *str; - int num; -}; - -/** - * @remarks If there is no input, set to the first element. - * It means the first element is default value. - * To disable default value, check essential options. - */ - -struct str_num_table tag_table[TAG_MAX] = { - { "platform", TAG_PLATFORM }, - { "custom", TAG_CUSTOM }, -}; - -struct str_num_table type_table[TYPE_MAX] = { - { "bool", TYPE_BOOL }, - { "int", TYPE_INT }, - { "double", TYPE_DOUBLE }, - { "string", TYPE_STRING }, -}; - -struct str_num_table runtime_table[RUNTIME_MAX] = { - { "c", RUNTIME_C }, - { "web", RUNTIME_WEB }, - { "dotnet", RUNTIME_DOTNET }, -}; - -static char tag_str[OPT_MAX]; -static enum tag tag_num; - -static char type_str[OPT_MAX]; -static enum type type_num; - -static char key[KEY_MAX]; - -static char runtime_str[OPT_MAX]; -static enum runtime runtime_num; - -static void show_help(void) -{ - printf("system_info_test [OPTIONS]\n"); - printf(" -g TAG System info tag to read (platform/custom)\n"); - printf(" (Optional, default value is platform)\n"); - printf(" -t TYPE System info type to read (bool/int/double/string)\n"); - printf(" (Essential)\n"); - printf(" -k KEY System info key to read\n"); - printf(" (Essential)\n"); - printf(" -r RUNTIME Runtime type (c/web/dotnet)\n"); - printf(" (Optional, default value is c)\n"); - printf("\n"); - printf(" -h Show this message\n"); - printf("\n"); - printf("Example:\n"); - printf(" system_info_test -g platform -t string -k tizen.org/system/platform.name -r c\n"); -} - -int main(int argc, char *argv[]) -{ - int ret; - int opt; - - bool val_bool; - int val_int; - double val_double; - char *val_string = NULL; - - /* Parse arguments */ - while ((opt = getopt(argc, argv, "g:t:k:r:h")) != -1) { - switch (opt) { - case 'g': - snprintf(tag_str, OPT_MAX, "%s", optarg); - break; - case 't': - snprintf(type_str, OPT_MAX, "%s", optarg); - break; - case 'k': - snprintf(key, KEY_MAX, "%s", optarg); - break; - case 'r': - snprintf(runtime_str, OPT_MAX, "%s", optarg); - break; - case 'h': - show_help(); - return SUCCESS; - default: - show_help(); - return EINVAL; - } - } - - /* Check whether essential options are inputted */ - if (type_str[0] == '\0' || key[0] == '\0') { - printf("Essential options aren't inputted\n\n"); - show_help(); - return EINVAL; - } - - /* Convert string arguments into the enum value */ - CONVERT_ARGUMENT(tag_str, sizeof(tag_str), tag_num, tag_table); - CONVERT_ARGUMENT(type_str, sizeof(type_str), type_num, type_table); - CONVERT_ARGUMENT(runtime_str, sizeof(runtime_str), runtime_num, runtime_table); - - /* Set the runtime environment value */ - switch (runtime_num) { - case RUNTIME_C: - ret = setenv(RUNTIME_ENV, "capp", 1); - break; - case RUNTIME_WEB: - ret = setenv(RUNTIME_ENV, "webapp", 1); - break; - case RUNTIME_DOTNET: - ret = setenv(RUNTIME_ENV, "dotnet", 1); - break; - default: - printf("Failed to convert runtime argument\n"); - return EIO; - break; - } - - if (ret != SUCCESS) { - printf("setenv failed : %m\n"); - return errno; - } - - printf("TAG(%s), TYPE(%s), RUNTIME(%s), KEY(%s), RESULT(", - tag_str, type_str, runtime_str, key); - - /* Call appropriate system-info API and print result */ - switch (tag_num) { - case TAG_PLATFORM: - switch (type_num) { - case TYPE_BOOL: - ret = system_info_get_platform_bool(key, &val_bool); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%d", val_bool); - break; - case TYPE_INT: - ret = system_info_get_platform_int(key, &val_int); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%d", val_int); - break; - case TYPE_DOUBLE: - ret = system_info_get_platform_double(key, &val_double); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%lf", val_double); - break; - case TYPE_STRING: - ret = system_info_get_platform_string(key, &val_string); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%s", val_string); - break; - default: - ret = SYSTEM_INFO_ERROR_INVALID_PARAMETER; - break; - } - break; - case TAG_CUSTOM: - switch (type_num) { - case TYPE_BOOL: - ret = system_info_get_custom_bool(key, &val_bool); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%d", val_bool); - break; - case TYPE_INT: - ret = system_info_get_custom_int(key, &val_int); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%d", val_int); - break; - case TYPE_DOUBLE: - ret = system_info_get_custom_double(key, &val_double); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%lf", val_double); - break; - case TYPE_STRING: - ret = system_info_get_custom_string(key, &val_string); - if (ret == SYSTEM_INFO_ERROR_NONE) - printf("%s", val_string); - break; - default: - ret = SYSTEM_INFO_ERROR_INVALID_PARAMETER; - break; - } - break; - default: - ret = SYSTEM_INFO_ERROR_INVALID_PARAMETER; - break; - } - - if (ret != SYSTEM_INFO_ERROR_NONE) { - printf("ERROR : %d", ret); - } - - printf(")\n"); - - return SUCCESS; -}