How do you test intrinsics code in xunit?
I've been optimizing an existing project by taking slow methods and creating an intrinsics alternative, using the slower non intrinsics code as a fallback if intrinsics aren't supported. This project has tests already so I can verify that the intrinsics version works correctly. Unfortunately the original method is never run (on simd supported systems) so future changes may silently break.
How do you modify/write tests for both intrinsic and normal versions? I can think of a few ways but most seem cumbersome or not possible in xunit.
How do you modify/write tests for both intrinsic and normal versions? I can think of a few ways but most seem cumbersome or not possible in xunit.
- Creates copies of and rewrite all tests to test both intrinsic and original code- This would solve the problem but would mean rewriting a lot of tests and potentially creating duplicate tests in the future.
- Create a xunit config that runs with and without COMPlus_EnableAVX enabled - I don't know if this is possible in xunit.
- Rerun tests with COMPlus_EnableAVX environment variables set to disable intrinsics support. - As far as I can tell xunit does not support setting environment variables, I also don't know how to rerun entire test classes with the new variable set. I was originally going to use github actions to rerun the tests with different variables set - this would only work on push so tests may pass on your machine but fail of commit.