2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 18:07:40 +00:00

util: Avoid trailing white space in hex dumps.

ovs_hex_dump() sometimes yields a trailing space in its output.  This is
annoying for the test infrastructure, since we have to specially mark the
trailing white space in Autotest with a "@&t@" marker at the end of the
line.  This commit gets rid of the trailing white space and the annoying
"@&t@" markers.

This also gets rid of an occasional trailing hyphen.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Russell Bryant <russell@ovn.org>
This commit is contained in:
Ben Pfaff 2017-09-14 17:00:38 -07:00
parent e51d0a1d5a
commit 327a39b6ec
4 changed files with 45 additions and 44 deletions

View File

@ -662,10 +662,11 @@ ovs_hex_dump(FILE *stream, const void *buf_, size_t size,
for (i = 0; i < start; i++) for (i = 0; i < start; i++)
fprintf(stream, " "); fprintf(stream, " ");
for (; i < end; i++) for (; i < end; i++)
fprintf(stream, "%02x%c", fprintf(stream, "%c%02x",
buf[i - start], i == per_line / 2 - 1? '-' : ' '); i == per_line / 2 ? '-' : ' ', buf[i - start]);
if (ascii) if (ascii)
{ {
fprintf(stream, " ");
for (; i < per_line; i++) for (; i < per_line; i++)
fprintf(stream, " "); fprintf(stream, " ");
fprintf(stream, "|"); fprintf(stream, "|");

View File

@ -120,18 +120,18 @@ AT_SETUP([encoding errors extension that became official])
AT_KEYWORDS([ofp-print ofp-errors]) AT_KEYWORDS([ofp-print ofp-errors])
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0100000812345678], [0], [dnl [ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0100000812345678], [0], [dnl
00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ 00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 01 02 01 01 00 00 08-12 34 56 78 @&t@ 00000010 00 01 02 01 01 00 00 08-12 34 56 78
]) ])
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0200000812345678], [0], [dnl [ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0200000812345678], [0], [dnl
00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ 00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 01 02 01 02 00 00 08-12 34 56 78 @&t@ 00000010 00 01 02 01 02 00 00 08-12 34 56 78
]) ])
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0300000812345678], [0], [dnl [ovs-ofctl encode-error-reply OFPRRFC_BAD_ROLE 0300000812345678], [0], [dnl
00000000 03 01 00 14 12 34 56 78-00 0b 00 02 03 00 00 08 @&t@ 00000000 03 01 00 14 12 34 56 78-00 0b 00 02 03 00 00 08
00000010 12 34 56 78 @&t@ 00000010 12 34 56 78
]) ])
AT_CLEANUP AT_CLEANUP
@ -190,18 +190,18 @@ AT_KEYWORDS([ofp-print ofp-errors])
# correctly using the standard experimenter format in OF1.2. # correctly using the standard experimenter format in OF1.2.
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0100000812345678], [0], [dnl [ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0100000812345678], [0], [dnl
00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ 00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 01 02 03 01 00 00 08-12 34 56 78 @&t@ 00000010 00 01 02 03 01 00 00 08-12 34 56 78
]) ])
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0200000812345678], [0], [dnl [ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0200000812345678], [0], [dnl
00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ 00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 01 02 03 02 00 00 08-12 34 56 78 @&t@ 00000010 00 01 02 03 02 00 00 08-12 34 56 78
]) ])
AT_CHECK( AT_CHECK(
[ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0300000812345678], [0], [dnl [ovs-ofctl encode-error-reply NXBRC_MUST_BE_ZERO 0300000812345678], [0], [dnl
00000000 03 01 00 18 12 34 56 78-ff ff 00 04 00 00 23 20 @&t@ 00000000 03 01 00 18 12 34 56 78-ff ff 00 04 00 00 23 20
00000010 03 00 00 08 12 34 56 78- 00000010 03 00 00 08 12 34 56 78
]) ])
# Check that OFPERR_OFPBIC_DUP_INST is: # Check that OFPERR_OFPBIC_DUP_INST is:
@ -211,24 +211,24 @@ AT_CHECK(
# - encoded in the standard form in OF1.4. # - encoded in the standard form in OF1.4.
AT_CHECK( AT_CHECK(
[ovs-ofctl '-vPATTERN:console:%c|%p|%m' encode-error-reply OFPBIC_DUP_INST 0100000812345678], [0], [dnl [ovs-ofctl '-vPATTERN:console:%c|%p|%m' encode-error-reply OFPBIC_DUP_INST 0100000812345678], [0], [dnl
00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ 00000000 01 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 01 02 09 01 00 00 08-12 34 56 78 @&t@ 00000010 00 01 02 09 01 00 00 08-12 34 56 78
], [ofp_errors|ERR|cannot encode OFPBIC_DUP_INST for OpenFlow 1.0 ], [ofp_errors|ERR|cannot encode OFPBIC_DUP_INST for OpenFlow 1.0
]) ])
AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0200000812345678], [0], AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0200000812345678], [0],
[00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20 @&t@ [00000000 02 01 00 1c 12 34 56 78-b0 c2 00 00 00 00 23 20
00000010 00 03 01 00 02 00 00 08-12 34 56 78 @&t@ 00000010 00 03 01 00 02 00 00 08-12 34 56 78
]) ])
AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0300000812345678], [0], AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0300000812345678], [0],
[00000000 03 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00 @&t@ [00000000 03 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00
00000010 03 00 00 08 12 34 56 78- 00000010 03 00 00 08 12 34 56 78
]) ])
AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0400000812345678], [0], AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0400000812345678], [0],
[00000000 04 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00 @&t@ [00000000 04 01 00 18 12 34 56 78-ff ff 0a 28 4f 4e 46 00
00000010 04 00 00 08 12 34 56 78- 00000010 04 00 00 08 12 34 56 78
]) ])
AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0500000812345678], [0], AT_CHECK([ovs-ofctl encode-error-reply OFPBIC_DUP_INST 0500000812345678], [0],
[00000000 05 01 00 14 12 34 56 78-00 03 00 09 05 00 00 08 @&t@ [00000000 05 01 00 14 12 34 56 78-00 03 00 09 05 00 00 08
00000010 12 34 56 78 @&t@ 00000010 12 34 56 78
]) ])
AT_CLEANUP AT_CLEANUP

