[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: testsuite under wine

From: Jerry D
Subject: Re: testsuite under wine
Date: Thu, 5 Jan 2023 19:41:58 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

On 1/4/23 6:50 PM, NightStrike via Fortran wrote:
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 <unistd.h>

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?

I have reproduced this test with C. I suspect that the 'write' function was written to accommodate non standard behavior of windows which expects a CR-LF. This means that POSIX compliant code is adjusted by the C or gfortran libraries to emit a extra CR so that on Windows it will just work ok. So the test is doing exactly what you are telling it to do. An LF causes the run times to add a CR in front.

With libgfortran I remember implementing some of this code myself and this is the reason, to keep applications happy on Windows.

So the gfortran tests we wrote to accept either a CR or a CR-LF, and in the test code to only issue a normal line ending which on UNIX will be an LF and Windows an CR-LF.

I lose track of details in between looking ta the test cases. let me know one of them to study that is gfortran side and will see what it is doing.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]