aboutsummaryrefslogtreecommitdiff
path: root/tests/workers.scm
blob: 4eaefbb43df67fa085ffee07a76aa976e0629968 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
;;; 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)
runtime_library.cmake") (("usr/") "")) (substitute* "lib/core/src/irods_default_paths.cpp" (("path.append\\(\"usr\"\\)") "path") (("path.remove_filename\\(\\).remove_filename\\(\\).remove_filename\\(\\)") "path.remove_filename().remove_filename()")) (substitute* "scripts/irods/paths.py" (("'usr', 'lib', 'irods'") "'lib', 'irods'")) (substitute* "scripts/irods/pypyodbc.py" (("\"/usr/lib/libodbc.so\"") (search-input-file inputs "/lib/libodbc.so"))))) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs #:allow-other-keys) (let ((gcc (assoc-ref inputs "gcc"))) (setenv "CPLUS_INCLUDE_PATH" (string-join (cons* (search-input-directory inputs "/include/c++/v1") (search-input-directory inputs "/include/catch2") (search-input-directory inputs "/include/nlohmann") ;; Hide GCC's C++ headers so that they do not interfere with ;; the Clang headers. (delete (string-append gcc "/include/c++") (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))) ":")) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH")))))))) (inputs `(("avro-cpp" ,avro-cpp-1.9-for-irods) ("boost" ,boost-for-irods) ("cppzmq" ,cppzmq) ("fmt" ,fmt-6) ("json" ,nlohmann-json) ("libarchive" ,libarchive) ("libcxxabi" ,libcxxabi-6) ; we need this for linking with -lc++abi ("linux-pam" ,linux-pam) ("mit-krb5" ,mit-krb5) ("nanodbc" ,nanodbc-for-irods) ("openssl" ,openssl) ("python" ,python-wrapper) ("unixodbc" ,unixodbc) ("zeromq" ,zeromq))) (native-inputs `(("catch2" ,catch2) ("clang" ,clang-toolchain-6) ("clang-runtime" ,clang-runtime-6) ("libcxx+libcxxabi" ,libcxx+libcxxabi-6))) (home-page "https://irods.org") (synopsis "Data management software") (description "The Integrated Rule-Oriented Data System (iRODS) is data management software. iRODS virtualizes data storage resources, so users can take control of their data, regardless of where and on what device the data is stored.") (license license:bsd-3))) (define-public irods-client-icommands (package (name "irods-client-icommands") (version "4.2.8") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/irods/irods_client_icommands") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "069n647p5ypf44gim8z26mwayg5lzgk7r9qyyqd8f9n7h0p4jxpn")))) (build-system cmake-build-system) (arguments `(#:tests? #false ; not clear how to run tests #:configure-flags (list "-DCMAKE_BUILD_TYPE=Release" ;; Configuration attempts to guess the distribution with Python. "-DIRODS_LINUX_DISTRIBUTION_NAME=guix" "-DIRODS_LINUX_DISTRIBUTION_VERSION_MAJOR=1" (string-append "-DIRODS_DIR=" (assoc-ref %build-inputs "irods") "/lib/irods/cmake") (string-append "-DIRODS_EXTERNALS_FULLPATH_CLANG=" (assoc-ref %build-inputs "clang")) (string-append "-DIRODS_EXTERNALS_FULLPATH_CLANG_RUNTIME=" (assoc-ref %build-inputs "clang-runtime")) (string-append "-DIRODS_EXTERNALS_FULLPATH_CPPZMQ=" (assoc-ref %build-inputs "cppzmq")) (string-append "-DIRODS_EXTERNALS_FULLPATH_ARCHIVE=" (assoc-ref %build-inputs "libarchive")) (string-append "-DIRODS_EXTERNALS_FULLPATH_AVRO=" (assoc-ref %build-inputs "avro-cpp")) (string-append "-DIRODS_EXTERNALS_FULLPATH_BOOST=" (assoc-ref %build-inputs "boost")) (string-append "-DIRODS_EXTERNALS_FULLPATH_ZMQ=" (assoc-ref %build-inputs "zeromq")) (string-append "-DIRODS_EXTERNALS_FULLPATH_JSON=" (assoc-ref %build-inputs "json")) (string-append "-DIRODS_EXTERNALS_FULLPATH_FMT=" (assoc-ref %build-inputs "fmt"))) #:phases (modify-phases %standard-phases (add-after 'unpack 'unset-Werror ; (lambda _ ; ;; -Werror kills the build due to a deprecation warning (substitute* "CMakeLists.txt" ; (("-Werror") "")))) (add-after 'unpack 'remove-/usr-prefix (lambda _ (substitute* "CMakeLists.txt" (("usr/") "")))) (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH (lambda* (#:key inputs #:allow-other-keys) (let ((gcc (assoc-ref inputs "gcc"))) (setenv "CPLUS_INCLUDE_PATH" (string-join (cons* (search-input-directory inputs "include/c++/v1") (search-input-directory inputs "include/nlohmann") ;; Hide GCC's C++ headers so that they do not interfere with ;; the Clang headers. (delete (string-append gcc "/include/c++") (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))) ":")) (format #true "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%" (getenv "CPLUS_INCLUDE_PATH")))))))) (inputs `(("avro-cpp" ,avro-cpp-1.9-for-irods) ("boost" ,boost-for-irods) ("cppzmq" ,cppzmq) ("fmt" ,fmt-6) ("irods" ,irods) ("json" ,nlohmann-json) ("libarchive" ,libarchive) ("libcxxabi" ,libcxxabi-6) ; we need this for linking with -lc++abi ("mit-krb5" ,mit-krb5) ("openssl" ,openssl) ("zeromq" ,zeromq))) (native-inputs `(("clang" ,clang-toolchain-6) ("clang-runtime" ,clang-runtime-6) ("libcxx+libcxxabi" ,libcxx+libcxxabi-6) ("help2man" ,help2man) ("which" ,which))) (home-page "https://irods.org") (synopsis "Data management software") (description "The Integrated Rule-Oriented Data System (iRODS) is data management software. iRODS virtualizes data storage resources, so users can take control of their data, regardless of where and on what device the data is stored.") (license license:bsd-3)))