Skip to content
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 case fixes for big-endian systems #48395

Closed
wants to merge 1 commit into from
Closed

Test case fixes for big-endian systems #48395

wants to merge 1 commit into from

Conversation

uweigand
Copy link
Contributor

  • Enable tests that were disabled on big-endian systems

  • Fix endian assumptions across various test cases

  • Update access to binary test data like UTF16 characters

  • Update reflection test cases accessing litte-endian PE images

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dnfadmin
Copy link

dnfadmin commented Feb 17, 2021

CLA assistant check
All CLA requirements met.

@ghost
Copy link

ghost commented Feb 17, 2021

Tagging subscribers to this area: @GrabYourPitchforks
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Enable tests that were disabled on big-endian systems

  • Fix endian assumptions across various test cases

  • Update access to binary test data like UTF16 characters

  • Update reflection test cases accessing litte-endian PE images

Author: uweigand
Assignees: -
Labels:

area-System.Memory

Milestone: -

@directhex directhex added the arch-s390x Related to s390x architecture (unsupported) label Feb 17, 2021
* Enable tests that were disabled on big-endian systems

* Fix endian assumptions across various test cases

* Update access to binary test data like UTF16 characters

* Update reflection test cases accessing litte-endian PE images
@ericstj
Copy link
Member

ericstj commented Feb 26, 2021

Adding some reviewers based on areas touched. Please divide as appropriate.

}
else
{
expected = (b4.B0 << 24) + (b4.B1 << 16) + (b4.B2 << 8) + (b4.B3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should instead have a test helper method that turns int32 and int64 from littleEndian to bigendian so that we don't have to duplicate shifting or checks and the expected value is only really ever written once in our tests. Similar to what you are doing in the BitConverteArray.cs tests where you just save to an array and then reverse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in BitConverterArray.cs it is more obvious how do those swaps, given that we're really operating on single scalar values (or arrays of the same type).

Here, the tests deliberately overlay multiple data types (modifying single bytes in a long, reading a pair of bytes as a short etc.), which seem inherently endian-sensitive. Since the intent of this test is exactly to verify that those aliased manipulations work as expected (where the "expected" behavior is explicitly endian-sensitive), it seemed to make more sense to me to verify the little- and big-endian results separately here.

If you have any specific suggestion of how to structure the tests differently, I'd be happy to implement and test ...

@joperezr
Copy link
Member

@ViktorHofer @ericstj should we consider adding a test queue that runs on big-endian machines so that all of these new test branches get coverage?

@ericstj
Copy link
Member

ericstj commented Feb 26, 2021

I was sharing with the infra crew that usually the order we go about these things is:

  1. Privately run tests.
  2. Submit a PR to suppress those that fail and file issues on areas to fix the product/tests.
  3. Enable CI to hold the line on support.
  4. Fix all the tests/product issues

@uweigand have you discussed running these tests with anyone? cc @directhex

@directhex
Copy link
Member

@ericstj we have a high pass rate for the changes in runtimelab - dotnet/runtimelab#679

The wrinkle here is:

  • This PR (and the other two) represent generic Big Endian fixes, which apply to any BE arch
  • The classlib already shows intent for supporting BE, and has various cases of handling it
  • No official MS-published architecture is BE, so no official arch we run CI on can validate BE changes. They've just been taken on faith, thus far

@ericstj
Copy link
Member

ericstj commented Feb 26, 2021

I see this is for https://github.com/dotnet/runtimelab/tree/feature/s390x

So the work to enable the runtime to build is happening in that branch. What's the reason for upstreaming the test changes?

@directhex
Copy link
Member

These changes apply for any BE architecture (e.g. POWER), they aren't specific to s390x. There's already hundreds of cases in the libraries/ code that attempt to deal with potentially big-endian runtimes - these are bug fixes against that existing code

@ericstj
Copy link
Member

ericstj commented Feb 26, 2021

I think we'd say the same thing about all those tests and unexercised code -- ideally we'd be testing it in CI as well. Mainly I wanted to understand what the expectation is of reviewers. It'd be nice to have a doc that describes the plan here as it looks like this same question has come up on multiple PRs that are part of this project: #44805 (comment)

Base automatically changed from master to main March 1, 2021 09:07
@uweigand
Copy link
Contributor Author

uweigand commented Mar 1, 2021

My reason for submitting these changes to runtime and not runtimelab (feature/s390x) is as @directhex mentioned: the existing runtime code attempts to handle big-endian platforms, and that code, while mostly correct, does have a few bugs -- some in the actual implementation and some in the test cases.

All changes in this PR are about tests that failed on big-endian systems, specifically s390x, and pass with the PR applied. I've verified this by running the tests manually, and there is now an automated CI on the runtimelab branch. Once s390x support is complete and stable, my hope is to get approval to merge all of it into runtime proper, at which point the CI would of course move there.

As to expectations on reviewers, speaking just for myself here, I'd much appreciate comments as to whether these changes are "correct" in the sense that the reason for the failing test was indeed an endian issue in the test case as opposed to the underlying implementation that is being tested. I think so --that I why I submitted the patch as it is-- but of course a review is always helpful.

@ghost
Copy link

ghost commented Mar 16, 2021

@uweigand , just a general comment from an observer (as I noticed that the review-process is kind of stuck) :

This PR is huge, and thus difficult to review.

From my experience, splitting one super-commit down to multiple (easy understandable) commits increases the chances of a quick and positive review.

Sometimes it is even better to provide multiple PRs (starting with those with the highest chances of acceptance, e.g. clear bug-fixes). This way you avoid that complex changes block the trivial ones to get merged.

All this is of course more work (for the patch provider), but less work for the patch reviewer.

@uweigand
Copy link
Contributor Author

@abebeos, thanks for the suggestion. I'll go ahead and split this into smaller PRs.

@uweigand
Copy link
Contributor Author

For reference, I've split out the following separate PRs:
#49688 (System.IO BinaryWriter)
#49689 (XML)
#49690 (System.Memory tests)
#49691 (System.Runtime tests)
#49692 (unsafe compiler services)
#49693 (System.Reflection tests)
#49694 (big-integer numerics)
#49695 (PKCS crypto)
#49696 (Visual Basic)
Closing this PR now.

@uweigand uweigand closed this Mar 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 15, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-s390x Related to s390x architecture (unsupported) area-Meta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants