I want to create various network errors during testing. I use the Berkely Socket API directly in C ++ on Linux. I am running the server layout in another thread from Boost.Test that is listening on the local host.
For example, I would like to create a timeout during the connection. So far, I tried not to accept accept on my breadboard server and set the backlog to 1, and then make some connections, but everything seems to connect successfully. I would think that if there was no room in the backlog, I would at least get a refusal to refuse, if not a timeout.
I would like to do this all programmatically, if possible, but I would think about using something external, such as IPchains, to intentionally remove certain packages to certain ports during testing, but I would need to automate the creation and deletion rules so I can do this from my Boost.Test tests.
I suppose I could mock various system calls, but I would prefer, if possible, to use a real TCP stack.
Ideas?
Robert S. Barnes
source share