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

nixos/tests: add ROCm and amdvlk tests #200757

Merged
merged 3 commits into from
Nov 23, 2022
Merged

nixos/tests: add ROCm and amdvlk tests #200757

merged 3 commits into from
Nov 23, 2022

Conversation

Flakebi
Copy link
Member

@Flakebi Flakebi commented Nov 11, 2022

Description of changes

Testing ROCm and other software like amdvlk is slightly more difficult, because it needs hardware like GPUs to run on.
This PR adds some infrastructure – make-test-hardware.nix analogous to make-test-python.nix – that makes it easy to write such tests and run them by giving access to the host hardware into the nix build sandbox.

The tests added here are very basic and are meant more for demonstration of how it works (and smoke testing that nothing fundamental is broken).

The added tests can be run with

$(nix-build -A rocm-opencl-icd.impureTests)
$(nix-build -A amdvlk.impureTests)
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Nov 11, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Nov 11, 2022
@Madouura
Copy link
Contributor

I've been very sick for a bit now so I can't divert much energy to testing this ATM, but on the surface it looks fine.
I'm concerned on whether we can "legally" include the sandbox changes in the test itself in nixpkgs however.
cc @Mic92 for an authoritative answer on this.

@Madouura
Copy link
Contributor

Also, card0 is not guaranteed to be an AMD card, I think there should be some logic to ensure it is, and if it is not, if say, card1 exists, test that.

@Flakebi
Copy link
Member Author

Flakebi commented Nov 14, 2022

Thanks a lot for your comments!

Good point about hydra, I was not sure if it will run all tests by default.
As you suggested, I added a new attribute impureTests, that runs the script, so $(nix-build -A rocm-opencl-icd.impureTests) works.

It’s still using a derivation to run the actual test, so that it’s mostly isolated.
Most importantly, the test does not inherit the users environment variables and it runs in an isolated filesystem without the systems /run/opengl-driver.

@Madouura, I changed the /dev/dri/card* check to accept any card, good point. Get well soon!

Diff compared to the previous version.

nixos/tests/all-tests.nix Outdated Show resolved Hide resolved
nixos/tests/rocm-opencl.nix Outdated Show resolved Hide resolved
@Madouura Madouura mentioned this pull request Nov 14, 2022
34 tasks
@github-actions github-actions bot removed the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Nov 15, 2022
@Flakebi
Copy link
Member Author

Flakebi commented Nov 15, 2022

Putting the tests under the packages is a good idea to keep nixos/tests clean.

I added makeImpureTests to pkgs, like you suggested.

Add a function to create tests that use hardware from the host system
like GPUs.
@Flakebi
Copy link
Member Author

Flakebi commented Nov 22, 2022

Rebased and set teams.rocm.members as maintainer.

Copy link
Contributor

@Madouura Madouura left a comment

Choose a reason for hiding this comment

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

Ran the tests, LGTM.

@Mic92 Mic92 merged commit 83c19c7 into NixOS:master Nov 23, 2022
@Flakebi Flakebi deleted the rocm-test branch November 23, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants