[ovs-dev] [ofp-print 14/15] ofp-print: Add tests for OpenFlow message formatting.
Justin Pettit
jpettit at nicira.com
Wed Jan 12 08:22:53 UTC 2011
On Dec 14, 2010, at 12:23 PM, Ben Pfaff wrote:
> It's become clear over the past few weeks that some people really depend
> on the formatting of ofp-print output. It has also become clear that OVS
> doesn't have anything that actually checks or enforces the formatting of
> the output. The former is not something I want to encourage, but the
> latter is somewhat worrisome because the formatting does change from time
> to time and I want to make sure that that is intentional.
>
> So this commit adds at least one test for each supported OpenFlow and
> Nicira extension message, so that we can better keep track of changes.
> ---
> tests/automake.mk | 1 +
> tests/ofp-print.at | 889 +++++++++++++++++++++++++++++++++++++++++++++++++
> tests/testsuite.at | 1 +
> utilities/ovs-ofctl.c | 14 +
> 4 files changed, 905 insertions(+), 0 deletions(-)
> create mode 100644 tests/ofp-print.at
Wow. Thanks for going through all this effort to make scripters lives easier.
> +static void
> +do_ofp_print(int argc, char *argv[])
> +{
> + struct ofpbuf packet;
> +
> + ofpbuf_init(&packet, strlen(argv[1]) / 2);
> + if (ofpbuf_put_hex(&packet, argv[1], NULL)[0] != '\0') {
> + ovs_fatal(0, "trailing garbage following hex bytes");
> + }
> + ofp_print(stdout, packet.data, packet.size, argc > 2 ? atoi(argv[2]) : 2);
> + ofpbuf_uninit(&packet);
> +}
Even though some of these commands are undocumented, I think it would be nice to include some sort of indication about what the command line arguments are...even if it's only documented in a comment right above the function.
--Justin
More information about the dev
mailing list