tests/cpio failure

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal
C
C
Christopher Baines wrote on 19 Dec 2022 15:44
(address . bug-guix@gnu.org)
871qovo3i3.fsf@cbaines.net
This test seems to fail, maybe because of high inode numbers, maybe
something to with btrfs.

I saw this with the failed builds here


cbaines@milano-guix-1 ~$ guix repl
GNU Guile 3.0.8
Copyright (C) 1995-2021 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> (use-modules (guix cpio))
scheme@(guix-user)> (file->cpio-header "guix/guix.scm")
$1 = #<<cpio-header> magic: 460545 ino: 5031515288 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>
scheme@(guix-user)> (use-modules (rnrs io ports))
scheme@(guix-user)> (define header $1)
scheme@(guix-user)> (call-with-values
(lambda ()
(open-bytevector-output-port))
(lambda (port get-bv)
(write-cpio-header header port)
(let ((port (open-bytevector-input-port (get-bv))))
(equal? header (read-cpio-header port)))))
$2 = #f
scheme@(guix-user)> (call-with-values
(lambda ()
(open-bytevector-output-port))
(lambda (port get-bv)
(write-cpio-header header port)
(let ((port (open-bytevector-input-port (get-bv))))
(equal? (peek "A" header)
(peek "B" (read-cpio-header port))))))

;;; ("A" #<<cpio-header> magic: 460545 ino: 5031515288 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>)

;;; ("B" #<<cpio-header> magic: 460545 ino: 736547992 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>)
$3 = #f
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmOgeURfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XcsXQ/+IpKoQFJ+yRd+fmrOShwFAL+Dt0TpiyEm
xD3o0kxhAKFBKC8mgMZK1WNdljdZMNxWcpid1WxoejMn7DgK23jLl2VMWMC7NGsd
BNLCf/6pNTUTP41w1D+CGtTPtkyqwr+DuKjMXm34mAxylnaQO7gP0TBLC798ERMy
cddABM667ydUMZINkehgHs+X9N9a01g12qB5uy02Ydl6GO2EMLNSenD0NHcqAGmt
4eKsMXK8X2Lw4rjz5ZZu+JUbDm4B8TqmHR99dOr9+IpWNPp8EqXoHS9PLIyGn8ek
EuSnEfMZTCcRmiQ+lG599/KpoXI+G1EW304BsjuohtGIANna4efNyASbBddOIYee
Kt0iSaW7xgfxBQLPN1wI29+lvCO2mYGXW8ftKIRFVOGWiQjkqqHQdAlm2PpskYYd
mRVnQXJcUCXJKlFdsaXJUQJlWV5pcdBz65WEglZNO4xl1obmINko5wm4jUkp4nir
ZYq38xmponPP2r3kGemDwiIYXOzl2mpJEiPBYhWZiHvT0CI8ZByWe5FaOJ0TjBN4
yonZhS9H083ewWKJx1LugvEejmywduTdGj5isO8GyuVnSSu3cbwDWaobzuASr2qc
8KetWEwR7Pl8pOXqee1v6r/m1VCnDsXQoxI9WavObsBpdCf6UrmtwBXyFk0TuyFC
+iwxXuChUWA=
=wgpT
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 19 Dec 2022 16:00
(name . Christopher Baines)(address . mail@cbaines.net)(address . 60202@debbugs.gnu.org)
87tu1rcubd.fsf@gnu.org
Hi,

Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (3 lines)
> This test seems to fail, maybe because of high inode numbers, maybe
> something to with btrfs.

Uh.

Toggle quote (3 lines)
> scheme@(guix-user)> (file->cpio-header "guix/guix.scm")
> $1 = #<<cpio-header> magic: 460545 ino: 5031515288 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>

[...]

Toggle quote (9 lines)
> (let ((port (open-bytevector-input-port (get-bv))))
> (equal? (peek "A" header)
> (peek "B" (read-cpio-header port))))))
>
> ;;; ("A" #<<cpio-header> magic: 460545 ino: 5031515288 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>)
>
> ;;; ("B" #<<cpio-header> magic: 460545 ino: 736547992 mode: 33188 uid: 1003 gid: 998 nlink: 1 mtime: 1671460627 file-size: 1452 dev-maj: 0 dev-min: 24 rdev-maj: 0 rdev-min: 0 name-size: 14 checksum: 0>)
> $3 = #f

(guix cpio) defines cpio headers like this:

Toggle snippet (19 lines)
(define-pack <cpio-header>
%make-cpio-header cpio-header?
write-cpio-header read-cpio-header
(magic 6 cpio-header-magic)
(ino 8 cpio-header-inode)
(mode 8 cpio-header-mode)
(uid 8 cpio-header-uid)
(gid 8 cpio-header-gid)
(nlink 8 cpio-header-nlink)
(mtime 8 cpio-header-mtime)
(file-size 8 cpio-header-file-size)
(dev-maj 8 cpio-header-device-major)
(dev-min 8 cpio-header-device-minor)
(rdev-maj 8 cpio-header-rdevice-major)
(rdev-min 8 cpio-header-rdevice-minor)
(name-size 8 cpio-header-name-size)
(checksum 8 cpio-header-checksum)) ;0 for "newc" format

The ‘ino’ value is stored as an 8-digit hexadecimal number—i.e., on 32
bits. And, guess what:

Toggle snippet (8 lines)
scheme@(guile-user)> 5031515288 ;the inode number above
$15 = 5031515288
scheme@(guile-user)> (expt 2 32)
$16 = 4294967296
scheme@(guile-user)> (- $16 $15)
$17 = -736547992

Noways, libc + kernel typically use a 64-bit ‘ino_t’, so fundamentally
the cpio format is “wrong”. But what can we do?

At least we can skip this test when that is the case (patch below).
WDYT?

Thanks,
Ludo’.
Toggle diff (32 lines)
diff --git a/tests/cpio.scm b/tests/cpio.scm
index 516de0655b..832101d1bb 100644
--- a/tests/cpio.scm
+++ b/tests/cpio.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015, 2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -31,12 +31,18 @@ (define-module (test-cpio)
(define %cpio-program
(which "cpio"))
+(define %test-file
+ (search-path %load-path "guix.scm"))
+
(test-begin "cpio")
+;; The cpio format expects 'ino' to fit in 32 bits. If we have a bigger inode
+;; number, skip this test.
+(test-skip
+ (if (>= (stat:ino (lstat %test-file)) (expt 2 32)) 1 0))
(test-assert "file->cpio-header + write-cpio-header + read-cpio-header"
- (let* ((file (search-path %load-path "guix.scm"))
- (header (file->cpio-header file)))
+ (let* ((header (file->cpio-header %test-file)))
(call-with-values
(lambda ()
(open-bytevector-output-port))
L
L
Ludovic Courtès wrote on 20 Dec 2022 17:15
(name . Christopher Baines)(address . mail@cbaines.net)(address . 60202-done@debbugs.gnu.org)
87k02m59x0.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (3 lines)
> At least we can skip this test when that is the case (patch below).
> WDYT?

I went ahead with this in 2880dc3046170e9129437caca586f13956d0d811.

Ludo’.
Closed
?