Merge pull request #605 from lixiumei123/main

Fix unit test
This commit is contained in:
fengzeroz
2022-06-29 15:43:37 +08:00
committed by GitHub
4 changed files with 22 additions and 19 deletions
+2
View File
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.12)
project(neuron)
enable_testing()
enable_language(C)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
+2
View File
@@ -44,6 +44,8 @@ ${MODBUS_TCP_CONFIG} {"host": "127.0.0.1", "port": 60502, "t
*** Variables ***
${neuron_process}
${MODBUS_PLUS_TCP_CONFIG} {"host": "127.0.0.1", "port": 60502, "connection_mode": 0, "timeout": 3000}
*** Keywords ***
Start Neuronx
Remove Persistence
+10 -10
View File
@@ -17,15 +17,15 @@ target_include_directories(http_test PRIVATE
${CMAKE_SOURCE_DIR}/plugins/restful)
target_link_libraries(http_test neuron-base gtest_main gtest jansson nng)
#file(COPY ${CMAKE_SOURCE_DIR}/plugin_param_schema.json DESTINATION ${CMAKE_BINARY_DIR}/tests)
#add_executable(mqtt_test mqtt_test.cc
#${CMAKE_SOURCE_DIR}/plugins/mqtt/util.c)
#target_include_directories(mqtt_test PRIVATE
#${CMAKE_SOURCE_DIR}/src
#${CMAKE_SOURCE_DIR}/include
#${CMAKE_SOURCE_DIR}/src/schema
#${CMAKE_SOURCE_DIR}/plugins/mqtt)
#target_link_libraries(mqtt_test neuron-base gtest_main gtest jansson ssl crypto)
# file(COPY ${CMAKE_SOURCE_DIR}/plugin_param_schema.json DESTINATION ${CMAKE_BINARY_DIR}/tests)
add_executable(mqtt_test mqtt_test.cc
${CMAKE_SOURCE_DIR}/plugins/mqtt/util.c)
target_include_directories(mqtt_test PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src/schema
${CMAKE_SOURCE_DIR}/plugins/mqtt)
target_link_libraries(mqtt_test neuron-base gtest_main gtest jansson ssl crypto)
file(COPY ${CMAKE_SOURCE_DIR}/neuron.key DESTINATION ${CMAKE_BINARY_DIR}/tests/config)
file(COPY ${CMAKE_SOURCE_DIR}/neuron.pem DESTINATION ${CMAKE_BINARY_DIR}/tests/config)
@@ -55,7 +55,7 @@ target_link_libraries(tag_sort_test neuron-base gtest_main gtest)
include(GoogleTest)
gtest_discover_tests(json_test)
gtest_discover_tests(http_test)
#gtest_discover_tests(mqtt_test)
gtest_discover_tests(mqtt_test)
gtest_discover_tests(jwt_test)
gtest_discover_tests(base64_test)
gtest_discover_tests(tag_sort_test)
+8 -9
View File
@@ -9,18 +9,17 @@ zlog_category_t *neuron = NULL;
TEST(MQTTTest, mqtt_option_init_by_config)
{
neu_config_t config;
memset(&config, 0, sizeof(neu_config_t));
neu_mqtt_option_t option;
memset(&option, 0, sizeof(neu_mqtt_option_t));
config.buf = (char *) "{\"node_id\":5,\"params\":{\"client-id\":"
"\"upload123\", \"upload-topic\":\"\", \"format\": "
"0,\"ssl\":false,\"host\":\"192.168.10."
"116\",\"port\":1883,\"username\":\"\",\"password\":"
"\"\",\"ca\":\"\", \"cert\":\"\", \"key\":\"\", "
"\"keypass\":\"\"}}";
char *config =
(char *) "{\"node_id\":5,\"params\":{\"client-id\":"
"\"upload123\", \"upload-topic\":\"\", \"format\": "
"0,\"ssl\":false,\"host\":\"192.168.10."
"116\",\"port\":1883,\"username\":\"\",\"password\":"
"\"\",\"ca\":\"\", \"cert\":\"\", \"key\":\"\", "
"\"keypass\":\"\"}}";
int rc = mqtt_option_init(&config, &option);
int rc = mqtt_option_init(config, &option);
EXPECT_EQ(0, rc);
mqtt_option_uninit(&option);
}