unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* system test for kmod and/or pure-Guile Linux module loader
@ 2018-03-04 17:28 Danny Milosavljevic
  2018-03-05  9:28 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2018-03-04 17:28 UTC (permalink / raw)
  To: guix-devel, ludo


[-- Attachment #1.1: Type: text/plain, Size: 428 bytes --]

Hi,

so I'm trying to write system tests for kmod (for now).

The tests of the kmod package are disabled because they load/unload kernel
modules - which is not what a build container is supposed to be
doing.

gnu/tests/linux.scm is attached.

I get this message:

guix build: error: build failed: creating directory `/gnu/store/.links': Read-only

although I tried to use my own store fs.  What am I doing wrong?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: linux.scm --]
[-- Type: text/x-scheme, Size: 4758 bytes --]

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.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 (gnu tests linux)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages linux)
  #:use-module (gnu packages package-management)
  #:use-module (gnu tests)
  #:use-module (gnu system)
  #:use-module (gnu system file-systems)
  #:use-module (gnu system shadow)
  #:use-module (gnu system vm)
  #:use-module (gnu services)
  #:use-module (gnu services base)
  #:use-module (guix gexp)
  #:use-module (guix store)
  #:export (%test-linux))

(define (operating-system-with-current-guix-marionette os)
  "Return a variant of OS that uses the current Guix."
  (operating-system
    (inherit os)
    (services (cons (service marionette-service-type
                             (marionette-configuration
                              (imported-modules '((gnu services herd)
                                                  (guix combinators)))))
               (modify-services (operating-system-user-services os)
                 (guix-service-type config =>
                                    (guix-configuration
                                     (inherit config)
                                     (guix (current-guix)))))))))

(define* %linux-os
  ;; Return operating system under test.
  (let ((base-os (simple-operating-system)))
    (operating-system
      (inherit (operating-system-with-current-guix-marionette base-os))
      (packages (cons* (operating-system-packages base-os))))))

(define (run-linux-test linux-os)
  "Run tests in LINUX-OS."
  ;(define os
  ;  (marionette-operating-system
  ;   linux-os
  ;   #:imported-modules '((guix combinators))))
  (define vm
    (virtual-machine
      (operating-system (operating-system (inherit linux-os)

      (file-systems (cons* (file-system
                            (device "root-fs")
                            (title 'label)
                            (mount-point "/")
                            (type "ext4"))
                           (file-system
                            (device "store-fs")
                            (title 'label)
                            (mount-point "/gnu")
                            (type "ext4"))
                           %base-file-systems)))

      )
      (memory-size 512)))

  (define (test kmod)
    "Test the given KMOD package.  KMOD is the name of the kmod package."
    (with-imported-modules '((gnu build marionette))
      #~(begin
          (use-modules (srfi srfi-11) (srfi srfi-64)
                       (gnu build marionette))

          (define marionette
            (make-marionette (list #$vm)))

          (mkdir #$output)
          (chdir #$output)

          (test-begin #$kmod)
          (test-assert "kmod tests work"
            (marionette-eval
             '(begin
                (use-modules (ice-9 popen) (ice-9 rdelim) (ice-9 ftw))
                (system* "guix" "build" "--keep-failed" "-e"
                         (string-append "((@ (guix packages) test-failing-package) " #$kmod ")"))
                (display "XXXXXXXXXXXX ")
                (display (scandir "/tmp"))
                (newline)
                (force-output)
                (chdir
                 (car
                  (filter-map (lambda (basename)
                                (if (string-prefix? "guix-build-kmod-" basename)
                                    (string-append "/tmp/" basename)
                                    #f))
                              (scandir "/tmp"))))
                (zero? (system* "make" "check")))
             marionette))
          (test-end)
          (exit (= (test-runner-fail-count (test-runner-current)) 0)))))

  (gexp->derivation "linux-test" (test "kmod")))

(define %test-linux
  (system-test
   (name "linux")
   (description "Test Linux.")
   (value (run-linux-test %linux-os))))

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: system test for kmod and/or pure-Guile Linux module loader
  2018-03-04 17:28 system test for kmod and/or pure-Guile Linux module loader Danny Milosavljevic
@ 2018-03-05  9:28 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-03-05  9:28 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> so I'm trying to write system tests for kmod (for now).
>
> The tests of the kmod package are disabled because they load/unload kernel
> modules - which is not what a build container is supposed to be
> doing.

Good idea.

> gnu/tests/linux.scm is attached.
>
> I get this message:
>
> guix build: error: build failed: creating directory `/gnu/store/.links': Read-only
>
> although I tried to use my own store fs.  What am I doing wrong?

The VMs in system tests use a read-only, 9p-mounted store, which may be
the reason you see this.  (That means you cannot build anything in that
store.)

The tests in (gnu tests install) use standalone VMs with a separate
store.  Perhaps you should do something like that?

HTH,
Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-05  9:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-04 17:28 system test for kmod and/or pure-Guile Linux module loader Danny Milosavljevic
2018-03-05  9:28 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).