| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | (define-module (tests services linux)
|
| 21 | #:use-module (ice-9 match)
|
| 22 | #:use-module (gnu packages linux)
|
| 23 | #:use-module (gnu services linux)
|
| 24 | #:use-module (guix gexp)
|
| 25 | #:use-module (srfi srfi-64))
|
| 26 |
|
| 27 | |
| 28 |
|
| 29 | (test-begin "linux-services")
|
| 30 |
|
| 31 |
|
| 32 | |
| 33 | |
| 34 | |
| 35 |
|
| 36 | (define earlyoom-configuration->command-line-args
|
| 37 | (@@ (gnu services linux) earlyoom-configuration->command-line-args))
|
| 38 |
|
| 39 | (define %earlyoom-configuration-sample
|
| 40 | (earlyoom-configuration
|
| 41 | (minimum-available-memory 10)
|
| 42 | (minimum-free-swap 20)
|
| 43 | (prefer-regexp "icecat")
|
| 44 | (avoid-regexp "guix-daemon")
|
| 45 | (memory-report-interval 60)
|
| 46 | (ignore-positive-oom-score-adj? #f)
|
| 47 | (run-with-higher-priority? #t)
|
| 48 | (show-debug-messages? #f)
|
| 49 | (send-notification-command "python \"/some/path/notify-all-users.py\"")))
|
| 50 |
|
| 51 | (test-equal "earlyoom-configuration->command-line-args"
|
| 52 | (list (file-append earlyoom "/bin/earlyoom")
|
| 53 | "-m" "10" "-s" "20" "--prefer" "icecat"
|
| 54 | "--avoid" "guix-daemon" "-r" "60" "-p"
|
| 55 | "-N" "python \"/some/path/notify-all-users.py\"")
|
| 56 | (earlyoom-configuration->command-line-args %earlyoom-configuration-sample))
|
| 57 |
|
| 58 |
|
| 59 | |
| 60 | |
| 61 | |
| 62 |
|
| 63 | (define zram-device-configuration->udev-string
|
| 64 | (@@ (gnu services linux) zram-device-configuration->udev-string))
|
| 65 |
|
| 66 | (define %zram-swap-device-test-1
|
| 67 | (zram-device-configuration
|
| 68 | (size "2G")
|
| 69 | (compression-algorithm 'zstd)
|
| 70 | (memory-limit "1G")
|
| 71 | (priority 42)))
|
| 72 |
|
| 73 | (test-equal "zram-swap-device-test-1"
|
| 74 | "KERNEL==\"zram0\", ATTR{comp_algorithm}=\"zstd\" ATTR{disksize}=\"2G\" ATTR{mem_limit}=\"1G\" RUN+=\"/run/current-system/profile/sbin/mkswap /dev/zram0\" RUN+=\"/run/current-system/profile/sbin/swapon --priority 42 /dev/zram0\"\n"
|
| 75 | (zram-device-configuration->udev-string %zram-swap-device-test-1))
|
| 76 |
|
| 77 | (define %zram-swap-device-test-2
|
| 78 | (zram-device-configuration
|
| 79 | (size 1048576) |
| 80 | (compression-algorithm 'lz4)))
|
| 81 |
|
| 82 | (test-equal "zram-swap-device-test-2"
|
| 83 | "KERNEL==\"zram0\", ATTR{comp_algorithm}=\"lz4\" ATTR{disksize}=\"1048576\" RUN+=\"/run/current-system/profile/sbin/mkswap /dev/zram0\" RUN+=\"/run/current-system/profile/sbin/swapon /dev/zram0\"\n"
|
| 84 | (zram-device-configuration->udev-string %zram-swap-device-test-2))
|
| 85 |
|
| 86 | (define %zram-swap-device-test-3
|
| 87 | (zram-device-configuration
|
| 88 | (memory-limit (* 512 1000))))
|
| 89 |
|
| 90 | (test-equal "zram-swap-device-test-3"
|
| 91 | "KERNEL==\"zram0\", ATTR{comp_algorithm}=\"lzo\" ATTR{disksize}=\"1G\" ATTR{mem_limit}=\"512000\" RUN+=\"/run/current-system/profile/sbin/mkswap /dev/zram0\" RUN+=\"/run/current-system/profile/sbin/swapon /dev/zram0\"\n"
|
| 92 | (zram-device-configuration->udev-string %zram-swap-device-test-3))
|
| 93 |
|
| 94 | (test-end "linux-services")
|