From 6609ca9efb843a7f12525ab7cc65f6e87f1b2dad Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 26 Aug 2021 14:42:38 +0800 Subject: [PATCH] [TD-5992] add test case --- src/client/tests/CMakeLists.txt | 2 +- src/client/tests/cliTest.cpp | 3 --- src/client/tests/setConfigTest.c | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/client/tests/setConfigTest.c diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt index 5de18942ac..f8f9c63510 100644 --- a/src/client/tests/CMakeLists.txt +++ b/src/client/tests/CMakeLists.txt @@ -16,6 +16,6 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) - ADD_EXECUTABLE(cliTest ${SOURCE_LIST}) + ADD_EXECUTABLE(cliTest setConfigTest ${SOURCE_LIST}) TARGET_LINK_LIBRARIES(cliTest taos cJson tutil common gtest pthread) ENDIF() diff --git a/src/client/tests/cliTest.cpp b/src/client/tests/cliTest.cpp index 89dbf080d0..c2799c7ff6 100644 --- a/src/client/tests/cliTest.cpp +++ b/src/client/tests/cliTest.cpp @@ -259,9 +259,6 @@ void validateResultFields() { } /* test parse time function */ TEST(testCase, result_field_test) { - const char *config = "{\"debugFlag\":\"135\"}"; - taos_set_config(config); - taos_set_config(config); taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); taos_init(); diff --git a/src/client/tests/setConfigTest.c b/src/client/tests/setConfigTest.c new file mode 100644 index 0000000000..3107e98af0 --- /dev/null +++ b/src/client/tests/setConfigTest.c @@ -0,0 +1,21 @@ +#include +#include + +#include "taos.h" +#include "tglobal.h" + +/* test parse time function */ +TEST(testCase, result_field_test) { + const char *config = "{\"debugFlag\":\"131\"}"; + taos_set_config(config); + + const char *config2 = "{\"debugFlag\":\"199\"}"; + taos_set_config(config2); // not take effect + + ASSERT_EQ(taosReadGlobalCfg(), true); // load file config, not take effect + ASSERT_EQ(taosCheckGlobalCfg(), 0); + + SGlobalCfg *cfg = taosGetConfigOption("debugFlag"); + ASSERT_EQ(cfg->cfgStatus, TAOS_CFG_CSTATUS_OPTION); + ASSERT_EQ(*(int32_t*)cfg.ptr, 135); +} -- GitLab