diff options
| author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2023-01-21 15:04:09 -0500 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2023-02-19 21:13:23 -0500 |
| commit | 598f4c509bbfec2b983a8ee246cce0a0fe45ec7f (patch) | |
| tree | 1bf799843929f714428c27eb2325c255a92793f3 /tests/rpm.scm | |
| parent | ac1d530d56c1a259630c8873b2281033878a4acb (diff) | |
pack: Add RPM format.
* guix/rpm.scm: New file.
* guix/scripts/pack.scm (rpm-archive): New procedure.
(%formats): Register it.
(show-formats): Add it.
(guix-pack): Register supported extra-options for the rpm format.
* tests/pack.scm (rpm-for-tests): New variable.
("rpm archive can be installed/uninstalled"): New test.
* tests/rpm.scm: New test.
* doc/guix.texi (Invoking guix pack): Document it.
Diffstat (limited to 'tests/rpm.scm')
| -rw-r--r-- | tests/rpm.scm | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/rpm.scm b/tests/rpm.scm new file mode 100644 index 00000000000..f40b36fe603 --- /dev/null +++ b/tests/rpm.scm | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (test-rpm) | ||
| 20 | #:use-module (guix rpm) | ||
| 21 | #:use-module (rnrs bytevectors) | ||
| 22 | #:use-module (srfi srfi-1) | ||
| 23 | #:use-module (srfi srfi-26) | ||
| 24 | #:use-module (srfi srfi-64) | ||
| 25 | #:use-module (srfi srfi-71)) | ||
| 26 | |||
| 27 | ;; For white-box testing. | ||
| 28 | (define-syntax-rule (expose-internal name) | ||
| 29 | (define name (@@ (guix rpm) name))) | ||
| 30 | |||
| 31 | (expose-internal RPMTAG_ARCH) | ||
| 32 | (expose-internal RPMTAG_LICENSE) | ||
| 33 | (expose-internal RPMTAG_NAME) | ||
| 34 | (expose-internal RPMTAG_OS) | ||
| 35 | (expose-internal RPMTAG_RELEASE) | ||
| 36 | (expose-internal RPMTAG_SUMMARY) | ||
| 37 | (expose-internal RPMTAG_VERSION) | ||
| 38 | (expose-internal header-entry-count) | ||
| 39 | (expose-internal header-entry-tag) | ||
| 40 | (expose-internal header-entry-value) | ||
| 41 | (expose-internal header-entry?) | ||
| 42 | (expose-internal make-header) | ||
| 43 | (expose-internal make-header-entry) | ||
| 44 | (expose-internal make-header-index+data) | ||
| 45 | |||
| 46 | (test-begin "rpm") | ||
| 47 | |||
| 48 | (test-equal "lead must be 96 bytes long" | ||
| 49 | 96 | ||
| 50 | (length (generate-lead "hello-2.12.1"))) | ||
| 51 | |||
| 52 | (define header-entries | ||
| 53 | (list (make-header-entry RPMTAG_NAME 1 "hello") | ||
| 54 | (make-header-entry RPMTAG_VERSION 1 "2.12.1") | ||
| 55 | (make-header-entry RPMTAG_RELEASE 1 "0") | ||
| 56 | (make-header-entry RPMTAG_SUMMARY 1 | ||
| 57 | "Hello, GNU world: An example GNU package") | ||
| 58 | (make-header-entry RPMTAG_LICENSE 1 "GPL 3 or later") | ||
| 59 | (make-header-entry RPMTAG_OS 1 "Linux") | ||
| 60 | (make-header-entry RPMTAG_ARCH 1 "x86_64"))) | ||
| 61 | |||
| 62 | (define expected-header-index-length | ||
| 63 | (* 16 (length header-entries))) ;16 bytes per index entry | ||
| 64 | |||
| 65 | (define expected-header-data-length | ||
| 66 | (+ (length header-entries) ;to account for null bytes | ||
| 67 | (fold + 0 (map (compose string-length (cut header-entry-value <>)) | ||
| 68 | header-entries)))) | ||
| 69 | |||
| 70 | (let ((index data (make-header-index+data header-entries))) | ||
| 71 | (test-equal "header index" | ||
| 72 | expected-header-index-length | ||
| 73 | (length index)) | ||
| 74 | |||
| 75 | ;; This test depends on the fact that only STRING entries are used, and that | ||
| 76 | ;; they are composed of single byte characters and the delimiting null byte. | ||
| 77 | (test-equal "header data" | ||
| 78 | expected-header-data-length | ||
| 79 | (length data))) | ||
| 80 | |||
| 81 | (test-equal "complete header section" | ||
| 82 | (+ 16 ;leading magic + count bytes | ||
| 83 | expected-header-index-length expected-header-data-length) | ||
| 84 | (length (make-header header-entries))) | ||
| 85 | |||
| 86 | (test-end) | ||
