From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 3272B1F8C6 for ; Sun, 29 Aug 2021 23:52:29 +0000 (UTC) Received: from localhost ([::1]:46470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKUbD-0002Zh-3v for normalperson@yhbt.net; Sun, 29 Aug 2021 19:52:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKUb3-0002XX-BO for bug-gnulib@gnu.org; Sun, 29 Aug 2021 19:52:19 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.219]:27086) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKUb0-0007SU-Fj for bug-gnulib@gnu.org; Sun, 29 Aug 2021 19:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1630281131; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=8EtDudh0J7V5Fp8swxhWVWpvC9rUhooO58Kh0U1OwWs=; b=EhHgMRFGL+0hzQI2GdniP1nSu4Y6aqBvm4sxTIicgLZc8jqMR/HkPF7xkFj1uFIkkJ VsQFXIs3ti3H9JQR9/DD7h5l5IVGTkEWrgD/+a5r8IGVyVlDYvoxqzy548DgG58BScnf L2W2A9NEfPdw+mjkqEcoNJ+fcvwJARBzHasohmt61qDB0t4bU3DTygm/4KM8iy8rlYPT 1wBGNamcaMq63TR4tO+XH0jQDcQWNC/3V2YAuHd9fjjQ2iniGpi5RWOGK/tg5Tg/Eem+ Lgp19OgECovlxBmEZnckuRozicFClWcU+AFtBc0IEVD/A0Y6zTES8al30GUDDCeI+Ps+ FOJg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94z26ll5ip69ul0iGsqz23qGdf6ocUvVBxZEOAQ==" X-RZG-CLASS-ID: mo00 Received: from omega.localnet by smtp.strato.de (RZmta 47.31.0 AUTH) with ESMTPSA id I0beb9x7TNqAsgd (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 30 Aug 2021 01:52:10 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: getcwd tests: Avoid test failure when running under QEMU user-mode Date: Mon, 30 Aug 2021 01:52:10 +0200 Message-ID: <2855014.Zkmt1EvEu4@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.219; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" In a QEMU user-mode environment (for various CPUs), the test-getcwd.sh test fails, with exit code 5. This happens with qemu 6.1.0, but did not happen with qemu 4.1.0 and older versions. It's not easy to fix, because the code is involved. What I see, is that * The test invokes rpl_getcwd, * rpl_getcwd invokes the system's getcwd (under the fake name getcwd_system), which is in fact __getcwd from sysdeps/unix/sysv/linux/getcwd.c that calls __getcwd_generic from sysdeps/posix/getcwd.c). This glibc routine triggers the following system calls: getcwd(0x40001528,4096) = -1 errno=248 (File name too long) lstat64(".",0x400066c8) = 0 lstat64("/",0x400066c8) = 0 openat(AT_FDCWD,"..",O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 4 fstat64(4,0x400066c8) = 0 fstat64(4,0x40006808) = 0 fcntl64(4,F_GETFL) = 0 fcntl64(4,F_SETFD,1) = 0 brk(NULL) = 0x00015000 brk(0x00036000) = 0x00036000 getdents64(4,86448,32768,86408,2065,0) = 80 close(4) = 0 and the system's getcwd thus fails with errno = 248 = EOVERFLOW (!). rpl_getcwd then fails with errno = 2 = ENOENT. It's too complex to fix this properly. So I just disable this test under QEMU. 2021-08-29 Bruno Haible getcwd tests: Avoid test failure when running under QEMU user-mode. * modules/getcwd-tests (Files): Add qemu.h. (Depends-on): Add stdbool. * tests/test-getcwd.c: Include qemu.h. (test_long_name): Skip this test when running under QEMU user-mode. (main): Consider return code 77 from test_long_name. diff --git a/modules/getcwd-tests b/modules/getcwd-tests index e5a7bd78b..c842c7711 100644 --- a/modules/getcwd-tests +++ b/modules/getcwd-tests @@ -1,12 +1,14 @@ Files: -tests/test-getcwd.c tests/test-getcwd.sh +tests/test-getcwd.c +tests/qemu.h Depends-on: errno fcntl-h getcwd-lgpl pathmax +stdbool sys_stat test-framework-sh diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c index 061c69eb1..051d4f26a 100644 --- a/tests/test-getcwd.c +++ b/tests/test-getcwd.c @@ -27,6 +27,7 @@ #include #include "pathmax.h" +#include "qemu.h" #include "macros.h" #if !(HAVE_GETPAGESIZE || defined getpagesize) @@ -138,6 +139,13 @@ test_long_name (void) this should be done in a compile test. */ return 0; #else + /* For a process running under QEMU user-mode, the "/" directory is not + really the root directory, but the value of the QEMU_LD_PREFIX environment + variable or of the -L command-line option. This causes the logic from + glibc/sysdeps/posix/getcwd.c to fail. In this case, skip the test. */ + if (is_running_under_qemu_user ()) + return 77; + char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) + DIR_NAME_SIZE + BUF_SLOP]; char *cwd = getcwd (buf, PATH_MAX); @@ -256,5 +264,7 @@ test_long_name (void) int main (int argc, char **argv) { - return test_abort_bug () * 10 + test_long_name (); + int err1 = test_abort_bug (); + int err2 = test_long_name (); + return err1 * 10 + (err1 != 0 && err2 == 77 ? 0 : err2); }