diff --git a/unit_test/test/configure_test.cpp b/unit_test/test/configure_test.cpp index a8b7575..2e3f0bd 100644 --- a/unit_test/test/configure_test.cpp +++ b/unit_test/test/configure_test.cpp @@ -12,21 +12,19 @@ extern "C" { #include "ztp_config.h" } -TEST(config_file_test, ztpConfig) +TEST(config_file_test, load_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) +TEST(config_file_test, load_devConfig) { int ret = init_configure("../../ztp.conf"); ASSERT_EQ(ERR_OK, ret); @@ -46,4 +44,3 @@ TEST(config_file_test, devConfig) ASSERT_STREQ(pDevCfg->lan_config.ip_addr, "192.168.1.1"); ASSERT_STREQ(pDevCfg->lan_config.netmask, "255.255.255.0"); } - diff --git a/unit_test/test/json_test.cpp b/unit_test/test/json_test.cpp index 941f550..cb76664 100644 --- a/unit_test/test/json_test.cpp +++ b/unit_test/test/json_test.cpp @@ -57,9 +57,3 @@ TEST(json_test, decode) ASSERT_EQ(0, ret); } - -auto main(int argc, char *argv[]) -> int -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/unit_test/test/restful_test.cpp b/unit_test/test/restful_test.cpp index 356cbca..dba1a8a 100644 --- a/unit_test/test/restful_test.cpp +++ b/unit_test/test/restful_test.cpp @@ -50,8 +50,6 @@ TEST(ztp_auth, authorized_success) free(pZTPRsp->ip); } - - free(pZTPRsp); } } @@ -87,6 +85,7 @@ TEST(ztp_auth, unauthorized_failed) if(pZTPRsp->ip) { free(pZTPRsp->ip); } + free(pZTPRsp); } } diff --git a/unit_test/test/test_main.cpp b/unit_test/test/test_main.cpp new file mode 100644 index 0000000..540b81e --- /dev/null +++ b/unit_test/test/test_main.cpp @@ -0,0 +1,17 @@ +// +// Created by xajhu on 2019/12/3 0003. +// +#include + +using namespace std; + +#include "gtest/gtest.h" + + +auto main(int argc, char *argv[]) -> int +{ + testing::GTEST_FLAG(repeat) = 1; + testing::GTEST_FLAG(break_on_failure) = true; + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}