Skip to main content
GameDev.net gamedev.net
🔒 Locked

Testing Framework

Started by Zanthos Oct 24, 2006 at 1:41 PM 2 replies 900+ views
Original Post
Zanthos
Zanthos
I've been making some modifications to a reliable UDP implementation I conjured up earlier this year to include in my current project and I really want to be testing it to breaking point(until I fix the bugs at least). How would you guys go about making a framework to test your network code? I've had some ideas, but nothing that can be run easily(and to be honest if it was anything more than running a single script, I would end up not using it, and that's not much good). Any suggestions/tips/source dumps would be very much appreciated :)
Ozymandias42
Ozymandias42
Well, probably the easiest way to test a reliable UDP implementation is to modify it so that you can have the sender arbitrary drop outgoing packets and/or reorder them at certain rates.

If you don't want to muck up your code with those sorts of "features," you could write a small tool that could act as a proxy between two of your implementations and do the same thing.

Then, to test, you'd write two small programs that sent and received a large chunk of data between themselves and made sure it stayed correct and in order.
Zanthos
Zanthos
I think the proxy solution will cover testing the general working conditions of the implementation(basically, does it send/recieve reliably.. most of the time). The problems arise when I try to test the individual component parts of the system using assertions to ensure the 'most of the time' becomes an 'all of the time'. I can't expect to really know the exact state at which the system should be in if two components are operating independent of each other, and the proxy is adding a layer of uncertainty, so it removes any hope of installing package-wide testing. Is a testing framework on such a system too complex to consider such a precise level of validation?
hplus0603
hplus0603
Unit testing: Using knowledge about the implementation of a single module, you test the contracts of that module in the absence of any other module (except for necessary mock objects).

Functional testing: You make rules about the system behavior, and then you assert that behavior.

For example, if there is a rule that "eventually all realiable messages will make it through, or if not possible within 1 minute, report connection closed", then you can set up a scenario with 80% packet loss, and send a known sequence of 8 reliable messages. With a packet send rate of 10 per second, there is basically no chance that the messages won't make it through in a minute, so you can assert they make it through. Then set the packet loss to 100%, re-run the test, and assert that the system reports connection loss.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.