简体   繁体   English

在生成文件中运行服务器和客户端

[英]Run a server and client in a makefile

I'm coding a socket file server in C++, and I can't figure out how to put proper unit testing into my makefile. 我正在用C ++编写套接字文件服务器的代码,我不知道如何在我的makefile中进行适当的单元测试。 My problem is as follows: 我的问题如下:

The server, when started, spits out its port number to stdout. 服务器启动时,将其端口号吐出到stdout。 It then listens, ad infinitum. 然后无限听。 The client process (my test suite) needs to read the server's output, and then start up in its own, parallel process. 客户端进程(我的测试套件)需要读取服务器的输出,然后以其自己的并行进程启动。

How can I write a script which will both 1. run the two programs in parallel, 2. allow me to get output from one to the other properly, 3. allow me to store the output in a nice format for later viewing. 我该如何编写一个脚本,该脚本将1.并行运行两个程序,2.允许我正确地将输出从一个程序输出到另一个程序,3.允许我以一种不错的格式存储输出以供以后查看。

It sounds as normal piping should work: 听起来正常的管道应该工作:

run:
    myserver | tee mylog.txt | myclient

Then, the file log.txt includes the output of myserver , ie the port number. 然后,文件log.txt包含myserver的输出,即端口号。 If you want to catch your client's output in a file, you can redirect it. 如果要在文件中捕获客户机的输出,则可以重定向它。

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

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