New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test framework output improvement. #3357
Conversation
@dot-asm is this more along the lines you would like? The output from the new failure test case
is:
It isn't a great example but should indicate the kind of output. |
Three things:
Your example remade:
|
Nice suggestions, I'll implement them tomorrow. Somethings to think about in the meantime... Would Do we really want hex offsets for strings? For memory it makes sense and will be done. Would spaces between the bytes in memory dumps aid readability? I think they might. @dot-asm ? How many bytes per line for memory dumps? The code currently uses the largest multiple of 8 bytes (16 characters) that fits into an 80 character line. Would using a multiple of 16 bytes be better here? The indentation varies, so a fixed value isn't a great idea. I don't see a need to make the output as compact as possible. Better for it to be easy to understand. These messages are only going to appear when a test fails which should be rare. |
Whichever character you use to denote where the "left" and "right" expression differ, there's always going to be someone not understanding. If you choose I would say that hex offsets are usefull either way, ... and I dunno, I find it easier to read and to see how many bytes are displayed in each line that way. Spaces between bytes would certainly make it more readable. A really classic display is to have two sets of 8 bytes per line with a little extra space between the two sets, like this:
(that's 48 characters, spaces included) If you want to go really classic, there's the display of characters right after (and display everything non-ascii with a period):
(that's 68 characters, spaces included) |
There are at least sixteen characters at the start of the line too (at least four indentation spaces, #, space, eight hex digits, colon, space/+/-). I'll think of something. |
What's TAP? |
It's a tricky question. From my viewpoint it's not only about readability, but even utility. For example, how do you add additional longer vector to evptests.txt? You just make up one (by adding something to shorter input), add some junk to expected value (if/as necessary), run evp_test and copy "got" to expected. From this viewpoint denser printout is better (note that original is just single line ready to be copied-n-pasted), because it takes lesser tweaking. I'd also say that lack of spaces between bytes is well compensated by emphasis. So with these two in mind I for one would vote against space-separated bytes. [Nor do I see much value in ASCII transcript, because in most cases we are looking at cipher texts or hash values, i.e. nothing ASCII-able.] |
BTW, +1 for offsets and not printing equivalent chunks twice. |
Good points. |
I'd like to argue that it would be more appropriate to emphasize bytes in memory comparison. I mean above we can see that nibbles are emphasized, 2b vs. 2d with only b vs. d emphasized, rather than complete bytes. |
The current nibble emphasis is due to the way I put the output together -- memory is converted to hex and then displayed as a string. I did this because it was faster to implement and I'm seeking feedback at the moment (which has been great BTW, thanks). Given that the memory and string display/diff code will have to be separated, emphasising bytes in the former will be done properly. I do agree about the ASCII transcript not being required. As for readability spacing, I'm less convinced. A short script could convert a pasted block of output removing the leadins, the spaces and newlines and either the '+' or '-' lines to provide the required evptests.txt line. It would be an additional step, but that seems like an okay compromise for readability. If we do want the ability to paste directly into evptests.txt, the output will have to go back to long lines with the highlights below. I'm less keen on this but will go with it if it is the consensus. |
I'm not sure why string and memory display should be different... but also, I'm missing information on how they should be different. As for the space / no space debate, I can propose the following compromise:
i.e. an added space every 8th byte (16th char). When it comes to the highlight of differences, how about doing what you do now, but consider the hex characters in pairs? |
But still 32 bytes per line, right?
I.e. emphasize bytes, not nibbles. |
Do you mean that, i.e. 64 chars? Either way, I don't really care that much, just as long as it's consistent and recognisable. However, I would recommend to keep each space separated chunk relatively short, as keeping track of the bytes makes most people blurry eyed after a bit (I'm noticing that after about 16 hex char, I'm starting to lose track of nibble pairs, for example). So, we need to decide on chunk size. 8 or 16 chars (i.e. 4 or 8 bytes, or 32-bit and 64-bit values, where that's a valuable way to look at it) is fairly common in places where space separation of chunks is done. |
Yes. |
... and are you still talking chunked lines, i.e. something like this?
or are you talking about an undivided line?
As mentioned already, I prefer the former, for readability. |
As already said, to me emphasizing differences compensates for lack of spaces. Which means I don't have special opinion... Well, one can argue that it might be sensible to break at least at 16 bytes to kind of reflect the fact that most ciphers have 128-bit block size... [going off-line...] |
32 bytes (64 chars) will spill over 80 columns at times. A sub test will indent 8 not 4 e.g which pushes to the 80 and deeper nesting might be possible. Will Is this okay? Strings will be different from memory because they don't require hex conversion, highlight single characters and don't have formatting spaces added. I assume they'll be line wrapped and diffed still. |
4fb4400
to
0cbac73
Compare
I've updated the output code for strings and memory. I think I've caught all of the suggestions thus far. Strings are wrapped in sixteen byte lumps and fitted to an 80 column display. They are shown with single quotes which distinguishes the empty string. A NULL pointer is displayed as
Memory dumps are blocked per eight bytes with a space between blocks and fitted to an 80 column display. Byte differences are highlighted. NULL pointers are shown as
I haven't used full width fields for the size/offset numbers to allow more horizontal space. This means the difference highlight carets will go out of alignment for huge outputs. |
test/testutil/tests.c
Outdated
static void test_fail_message_va(const char *prefix, const char *file, int line, | ||
const char *type, const char *fmt, va_list ap) | ||
const char *type, const char *, const char *, | ||
const char *, const char *fmt, ...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the names left
, right
and op
here. They do serve as documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, tomorrow.
Have you given any thought to possible control characters in strings? Such as |
I did think about control characters and non-printables. They'll lead to the display of characters that aren't in the strings. Displaying
The space in the second string isn't real. Moreover, this is indistinguishable from a comparison of I'm fine to implement something so long as the shortcomings and loss of regular formatting are acceptable. Do non-printable strings appear in the tests? On success, I can't remember seeing any (not that that means much). On failure, further investigation will be required. @richsalz do you know? |
I haven't seen any control characters in tests, yet... but I prefer to be prepared. Glad you thought of it, I'm satisfied with that. |
Let's really fix it if/when it becomes an issue. |
I've added the argument names to the forward declaration of |
I could replace unprintable characters with a |
Sounds reasonable |
Okay, the update which displays non-printable characters as |
Format the test failure output more nicely. More vertical space is used to make things a little clearer. Tests are expected to pass so this doesn't impact the normal case. Strings and memory comparisons highlight differences.
The Travis failure is unrelated to this commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good enough for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me know if you want me to merge.
Merged. 516deca |
Format the test failure output more nicely. More vertical space is used to make things a little clearer. Tests are expected to pass so this doesn't impact the normal case. Strings and memory comparisons highlight differences. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from #3357)
Format the test failure output more nicely. More vertical space is used to make things a little clearer. Tests are expected to pass so this doesn't impact the normal case. Strings and memory comparisons highlight differences and break on sixteen character boundaries.
This is a first stab at better output, it is mutable.