media-server icon indicating copy to clipboard operation
media-server copied to clipboard

test中若需更改测试项需要重新编译

Open xutopia77 opened this issue 3 years ago • 3 comments

在test.cpp中的测试项,如果需要运行其他的测试项,需要修改代码,重新编译一下,再运行; 例如:我想运行 //rtmp_server_forward_aio_test(NULL, 1935);,就需要把注释去掉,重新编译,再运行; 解决办法:可以使用c++的反射机制,根据输入的字符串参数,来调用相应的测试项; 例如: 注册测试项

REGISTER(rtmp_server_forward_aio_test);
RUN_REG("rtmp_server_forward_aio_test", argc, argv);

运行: ./test -c rtmp_server_forward_aio_test

xutopia77 avatar Jun 30 '21 02:06 xutopia77

看上去不错,需要新增多少代码?

ireader avatar Jun 30 '21 02:06 ireader

增加一个头文件,实现一个反射机制的c++类就可以了,当然也可以在c中调用; 但是需要c++11的支持,用到移动语义

xutopia77 avatar Jun 30 '21 03:06 xutopia77

test文件可以用c++11,没关系的,欢迎提交。

ireader avatar Jun 30 '21 03:06 ireader