简体   繁体   中英

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. My problem is as follows:

The server, when started, spits out its port number to 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.

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. If you want to catch your client's output in a file, you can redirect it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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