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
After stepping through the program in gdb, I noticed that current_pos
was -1. This is because lseek on /dev/random or /dev/urandom fails after
setting errno to ESPIPE on GNU/Hurd. Here is a test program:
$ cat main.c
#define _GNU_SOURCE 1
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
int
main (void)
{
int fd = open ("/dev/urandom", O_RDONLY);
if (fd < 0)
{
fprintf (stderr, "open: %s\n", strerror (errno));
return EXIT_FAILURE;
}
int current_pos = lseek (fd, 0, SEEK_CUR);
if (current_pos < 0)
{
fprintf (stderr, "lseek: %s\n", strerror (errno));
return EXIT_FAILURE;
}
return 0;
}
On GNU/Linux:
$ gcc main.c && ./a.out
$ echo $?
0
On GNU/Hurd:
$ gcc main.c && ./a.out
lseek: Illegal seek
$ echo $?
1
I don't see a way around this because that is just the way the random
devices are implemented on Hurd [1]. Okay to skip the test with the
attached patch?
Collin
[1] https://git.savannah.gnu.org/cgit/hurd/hurd.git/tree/trans/random.c#n442
>From 5c8502f7c5e7e6829e84641234f115b9994e60e9 Mon Sep 17 00:00:00 2001
Message-ID: <5c8502f7c5e7e6829e84641234f115b9994e60e9.1762584071.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Fri, 7 Nov 2025 22:15:37 -0800
Subject: [PATCH] tests: tail: avoid a test failure on GNU/Hurd
* tests/tail/tail-c.sh: Allow 'tail -c 4096 /dev/urandom' to run forever
on GNU/Hurd since lseek fails with ESPIPE.
---
tests/tail/tail-c.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/tail/tail-c.sh b/tests/tail/tail-c.sh
index 23519918b..fe74b42c8 100755
--- a/tests/tail/tail-c.sh
+++ b/tests/tail/tail-c.sh
@@ -55,7 +55,8 @@ if test -r /dev/urandom; then
[12].*) ;; # Older Linux versions timeout
*) fail=1 ;;
esac ;;
- *) fail=1 ;;
+ # GNU/Hurd cannot seek on /dev/urandom.
+ *) test "$(uname)" = GNU || fail=1 ;;
esac ;;
esac
fi
--
2.51.1