diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-01-13 09:38:38 +0100 |
|---|---|---|
| committer | Rutherther <rutherther@ditigal.xyz> | 2026-01-25 21:25:40 +0100 |
| commit | 0c5d65d5400c6193571972451083baa66265ec5a (patch) | |
| tree | 170670c1dbd525e94d48d25a3fa8e1a5c455c21c /tests | |
| parent | 062f036fecf6db056feaaf127b5df1c39d49f5d8 (diff) | |
transformations: Add ‘--amd-gpu’ transformation option.
* guix/transformations.scm (split-on-commas): New procedure, moved from…
(transform-package-toolchain): … here.
(package-amd-gpu-specialization, transform-package-amd-gpu-targets): New
procedures.
(%transformations, %options): Add ‘amd-gpu’.
* tests/transformations.scm ("options->transformations, amd-gpu")
("options->transformations, amd-gpu, not applicable")
("options->transformations, amd-gpu, missing clang-rocm input")
("options->transformations, amd-gpu, wrong GPU"): New tests.
* doc/guix.texi (Package Transformation Options): Document it.
Change-Id: I56bf0dffbf12bc08cf6318fe56952473b395c303
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Merges: #5583
Signed-off-by: Rutherther <rutherther@ditigal.xyz>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/transformations.scm | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/transformations.scm b/tests/transformations.scm index 9f5aacc41b4..1db54a0e196 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2016-2017, 2019-2024 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2016-2017, 2019-2024, 2026 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2021 Marius Bakke <marius@gnu.org> | 3 | ;;; Copyright © 2021 Marius Bakke <marius@gnu.org> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| @@ -638,6 +638,45 @@ | |||
| 638 | (package->bag (t p)) | 638 | (package->bag (t p)) |
| 639 | #f))) | 639 | #f))) |
| 640 | 640 | ||
| 641 | (test-equal "options->transformations, amd-gpu" | ||
| 642 | '("gfx90a" "gfx942") | ||
| 643 | (let ((p (dummy-package "amd-gpu-code" | ||
| 644 | (native-inputs | ||
| 645 | (list (@ (gnu packages llvm) clang-rocm))) | ||
| 646 | (properties '((amd-gpu-targets . ("whatever")))))) | ||
| 647 | (t (options->transformation '((amd-gpu . ("gfx90a" "gfx942")))))) | ||
| 648 | (assoc-ref (package-properties (t p)) 'amd-gpu-targets))) | ||
| 649 | |||
| 650 | (test-equal "options->transformations, amd-gpu, not applicable" | ||
| 651 | #f | ||
| 652 | (let ((p (dummy-package "not-amd-gpu-code")) | ||
| 653 | (t (options->transformation '((amd-gpu . ("gfx90a" "gfx942")))))) | ||
| 654 | (assoc-ref (package-properties (t p)) 'amd-gpu-targets))) | ||
| 655 | |||
| 656 | (test-assert "options->transformations, amd-gpu, missing clang-rocm input" | ||
| 657 | (let ((p (dummy-package "amd-gpu-code" | ||
| 658 | (properties '((amd-gpu-targets . ("whatever")))))) | ||
| 659 | (t (options->transformation '((amd-gpu . ("generic")))))) | ||
| 660 | ;; Since 'clang-rocm' is not among the inputs, an error should be raised. | ||
| 661 | (guard (c ((formatted-message? c) | ||
| 662 | (string-contains (formatted-message-string c) | ||
| 663 | "no ROCm compiler"))) | ||
| 664 | (t p) | ||
| 665 | #f))) | ||
| 666 | |||
| 667 | (test-assert "options->transformations, amd-gpu, wrong GPU" | ||
| 668 | (let ((p (dummy-package "amd-gpu-code" | ||
| 669 | (native-inputs | ||
| 670 | (list (@ (gnu packages llvm) clang-rocm))) | ||
| 671 | (properties '((amd-gpu-targets . ("whatever")))))) | ||
| 672 | (t (options->transformation '((amd-gpu . ("does-not-exist")))))) | ||
| 673 | ;; Since this AMD GPU target is not known to 'clang-rocm', an error should | ||
| 674 | ;; be raised. | ||
| 675 | (guard (c ((formatted-message? c) | ||
| 676 | (member "does-not-exist" (formatted-message-arguments c)))) | ||
| 677 | (t p) | ||
| 678 | #f))) | ||
| 679 | |||
| 641 | (test-equal "options->transformation + package->manifest-entry" | 680 | (test-equal "options->transformation + package->manifest-entry" |
| 642 | '((transformations . ((without-tests . "foo")))) | 681 | '((transformations . ((without-tests . "foo")))) |
| 643 | (let* ((p (dummy-package "foo")) | 682 | (let* ((p (dummy-package "foo")) |
