116 lines
4.1 KiB
C++
116 lines
4.1 KiB
C++
/**
|
||
* @file test_XNInterfaceGen.cpp
|
||
* @brief 测试XNInterfaceGen动态库的测试程序
|
||
*/
|
||
|
||
#include <iostream>
|
||
#include <string>
|
||
#include <cstring>
|
||
|
||
// 声明外部函数
|
||
extern "C"
|
||
{
|
||
int XNInterfaceGen_Step1_InitParams(int configrationID, const char *errorMsg,
|
||
const int errorMsgSize);
|
||
int XNInterfaceGen_Step2_GetInterfaceData(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step3_CreateConfigDir(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step4_GenerateIDL(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step5_GenerateFastDDS(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step6_GenerateDDSInterface(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step7_GenerateCMakeLists(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step8_BuildAndInstall(const char *errorMsg, const int errorMsgSize);
|
||
int XNInterfaceGen_Step9_SudoLdconfig(const char *errorMsg, const int errorMsgSize);
|
||
}
|
||
|
||
int main()
|
||
{
|
||
// 测试参数
|
||
int configrationID = 1; // 配置ID
|
||
char errorMsg[1024] = {0}; // 错误信息缓冲区
|
||
|
||
std::cout << "开始测试XNInterfaceGen步骤函数..." << std::endl;
|
||
|
||
// 步骤1: 初始化参数
|
||
std::cout << "步骤1: 初始化参数..." << std::endl;
|
||
int ret = XNInterfaceGen_Step1_InitParams(configrationID, errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤1失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤1成功: " << errorMsg << std::endl;
|
||
|
||
// 步骤2: 获取接口数据
|
||
std::cout << "步骤2: 获取接口数据..." << std::endl;
|
||
ret = XNInterfaceGen_Step2_GetInterfaceData(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤2失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤2成功" << std::endl;
|
||
|
||
// 步骤3: 创建配置目录
|
||
std::cout << "步骤3: 创建配置目录..." << std::endl;
|
||
ret = XNInterfaceGen_Step3_CreateConfigDir(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤3失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤3成功" << std::endl;
|
||
|
||
// 步骤4: 生成IDL
|
||
std::cout << "步骤4: 生成IDL..." << std::endl;
|
||
ret = XNInterfaceGen_Step4_GenerateIDL(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤4失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤4成功" << std::endl;
|
||
|
||
// 步骤5: 生成FastDDS代码
|
||
std::cout << "步骤5: 生成FastDDS代码..." << std::endl;
|
||
ret = XNInterfaceGen_Step5_GenerateFastDDS(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤5失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤5成功" << std::endl;
|
||
|
||
// 步骤6: 生成DDS接口
|
||
std::cout << "步骤6: 生成DDS接口..." << std::endl;
|
||
ret = XNInterfaceGen_Step6_GenerateDDSInterface(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤6失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤6成功" << std::endl;
|
||
|
||
// 步骤7: 生成CMakeLists
|
||
std::cout << "步骤7: 生成CMakeLists..." << std::endl;
|
||
ret = XNInterfaceGen_Step7_GenerateCMakeLists(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤7失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤7成功" << std::endl;
|
||
|
||
// 步骤8: 构建和安装
|
||
std::cout << "步骤8: 构建和安装..." << std::endl;
|
||
ret = XNInterfaceGen_Step8_BuildAndInstall(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤8失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤8成功" << std::endl;
|
||
|
||
// 步骤9: 执行ldconfig
|
||
std::cout << "步骤9: 执行ldconfig..." << std::endl;
|
||
ret = XNInterfaceGen_Step9_SudoLdconfig(errorMsg, sizeof(errorMsg));
|
||
if (ret != 0) {
|
||
std::cout << "步骤9失败!错误信息: " << errorMsg << std::endl;
|
||
return ret;
|
||
}
|
||
std::cout << "步骤9成功" << std::endl;
|
||
|
||
std::cout << "所有步骤测试成功!接口生成完成。" << std::endl;
|
||
return 0;
|
||
} |