简体   繁体   English

协议缓冲区测试C ++:expect / tcl / tk?

[英]Protocol buffers testing C++: expect/tcl/tk?

I have several modules that listen on determinate port to communicate with each other using UDP with protocol buffers (C++). 我有几个模块侦听确定端口,使用UDP与协议缓冲区(C ++)相互通信。
I need to automatize tests for each one of them. 我需要为每个测试自动化测试。
Which is the best strategy to do the testing? 哪个是进行测试的最佳策略?

I mean I could write a C++ program that emulates each component using determined commands, for example in xml: 我的意思是我可以编写一个C ++程序,使用确定的命令模拟每个组件,例如在xml中:

<commands>
  <send cmd="blahblah" from="module1" to="module2">
  <expect cmd="ack" from="module2" to="module1">
</commands>

but I was told that Expect/Tcl/Tk could be used. 但我被告知可以使用Expect / Tcl / Tk。 After some research, I think serialized protobuf's commands can't be done with static text, besides from what I have investigated, Expect works with output stream, and to test those components I need something that works with TCP/UDP sockets. 经过一些研究,我认为序列化的protobuf命令不能用静态文本完成,除了我调查的内容外,Expect还可以处理输出流,并测试那些需要与TCP / UDP套接字配合使用的组件。 Correct me if I am wrong. 如果我错了,请纠正我。 So is there some other tool to achieve this behavior (I mean sockets)? 那么有没有其他工具来实现这种行为(我的意思是套接字)?

I have no experience either with protobuf nor with expect. 我没有使用protobuf也没有经验。 I would like to hear some opinions, maybe use some other tools to perform this type of testing. 我想听听一些意见,也许可以使用其他工具来执行此类测试。

Expect is not really suitable for binary data, so I wouldn't use it for protocol buffers messages. Expect不太适合二进制数据,因此我不会将它用于协议缓冲区消息。

I would recommend writing a small C++ (or any other language) program that takes a command to send and and an response to expect, like you suggested. 我建议编写一个小型C ++(或任何其他语言)程序,它接受一个命令发送和一个期望的响应,就像你建议的那样。 You can use the protocol buffers text format to represent your data, so you do not have to write manual XML -> protobuf conversion for each message. 您可以使用协议缓冲区文本格式来表示数据,因此您不必为每条消息编写手动XML - > protobuf转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM