From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 7AC1F3858D35; Thu, 5 Jan 2023 02:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AC1F3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1433ef3b61fso41819108fac.10; Wed, 04 Jan 2023 18:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3oAbdomfQq+5hWjBQa2isc6EoGhTFgYDnmqRmxOaI7M=; b=PeBTbPAl/PqgenYNaBaDHfnty4OMCaTcjQpsQDMVc6yvfUP1zPZI8TE1hEyhWYRGgy Hb2KKEE3sWWpNlttgqW1nE5j+EhKWZNCwFV5gDsbeRla1N3Yj7bJJMtki2ksTMaeu22p soDaL6JIpZhDvakNFRcjluws+T+gd5Z4VSsyVRHAaGhNIv+dMqHY/9RwkMNGJeb3L6F8 dT5bSLT0U0sjHfo0Xjnwub+A56jlIWZ2tG6ibEgbZA1HdMGFyQUZ+54kWqszflwcViJx keLVMOMOfj0OFAtPLhPOT+F+HZIue70wg1//iw31V8Dkd40e6f/3vXDzB/dZPpdC/Dl+ 9Mkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3oAbdomfQq+5hWjBQa2isc6EoGhTFgYDnmqRmxOaI7M=; b=kz1blqVDdBjxTO0215Z4b0JbELJdweQijz165q9gBVvqcmbdw5AXAjTatE4ee/t4WM ma5PAUE/dgKEynLMKtPgjaSiVy4O84d3AGRnpsB3xlmCi9lPp3eqteQl3pYDgzrfEDUm tpZc1r3Ud2VlEkqcTXutJn16Lno1wP2yupY4pyjuQcvZ7Oatqd0izSDt6JCT9rwUDjvd +GaSog8Zao3+3zc+d5nFUqGb4+P/pPZ4fSgYJPQ2Yz34WsmG6uhKAN6e/DsJI/Ytn728 4Y92vTZy7gU2bPQg56IgsuY4JvdV7uw9Lk3PtUj1tWmhR/X6EPeAfo7GE1qZqL7jjhAz HtZQ== X-Gm-Message-State: AFqh2kq6ddRjbl5LqjbEK53MsDBJXFby5e0cnkTjZGJKo5MgtYgDLJ0j QilKXTnteFhmQlRSuliADaV4gOPvas5uf8O6mCI= X-Google-Smtp-Source: AMrXdXtwsHsKMTc3TRqNL83XZkroL0Z7A9VqWT6GU20jd6l8ofkQlCVCdJYkitLORkVoO77mxg+Ios20S+DqHCsbjvk= X-Received: by 2002:a05:6870:6a88:b0:143:aaa4:2559 with SMTP id mv8-20020a0568706a8800b00143aaa42559mr3346436oab.152.1672887003621; Wed, 04 Jan 2023 18:50:03 -0800 (PST) MIME-Version: 1.0 References: <639FE88D.7090408@gmail.com> <7cb45ab2-cc6e-c502-5592-51ffabcbc6f8@codeweavers.com> <63A3DF0E.1050902@gmail.com> <63A67964.6080902@gmail.com> In-Reply-To: <63A67964.6080902@gmail.com> From: NightStrike Date: Wed, 4 Jan 2023 21:50:01 -0500 Message-ID: Subject: Re: testsuite under wine To: jcb62281@gmail.com Cc: Jacek Caban , fortran@gcc.gnu.org, Eric Pouech , "gcc@gcc.gnu.org" , dejagnu@gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Dec 23, 2022 at 11:00 PM Jacob Bachmeyer wrote: > NightStrike wrote: > > On Wed, Dec 21, 2022 at 11:37 PM Jacob Bachmeyer wrote: > >> NightStrike wrote: > >> > >>> [...] > >>> Second, the problems with extra \r's still remain, but I think we've > >>> generally come to think that that part isn't Wine and is instead > >>> either the testsuite or deja. So I'll keep those replies to Jacob's > >>> previous message. > >>> > >>> > >> Most likely, it is a combination of the MinGW libc (which emits "\r\n" > >> for end-of-line in accordance with Windows convention) and the kernel > >> terminal driver (which passes "\r" and translates "\n" to "\r\n" in > >> accordance with POSIX convention). Wine, short of trying to translate > >> "\r\n" back to "\n" in accordance with POSIX conventions (and likely > >> making an even bigger mess---does Wine know if a handle is supposed to > >> be text or binary?) cannot really fix this, so the testsuite needs to > >> handle non-POSIX-standard line endings. (The Rust tests probably have > >> an outright bug if the newlines are being duplicated.) > >> > > > > You may be onto something here. I ran wine under script as `script -c > > "wine64 ./a.exe" out` (thanks, Arsen!), and it had the same extra \r > > prepended to the \r\n. I was making the mistake previously of running > > wine manually and capturing it to a file as `wine64 ./a.exe > out`, > > which as several have pointed out in this thread, that would disable > > the quirk, so of course it didn't reveal any problems. I'm behind, > > but I'll catch up to you guys eventually :) > > > > So close, and yet so far... script(1) /also/ uses a pty, so it is > getting the same translations as Expect and therefore DejaGnu. > > > So at least we know for sure that this particular instance of extra > > characters is coming from Wine. Maybe Wine can be smart enough to > > only translate \n into \r\n instead of translating \r\n into \r\r\n. > > Jacek / Eric, comments here? I'm happy to try another patch, the > > first one was great. > > > > I doubt that Wine is doing that translation. MinGW libc produces output > conformant to Windows conventions, so printf("\n") on a text handle > emits "\r\n", which Wine passes along. POSIX convention is that "\n" is > translated to "\r\n" in the kernel terminal driver upon output, so the > kernel translates the "\n" in the "\r\n" into /another/ "\r\n", yielding > "\r\r\n" at the pty master end. This is why DejaGnu testsuites must be > prepared to discard excess carriage returns. The first CR came from > MinGW libc; the second CR came from the kernel terminal driver; the LF > was ultimately passed through. Jacek and I have been digging into this on IRC, and he's been very helpful in trying to get further, but we're still stuck. We tried to be more introspective, inserting strace both as "strace script wine" and as "script strace wine". We tried running just "wine a.exe" without any extra glue, and logging the raw SSH packets from putty. After many iterations on these and other tests, Jacek finally had the idea to try removing Windows entirely from the equation, and we ran with a purely unix program / compiler combination: #include int main() { write(1, "test\r\n", 6); return 0; } (and also as "test\n", 5) In both versions, the following was observed: case 1) ./a.out | xxd case 2) script -c ./a.out out; xxd out case 3) enable putting logging, ./a.out In case 1, xxd showed no extra \r's. In cases 2 and 3, there was an extra \r (either 0d 0d 0a for test\r\n, or 0d 0a for test\n). So, is it possible after all of this back and forth regarding mingw, wine, and others, that it's down to the write() system call that's inserting extra \r's? Is this expected?