View File

@ -3,49 +3,49 @@ AT_BANNER([OpenFlow utilities])
AT_SETUP([encoding hellos]) AT_SETUP([encoding hellos])
dnl All versions up to a max version supported: dnl All versions up to a max version supported:
AT_CHECK([ovs-ofctl encode-hello 0x2], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x2], [0], [dnl
00000000 01 00 00 08 00 00 00 01- 00000000 01 00 00 08 00 00 00 01
OFPT_HELLO (xid=0x1): OFPT_HELLO (xid=0x1):
version bitmap: 0x01 version bitmap: 0x01
]) ])
AT_CHECK([ovs-ofctl encode-hello 0x6], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x6], [0], [dnl
00000000 02 00 00 08 00 00 00 01- 00000000 02 00 00 08 00 00 00 01
OFPT_HELLO (OF1.1) (xid=0x1): OFPT_HELLO (OF1.1) (xid=0x1):
version bitmap: 0x01, 0x02 version bitmap: 0x01, 0x02
]) ])
AT_CHECK([ovs-ofctl encode-hello 0xe], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0xe], [0], [dnl
00000000 03 00 00 08 00 00 00 01- 00000000 03 00 00 08 00 00 00 01
OFPT_HELLO (OF1.2) (xid=0x1): OFPT_HELLO (OF1.2) (xid=0x1):
version bitmap: 0x01, 0x02, 0x03 version bitmap: 0x01, 0x02, 0x03
]) ])
AT_CHECK([ovs-ofctl encode-hello 0x1e], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x1e], [0], [dnl
00000000 04 00 00 08 00 00 00 01- 00000000 04 00 00 08 00 00 00 01
OFPT_HELLO (OF1.3) (xid=0x1): OFPT_HELLO (OF1.3) (xid=0x1):
version bitmap: 0x01, 0x02, 0x03, 0x04 version bitmap: 0x01, 0x02, 0x03, 0x04
]) ])
AT_CHECK([ovs-ofctl encode-hello 0x3e], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x3e], [0], [dnl
00000000 05 00 00 08 00 00 00 01- 00000000 05 00 00 08 00 00 00 01
OFPT_HELLO (OF1.4) (xid=0x1): OFPT_HELLO (OF1.4) (xid=0x1):
version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05 version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05
]) ])
dnl Some versions below max version missing. dnl Some versions below max version missing.
AT_CHECK([ovs-ofctl encode-hello 0xc], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0xc], [0], [dnl
00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 0c @&t@ 00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 0c
OFPT_HELLO (OF1.2) (xid=0x1): OFPT_HELLO (OF1.2) (xid=0x1):
version bitmap: 0x02, 0x03 version bitmap: 0x02, 0x03
]) ])
AT_CHECK([ovs-ofctl encode-hello 0xa], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0xa], [0], [dnl
00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 0a @&t@ 00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 0a
OFPT_HELLO (OF1.2) (xid=0x1): OFPT_HELLO (OF1.2) (xid=0x1):
version bitmap: 0x01, 0x03 version bitmap: 0x01, 0x03
]) ])
AT_CHECK([ovs-ofctl encode-hello 0x8], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x8], [0], [dnl
00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 08 @&t@ 00000000 03 00 00 10 00 00 00 01-00 01 00 08 00 00 00 08
OFPT_HELLO (OF1.2) (xid=0x1): OFPT_HELLO (OF1.2) (xid=0x1):
version bitmap: 0x03 version bitmap: 0x03
]) ])
AT_CHECK([ovs-ofctl encode-hello 0x4], [0], [dnl AT_CHECK([ovs-ofctl encode-hello 0x4], [0], [dnl
00000000 02 00 00 10 00 00 00 01-00 01 00 08 00 00 00 04 @&t@ 00000000 02 00 00 10 00 00 00 01-00 01 00 08 00 00 00 04
OFPT_HELLO (OF1.1) (xid=0x1): OFPT_HELLO (OF1.1) (xid=0x1):
version bitmap: 0x02 version bitmap: 0x02
]) ])

