-
Notifications
You must be signed in to change notification settings - Fork 37
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
src/lib.rs doctest fails on s390x / IBM System Z (big endian) #77
Comments
@decathorpe darn i thought i responded to this; so yea, this is an easy fix; the example is wrong :) and your analysis is correct:
this needs to be fixed; note we read at offset 2 in the I think this will fix:
other examples that read at an offset into the big/little endian array also likely need to be fixed. If you have the ability to test this, would you be able to make a PR with the fixes? :) |
Thanks! I'll apply your suggested fix and if it works on all architectures I have access to, I'll prepare a PR. |
Oh. Interesting. The first failure is fixed, but then the next one confuses me:
This fails on s390x with this error message:
This assertion expects |
Ah nope that’s correct return too :) so on little endian architectures it reads out correctly deadbeef if we read it out big endian style. On big endian architectures if we read it big endian then the bytes appear as they are left to right, which is efbeadde. So it and the u16 read also will need cfgs to alter their output depending on whether it’s little or big. So basically same fix. Because the bytes themselves are basically the opposite of whichever arch would read them naturally in memory, each non zero offset non byte read of the bytes is swapped and opposite and needs a cfg |
And the first example of reading the u32 without an endian specifier is correct because it defaults to host endianness so it is correct in both cases. It might be good to swap the read snd not the assert so if it’s a big endian arch we read out LE and if little we read BE. That way in either case we assert it’s equal to deadbeef Ditto for the u16 read |
I'm apparently unable to figure out how to do this correctly ... sorry. LE / BE stuff always ties my brain in knots. |
@decathorpe you can try latest master to see if the lib.rs doc tests now pass on this BE system; please reopen if you test and find other issues, and thanks again! |
https://github.com/m4b/scroll/blob/master/src/lib.rs#L55
All other tests and doctests pass. So it looks like the example data that's defined for the example is wrong / typo'd?
It's hard for me to tell with assertion is actually triggering the panic, because the line numbers inside the doctest are messed up (probably due to the #cfgs), but I think it's this one:
assert_eq!(byte, 0xbe);
(matching the190 / BE
"right" side in the assertion)The text was updated successfully, but these errors were encountered: