samedi 6 janvier 2018

Ways to speed up testing of programs that rely on time consuming system calls

So I'm developing two pieces of software: a client and a server. They communicate with each other via a TCP based protocol.

The goal is to have some automated tests that verifies various scenario's. Some examples:

1) Client sends request to server, server respons. The test should check whether the response was correct.

2) Client sends request to server, but server does not respond. The client should timeout after 5.0 seconds. The test should check if the client does indeed timeout after 5.0 ± 0.1 second.

3) Server sends PING command to a connected client, the client does not respond. The server should disconnect the client after 20 seconds. The test should check that the client is indeed disconnected after 20 ± 0.1 second.

So to be clear, I've already written these tests, and they work fine. The problem is, as the number of tests increase, so does the time it takes to run the full test suite. For example, just running tests nr 2 and 3 already takes 25 seconds.

The question: Are there ways to somehow speed up these tests?

I was thinking about running the processes in some kind of 'special' container/sandbox/whatever that has an increased clockspeed so that calls to poll() are returning in for example 1/100th the specified timeout.

Is there some general way of doing this kind of tests? I would love to hear other suggestions as I'm kinda reaching a dead-end with my google-skills.

Aucun commentaire:

Enregistrer un commentaire