View File

@ -2443,30 +2443,30 @@ NXOXM_ET_DP_HASH_W(01234567/0fffffff)
# in OF1.5. # in OF1.5.
AT_CHECK([ovs-ofctl -m --strict parse-oxm OpenFlow15 < oxm.txt], [0], [dnl AT_CHECK([ovs-ofctl -m --strict parse-oxm OpenFlow15 < oxm.txt], [0], [dnl
NXOXM_ET_DP_HASH(01234567) NXOXM_ET_DP_HASH(01234567)
00000000 00 01 00 10 ff ff 00 08-00 00 23 20 01 23 45 67 @&t@ 00000000 00 01 00 10 ff ff 00 08-00 00 23 20 01 23 45 67
NXOXM_ET_DP_HASH(01234567) NXOXM_ET_DP_HASH(01234567)
00000000 00 01 00 10 ff ff 00 08-00 00 23 20 01 23 45 67 @&t@ 00000000 00 01 00 10 ff ff 00 08-00 00 23 20 01 23 45 67
NXOXM_ET_DP_HASH_W(01234567/0fffffff) NXOXM_ET_DP_HASH_W(01234567/0fffffff)
00000000 00 01 00 14 ff ff 01 0c-00 00 23 20 01 23 45 67 @&t@ 00000000 00 01 00 14 ff ff 01 0c-00 00 23 20 01 23 45 67
00000010 0f ff ff ff 00 00 00 00- 00000010 0f ff ff ff 00 00 00 00
NXOXM_ET_DP_HASH_W(01234567/0fffffff) NXOXM_ET_DP_HASH_W(01234567/0fffffff)
00000000 00 01 00 14 ff ff 01 0c-00 00 23 20 01 23 45 67 @&t@ 00000000 00 01 00 14 ff ff 01 0c-00 00 23 20 01 23 45 67
00000010 0f ff ff ff 00 00 00 00- 00000010 0f ff ff ff 00 00 00 00
]) ])
# Then verify that both forms are accepted and NXM_NX_DP_HASH is encoded # Then verify that both forms are accepted and NXM_NX_DP_HASH is encoded
# in OF1.2. # in OF1.2.
AT_CHECK([ovs-ofctl -m --strict parse-oxm OpenFlow12 < oxm.txt], [0], [dnl AT_CHECK([ovs-ofctl -m --strict parse-oxm OpenFlow12 < oxm.txt], [0], [dnl
NXM_NX_DP_HASH(01234567) NXM_NX_DP_HASH(01234567)
00000000 00 01 00 0c 00 01 46 04-01 23 45 67 00 00 00 00 @&t@ 00000000 00 01 00 0c 00 01 46 04-01 23 45 67 00 00 00 00
NXM_NX_DP_HASH(01234567) NXM_NX_DP_HASH(01234567)
00000000 00 01 00 0c 00 01 46 04-01 23 45 67 00 00 00 00 @&t@ 00000000 00 01 00 0c 00 01 46 04-01 23 45 67 00 00 00 00
NXM_NX_DP_HASH_W(01234567/0fffffff) NXM_NX_DP_HASH_W(01234567/0fffffff)
00000000 00 01 00 10 00 01 47 08-01 23 45 67 0f ff ff ff @&t@ 00000000 00 01 00 10 00 01 47 08-01 23 45 67 0f ff ff ff
NXM_NX_DP_HASH_W(01234567/0fffffff) NXM_NX_DP_HASH_W(01234567/0fffffff)
00000000 00 01 00 10 00 01 47 08-01 23 45 67 0f ff ff ff @&t@ 00000000 00 01 00 10 00 01 47 08-01 23 45 67 0f ff ff ff
]) ])
AT_CLEANUP AT_CLEANUP