floodlight/loxigen — pull request #12 by rlane (2013-05-13 20:51:20+00:00)
Title: Share test data between backends

Reviewer: @andi-bigswitch

Writing tests (specifically, figuring out the binary wire representation of an OpenFlow object) is the most time consuming part of working on LoxiGen, so it makes sense to share them between multiple backends. These changes add a test_data directory containing, for many different messages, several syntaxes for a message (binary, pyloxi, pretty-printed, etc). The language-specific unit test can then pull out the relevant sections from each file.

Example test data file (of10/hello.data):
```
-- binary
01 00 # version / type
00 08 # length
12 34 56 78 # xid
-- python
ofp.message.hello(xid=0x12345678)
```

The pyloxi unit test evals the "python" section to get a pyloxi object, then call pack() and compares the result to the (parsed) binary section, then calls unpack() with the binary representation and compares that to the original pyloxi object. There's optional support for testing pretty-printing.

When writing another backend (like Java) the developer will just add another "java" section to the data file with the Java syntax for the same message, and wire up the Java unit tests to do the serialization/deserialization tests.

I moved a few representative pyloxi unit tests into the test_data directory. Once this pull request goes in I'll move the rest.