aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2015, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-base32)
  #:use-module (gcrypt hash)
  #:use-module (guix base32)
  #:use-module (guix utils)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 match)
  #:use-module (rnrs bytevectors)
  #:use-module (rnrs io ports))

;; Test the (guix base32) module.

(test-begin "base32")

(test-assert "bytevector->base32-string"
  (fold (lambda (bv expected result)
          (and result
               (string=? (bytevector->base32-string bv)
                         expected)))
        #t

        ;; Examples from RFC 4648.
        (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))
        '(""
          "my"
          "mzxq"
          "mzxw6"
          "mzxw6yq"
          "mzxw6ytb"
          "mzxw6ytboi")))

(test-assert "base32-string->bytevector"
  (every (lambda (bv)
           (equal? (base32-string->bytevector
                    (bytevector->base32-string bv))
                   bv))
         ;; Examples from RFC 4648.
         (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))))

(test-assert "nix-base32-string->bytevector"
  (every (lambda (bv)
           (equal? (nix-base32-string->bytevector
                    (bytevector->nix-base32-string bv))
                   bv))
         ;; Examples from RFC 4648.
         (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))))

(test-equal "&invalid-base32-character"
  #\e
  (guard (c ((invalid-base32-character? c)
             (invalid-base32-character-value c)))
    (nix-base32-string->bytevector
     (string-append (make-string 51 #\a) "e"))))

(test-end)
in docstring....Ludovic Courtès 2020-12-21system: Allow separated /boot and encrypted root....Miguel Ángel Arruga Vivas 2020-11-26mapped-devices: Allow target to be list of strings....Mikhail Tsykalov 2020-11-02system: Change comment wording....Miguel Ángel Arruga Vivas 2020-11-01system: Add store-directory-prefix to boot-parameters....Miguel Ángel Arruga Vivas 2020-10-18system: Provide locale information to the bootloader....Miguel Ángel Arruga Vivas 2020-10-18system: Add locale to boot-parameters....Miguel Ángel Arruga Vivas 2020-10-15install: Deduplicate packages with %base-package sets....Efraim Flashner 2020-10-15system: Add %base-packages-disk-utilities....Efraim Flashner 2020-10-09system: hurd: Add PAM support with shadow and sudo....Jan (janneke) Nieuwenhuizen 2020-10-08system: Include 'guile-3.0-latest' in '%base-packages'....Ludovic Courtès 2020-09-07linux-boot: Handle nfs-root device strings....Stefan 2020-08-24system: Validate sudoers file when building the system....Ludovic Courtès 2020-07-29system: 'operating-system-with-provenance' uses the OS location info....Ludovic Courtès 2020-07-25Use 'formatted-message' instead of '&message' where appropriate....Ludovic Courtès 2020-07-25utils: Move <location> and '&error-location' to (guix diagnostics)....Ludovic Courtès 2020-07-15system: 'operating-system-root-file-system' raises upon missing root....Ludovic Courtès 2020-07-15system: Add 'location' field to <operating-system>....Ludovic Courtès 2020-07-05system: Do not use "hurd-target?"....Mathieu Othacehe 2020-07-03services: system-service-type: Add entries support for the Hurd....Jan (janneke) Nieuwenhuizen 2020-07-03system: 'read-boot-parameters' allow initrd to be missing....Jan (janneke) Nieuwenhuizen 2020-07-03system: 'read-boot-parameters' bugfix for multiboot....Jan (janneke) Nieuwenhuizen 2020-06-21system: Add 'sg' and 'newgrp' to %SETUID-PROGRAMS....Brice Waegeneire 2020-06-19hurd-boot: Use 'setxattr' instead of invoking settrans....Jan (janneke) Nieuwenhuizen 2020-06-09services: etc: Add '/etc/ttys' symlink for the Hurd....Jan (janneke) Nieuwenhuizen 2020-06-09system: Fix typo that breaks grub.cfg generation....Royce Strange 2020-06-08gnu: services: Add %hurd-startup-service....Jan (janneke) Nieuwenhuizen 2020-06-08system: hurd: Populate services....Jan (janneke) Nieuwenhuizen 2020-06-08services: hurd: Populate system profile....Jan (janneke) Nieuwenhuizen 2020-06-08services: Support etc-service for the Hurd....Jan (janneke) Nieuwenhuizen 2020-06-08system: Support activation service for the Hurd....Jan (janneke) Nieuwenhuizen 2020-06-08system: Use 'hurd' package in label....Jan (janneke) Nieuwenhuizen 2020-06-08system: Add 'multiboot-modules' field to <boot-parameters>....Jan (janneke) Nieuwenhuizen 2020-06-08system: Add 'hurd' field to <operating-system>....Jan (janneke) Nieuwenhuizen 2020-06-08system: hurd: Add hurd-default-essential-services....Jan (janneke) Nieuwenhuizen 2020-06-06system: 'system-linux-image-file-name' takes an optional parameter....Ludovic Courtès 2020-05-29bootloader: grub: Rename the btrfs-subvolume-file-name parameter....Maxim Cournoyer 2020-05-20bootloader: grub: Allow booting from a Btrfs subvolume....Maxim Cournoyer 2020-05-05Merge branch 'master' into core-updatesMarius Bakke 2020-05-05system: vm: Move operating-system-uuid....Mathieu Othacehe 2020-05-02Merge branch 'master' into core-updatesMarius Bakke