aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 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-workers)
  #:use-module (guix workers)
  #:use-module (ice-9 threads)
  #:use-module (srfi srfi-64))

(test-begin "workers")

(test-equal "enqueue"
  4242
  (let* ((pool   (make-pool))
         (result 0)
         (1+!    (let ((lock (make-mutex)))
                   (lambda ()
                     (with-mutex lock
                       (set! result (+ result 1)))))))
    (let loop ((i 4242))
      (unless (zero? i)
        (pool-enqueue! pool 1+!)
        (loop (- i 1))))
    (let poll ()
      (unless (pool-idle? pool)
        (pk 'busy result)
        (sleep 1)
        (poll)))
    result))

;; Same as above, but throw exceptions within the workers and make sure they
;; remain alive.
(test-equal "exceptions"
  4242
  (let* ((pool   (make-pool 10))
         (result 0)
         (1+!    (let ((lock (make-mutex)))
                   (lambda ()
                     (with-mutex lock
                       (set! result (+ result 1)))))))
    (let loop ((i 10))
      (unless (zero? i)
        (pool-enqueue! pool (lambda ()
                              (throw 'whatever)))
        (loop (- i 1))))
    (let loop ((i 4242))
      (unless (zero? i)
        (pool-enqueue! pool 1+!)
        (loop (- i 1))))
    (let poll ()
      (unless (pool-idle? pool)
        (pk 'busy result)
        (sleep 1)
        (poll)))
    result))

(test-end)
Ludovic Courtès 2018-06-26vm: Don't try to modify the bind-mounted store....Ludovic Courtès 2018-06-14Remove 'guix-register' and its traces....Ludovic Courtès 2018-06-14install: Use 'reset-timestamps' from (guix store database)....Ludovic Courtès 2018-06-14install: Use (guix store database) instead of 'guix-register'....Ludovic Courtès 2018-05-25vm: Pass "panic=1" to Linux....Ludovic Courtès 2018-05-23vm: Print the label and UUID of partitions....Ludovic Courtès 2018-03-24gnu: When building in a VM, share a temporary directory....Chris Marusich 2018-03-24vm: Allow control of deduplication in root-partition-initializer....Chris Marusich 2018-03-16vm: Pass "-append ..." only once....Danny Milosavljevic 2018-03-15vm: Use 'invoke' instead of 'system*'....Ludovic Courtès 2018-01-19gnu: Consistently Write ‘file system(s)’....Tobias Geerinckx-Rice 2017-12-18vm: Pass the host's /dev/urandom to the guest at /dev/hwrng....Leo Famulari 2017-12-15vm: Adapt qemu command to ARM....Mathieu Othacehe 2017-12-13vm: Use qemu drive device parameter....Mathieu Othacehe 2017-11-29vm: ISO9660 images include /etc and other standard files....Ludovic Courtès 2017-09-22build: Do not store two copies of the ISO-9660 superblock anymore....Danny Milosavljevic 2017-09-11file-systems: Introduce (gnu system uuid)....Ludovic Courtès 2017-09-11vm: Allow partitions to be initialized with a given UUID....Ludovic Courtès 2017-09-10vm: Add comment about deduplication in make-iso9660-image....Christopher Baines 2017-09-06vm: Create /mnt in the generated ISO image in make-iso9660-image....Christopher Baines 2017-09-06vm: Add support for registering closures to make-iso9660-image....Christopher Baines 2017-07-18vm: 'iso9660-image' produces a single-file output....Ludovic Courtès 2017-07-18vm: Increase disk size overhead estimate....Tobias Geerinckx-Rice 2017-07-17build, vm: Use a less common label....Tobias Geerinckx-Rice 2017-07-12build: Make ISO-9660 image bootable from USB flash drive....Danny Milosavljevic 2017-07-10build, vm: Use "GuixSD" or "GUIXSD" as volume label....Danny Milosavljevic 2017-07-03build: Add (gnu build file-systems) import....Danny Milosavljevic 2017-07-03build: Clarify error message when make-iso9660-image fails....Danny Milosavljevic 2017-07-03build: Allow specifying volume-uuid with make-iso9660-image....Danny Milosavljevic 2017-07-03build: Add iso9660 system image generator....Danny Milosavljevic 2017-06-30vm: Use 'fold2' from (guix combinators)....Ludovic Courtès 2017-06-30vm: Estimate the disk size by default....Ludovic Courtès 2017-06-30vm: Display the disk and partition sizes....Ludovic Courtès 2017-06-30vm: Fix 'load-in-linux-vm' docstring....Ludovic Courtès 2017-05-19vm: Add UEFI loader to disk images....Marius Bakke 2017-05-19vm: Support creating FAT partitions....Marius Bakke 2017-05-19vm: Support arbitrary partition flags....Marius Bakke 2017-05-16bootloader: Adapt vm to new bootloader API....Mathieu Othacehe