From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 3/5] gnu: Enable tests in Python 3. Date: Sun, 23 Mar 2014 11:43:31 +0100 Message-ID: <87siq9tcto.fsf@gnu.org> References: <1394160455-32580-1-git-send-email-tipecaml@gmail.com> <1394160455-32580-4-git-send-email-tipecaml@gmail.com> <878usm9wik.fsf@gnu.org> <532BBC8C.7010004@gmail.com> <87eh1v3d6p.fsf@gnu.org> <532E1907.3050907@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRfsU-0001wq-Il for guix-devel@gnu.org; Sun, 23 Mar 2014 06:43:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRfsM-0007kE-N9 for guix-devel@gnu.org; Sun, 23 Mar 2014 06:43:42 -0400 Received: from hera.aquilenet.fr ([2a01:474::1]:45220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRfsM-0007jR-9I for guix-devel@gnu.org; Sun, 23 Mar 2014 06:43:34 -0400 In-Reply-To: <532E1907.3050907@gmail.com> (Cyril Roelandt's message of "Sun, 23 Mar 2014 00:13:11 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Cyril Roelandt Cc: guix-devel@gnu.org Cyril Roelandt skribis: > On 03/21/2014 02:15 PM, Ludovic Court=C3=A8s wrote: >> Cyril Roelandt skribis: >> >>> On 03/07/2014 10:40 AM, Ludovic Court=C3=A8s wrote: >>>> Cyril Roelandt skribis: >> >> [...] >> >>>>> +--- Lib/test/test_posixpath.py 2014-03-01 05:46:56.984311000 +0100 >>>>> ++++ Lib/test/test_posixpath.py 2014-03-01 06:20:50.704311000 +0100 >>>>> +@@ -319,7 +319,11 @@ >>>>> + del env['HOME'] >>>>> + home =3D pwd.getpwuid(os.getuid()).pw_dir >>>>> + # $HOME can end with a trailing /, so strip it (see= #17809) >>>>> +- self.assertEqual(posixpath.expanduser("~"), home.rs= trip("/")) >>>>> ++ # The Guix builders have '/' as a home directory, so >>>>> ++ # home.rstrip("/") will be an empty string and the test will >>>>> ++ # fail. Let's just disable it since it does not really make >>>>> ++ # sense with such a bizarre setup. >>>>> ++ # self.assertEqual(posixpath.expanduser("~"), home.= rstrip("/")) >>>> >>>> I see that the recipe=E2=80=99s =E2=80=98pre-check=E2=80=99 phase does: >>>> >>>> (setenv "HOME" (getcwd)) >>>> >>>> so $HOME should actually be /tmp/nix-build-xxx, not just /, no? >>>> >>> >>> Yes, but I think it uses getpwent() or something that does not use >>> $HOME to retrieve the home directory in this case. >> >> Here=E2=80=99s what I see, with nscd turned off (this uses getpwnam(2)): >> >> --8<---------------cut here---------------start------------->8--- >> $ strace guile -c '(getpw "ludo")' >> [...] >> open("/etc/passwd", O_RDONLY|O_CLOEXEC) =3D 5 >> fstat(5, {st_mode=3DS_IFREG|0644, st_size=3D2072, ...}) =3D 0 >> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)= =3D 0x7f264dea5000 >> read(5, "root:x:0:0:System administrator:"..., 4096) =3D 2072 >> --8<---------------cut here---------------end--------------->8--- >> >> Normally the chroot environment has all that too. And indeed, the >> equivalent of the above Python snippet seems to work: >> >> --8<---------------cut here---------------start------------->8--- >> scheme@(guile-user)> ,use(guix) >> scheme@(guile-user)> ,use(guix monads) >> scheme@(guile-user)> (define s (open-connection)) >> scheme@(guile-user)> (derivation-expression "getpw" '(pk (getpw (getuid)= ))) >> $11 =3D # >> scheme@(guile-user)> (run-with-store s $11) >> $12 =3D # /gnu/store/z68rzri3myxx1dg931fb1ksxdg7c29zg-getpw 33dfa00> >> scheme@(guile-user)> (build-derivations s (list $12)) >> building path(s) `/gnu/store/z68rzri3myxx1dg931fb1ksxdg7c29zg-getpw' >> >> ;;; (#("nixbld" "x" 30001 30000 "Nix build user" "/" "/noshell")) > > Am I misteading this, or is the home directory '/' for the nixbld user > ? Correct, as per build.cc: --8<---------------cut here---------------start------------->8--- /* Create a /etc/passwd with entries for the build user and the nobody account. The latter is kind of a hack to support Samba-in-QEMU. */ createDirs(chrootRootDir + "/etc"); writeFile(chrootRootDir + "/etc/passwd", (format( "nixbld:x:%1%:%2%:Nix build user:/:/noshell\n" "nobody:x:65534:65534:Nobody:/:/noshell\n") % (buildUser.enabled() ? buildUser.getUID() : getuid()) % (buildUser.enabled() ? buildUser.getGID() : getgid())).st= r()); --8<---------------cut here---------------end--------------->8--- > That's exactly what happens in Python (that uses getwpent). Hence the > bug. I think skipping this assertion is the right thing to do here. Oh right. (Somehow I ended up thinking that getpwent was not working or something like that; sorry for the misunderstanding!) So OK to push as is! Thanks, Ludo=E2=80=99.