Pádraig Brady <[email protected]> writes:

> On 08/11/2025 06:41, Collin Funk wrote:
>> On GNU/Hurd tests/tail/tail-c fails because the following command times
>> out:
>>      timeout --verbose 1 tail -c 4096 /dev/urandom >/dev/null 2>err
>
> Ah right. TBH Hurd is perfectly entitled to behave like that.
> I.e. tail resorts to reading all data as non seekable.
> The patch looks fine. Please push.

I thought it was fine too, because urandom and random aren't
standardized. I prefer the behavior on GNU/Linux though.

On GNU/Linux the offset is always zero and lseek is a noop that
succeeds:

    $ cat main.c
    #include <stdio.h>
    #include <stdlib.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <inttypes.h>
    int
    main (void)
    {
      int fd = open ("/dev/urandom", O_RDONLY);
      if (fd < 0)
        abort ();
      printf ("%jd\n", (intmax_t) lseek (fd, 0, SEEK_CUR));
      printf ("%jd\n", (intmax_t) lseek (fd, 1, SEEK_CUR));
      unsigned char dummy;
      if (read (fd, &dummy, sizeof dummy) <= 0)
        abort ();
      printf ("%jd\n", (intmax_t) lseek (fd, 0, SEEK_CUR));
      printf ("%jd\n", (intmax_t) lseek (fd, 1, SEEK_CUR));
      return 0;
    }
    gcc main.c && ./a.out 
    0
    0
    0
    0

> Note also the 1 second timeout is too aggressive.
> For any test that we consider to have failed after a timeout
> the timeout should be 10 seconds to cater for slow/loaded systems
> and avoid intermittent false failures.
> I've just pushed a patch to fix that.

Cool, thanks.

Collin

Reply via email to