提交 8e6cc1cb 编写于 作者: J jiacy-jcy

[TD-5992]<test>:add ctest files for clientcfgtest

上级 da149e8a
文件已添加
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config to wrong type
const char config1[128] = "{\"cache\":\"4\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg1 ;
cfg1 = taosGetConfigOption("cache");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config cache to '4'success!\n");
else
printf("config cache failure!\n");
return 0 ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config with wrong JSON
//The result is failure
const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\135\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg1 ;
cfg1 = taosGetConfigOption("firstEp");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config firstEp 'BCC-2:6030'success!\n");
else
printf("config firstEp failure!\n");
SGlobalCfg *cfg2 ;
cfg2 = taosGetConfigOption("debugFlag");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config debugFlag '135'success!\n");
else
printf("config debugFlag failure!\n");
//case2:
//repair the JSON and try again
//The result is success
const char config2[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured
taos_set_config(config2); //configure the parameter
SGlobalCfg *cfg3 ;
cfg3 = taosGetConfigOption("firstEp");//check the option result
if(cfg3->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config firstEp 'BCC-2:6030'success!\n");
else
printf("config firstEp failure!\n");
SGlobalCfg *cfg4 ;
cfg4 = taosGetConfigOption("debugFlag");//check the option result
if(cfg4->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config debugFlag '135'success!\n");
else
printf("config debugFlag failure!\n");
return 0 ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config to wrong type
//The result is failure
const char config1[128] = "{\"debugFlag\":\"9999999999999999999999999\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg1 ;
cfg1 = taosGetConfigOption("debugFlag");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config debugFlag '9999999999999999999999999\n");
else
printf("config debugFlag failure!\n");
//case2:
//Try again with right parameter
//The result is failure
const char config2[128] = "{\"debugFlag\":\"135\"}";//input the parameter which want to be configured
taos_set_config(config2); //configure the parameter
SGlobalCfg *cfg2 ;
cfg2 = taosGetConfigOption("debugFlag");//check the option result
if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config debugflag '135'success!\n");
else
printf("config debugflag failure!\n");
return 0 ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config to wrong type
const char config1[128] = "{\"rpcTimer\":\"0\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg1 ;
cfg1 = taosGetConfigOption("rpcTimer");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config rpcTimer to '0'success!\n");
else
printf("config rpcTimer failure!\n");
//case2:
//Try again with right parameter
const char config2[128] = "{\"rpcTimer\":\"400\"}";//input the parameter which want to be configured
taos_set_config(config2); //configure the parameter
SGlobalCfg *cfg2 ;
cfg2 = taosGetConfigOption("rpcTimer");//check the option result
if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config rpcTimer '400'success!\n");
else
printf("config rpcTimer failure!\n");
return 0 ;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <taos.h>
#include "os.h"
#include "taosdef.h"
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsocket.h"
#include "tutil.h"
extern SGlobalCfg *taosGetConfigOption(const char *option) ;
int main( int argc, char *argv[]){
printf("start to test\n");
//case1:
//Test config firstEp success
const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured
taos_set_config(config1); //configure the parameter
SGlobalCfg *cfg1 ;
cfg1 = taosGetConfigOption("firstEp");//check the option result
if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config firstEp 'BCC-2:6030'success!\n");
else
printf("config firstEp failure!\n");
SGlobalCfg *cfg2 ;
cfg2 = taosGetConfigOption("debugFlag");//check the option result
if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config debugFlag '135' success!\n");
else
printf("config debugFlag failure!\n");
//case2:
//Test config only useful at the first time
//The result is failure
const char config2[128] = "{\"fqdn\":\"BCC-3\"}";//input the parameter which want to be configured
taos_set_config(config2); //configure the parameter
SGlobalCfg *cfg3 ;
cfg2 = taosGetConfigOption("fqdn");//check the option result
if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success
printf("config fqdn to 'BCC-3'success!\n");
else
printf("config fqdn failure!\n");
return 0 ;
}
......@@ -6,7 +6,11 @@ TARGET=exe
LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt
CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \
-Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99
-Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \
-I/home/ubuntu/TDengine/src/os/inc -I/home/ubuntu/TDengine/src/inc \
-I/home/ubuntu/TDengine/src/util/inc \
-I/home/ubuntu/TDengine/src/common/inc
all: $(TARGET)
......@@ -17,6 +21,12 @@ exe:
gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS)
gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS)
gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest.c -o $(ROOT)clientcfgtest $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongtype.c -o $(ROOT)clientcfgtest-wrongtype $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongjson.c -o $(ROOT)clientcfgtest-wrongjson $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-wrongvalue.c -o $(ROOT)clientcfgtest-wrongvalue $(LFLAGS)
gcc $(CFLAGS) ./clientcfgtest-taosd.c -o $(ROOT)clientcfgtest-taosd $(LFLAGS)
clean:
rm $(ROOT)asyncdemo
......@@ -26,3 +36,9 @@ clean:
rm $(ROOT)stream
rm $(ROOT)subscribe
rm $(ROOT)apitest
rm $(ROOT)clientcfgtest
rm $(ROOT)clientcfgtest-wrongtype
rm $(ROOT)clientcfgtest-wrongjson
rm $(ROOT)clientcfgtest-wrongvalue
rm $(ROOT)clientcfgtest-taosd
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册