Mod aaa-12 1. 增加配置文件信息获取接口。2. 增加配置文件单元测试
RCA: SOL: 修改人:huangxin 检视人:huangxin
This commit is contained in:
parent
274428e9ce
commit
d32d08039b
|
@ -22,6 +22,16 @@ static pthread_t g_monThreadId;
|
|||
static ZTP_CONFIG g_ztpInfo;
|
||||
static DEVICE_CONFIG g_devInfo;
|
||||
|
||||
PZTP_CONFIG get_ztp_configure(void)
|
||||
{
|
||||
return &g_ztpInfo;
|
||||
}
|
||||
|
||||
PDEVICE_CONFIG get_device_configure(void)
|
||||
{
|
||||
return &g_devInfo;
|
||||
}
|
||||
|
||||
static void __init_dev_config(PDEVICE_CONFIG pCfg)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -90,4 +90,7 @@ double cfg_get_float_value(config_t *pCfg, const char *pTags, double defValue);
|
|||
int cfg_get_array_int_value(config_t *pCfg, const char *pTags, int *pArray, int *pMaxItem);
|
||||
|
||||
int load_dev_config(const char *devId);
|
||||
|
||||
PZTP_CONFIG get_ztp_configure(void);
|
||||
PDEVICE_CONFIG get_device_configure(void);
|
||||
#endif //ZTP_CLIENT_ZTP_CONFIG_H
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
//
|
||||
// Created by xajhu on 2019/12/3 0003.
|
||||
//
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
extern "C" {
|
||||
#include "err_code.h"
|
||||
#include "ztp_config.h"
|
||||
}
|
||||
|
||||
TEST(config_file_test, ztpConfig)
|
||||
{
|
||||
int ret = init_configure("../../ztp.conf");
|
||||
ASSERT_EQ(ERR_OK, ret);
|
||||
|
||||
|
||||
PZTP_CONFIG pZtpCfg = get_ztp_configure();
|
||||
|
||||
|
||||
ASSERT_STREQ(pZtpCfg->svr_cfg.server_url, "cmhi.ztp.com");
|
||||
ASSERT_STREQ(pZtpCfg->dev_dir, "dev_confs");
|
||||
ASSERT_EQ(10082, pZtpCfg->svr_cfg.port);
|
||||
}
|
||||
|
||||
TEST(config_file_test, devConfig)
|
||||
{
|
||||
int ret = init_configure("../../ztp.conf");
|
||||
ASSERT_EQ(ERR_OK, ret);
|
||||
|
||||
ret = load_dev_config("ace08484843");
|
||||
ASSERT_EQ(ERR_OK, ret);
|
||||
|
||||
PDEVICE_CONFIG pDevCfg = get_device_configure();
|
||||
|
||||
ASSERT_EQ(pDevCfg->port_cfg[0].port_type, WAN_PORT);
|
||||
ASSERT_EQ(pDevCfg->port_cfg[0].port_protocol, DHCP_TYPE);
|
||||
|
||||
ASSERT_EQ(pDevCfg->port_cfg[1].port_type, WAN_PORT);
|
||||
ASSERT_EQ(pDevCfg->port_cfg[1].port_protocol, STATIC_TYPE);
|
||||
|
||||
ASSERT_EQ(pDevCfg->lan_config.ip_type, IPV4_TYPE);
|
||||
ASSERT_STREQ(pDevCfg->lan_config.ip_addr, "192.168.1.1");
|
||||
ASSERT_STREQ(pDevCfg->lan_config.netmask, "255.255.255.0");
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ TEST(ztp_auth, authorized_success)
|
|||
memset(buf, 0, 4096);
|
||||
ret = http_post_request(REQ_URL, JSON_REQ, (unsigned char *)buf, &size);
|
||||
|
||||
EXPECT_EQ(ERR_OK, ret);
|
||||
ASSERT_EQ(ERR_OK, ret);
|
||||
|
||||
ret = Json2Struct(buf, &pZTPRsp, JE_AUTH_ZTP, false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue