Subject: bug#70862: 'write-error' test fails on NetBSD when run as root

From: Bruno Haible <[email-masked]>
Date: Fri, 10 May 2024 18:01:56 +0200

Hi,

On NetBSD, building gzip from git (with the newest gnulib) and
running "make check" as root produces 1 test failure:

FAIL: write-error
=================

FAIL write-error (exit status: 1)

How to reproduce:
1. Download tarball.zip from
   https://github.com/gnu-gzip/ci-check/actions/runs/9033181872/artifacts/1491311737
2. Unpack it.
3. tar xfz gzip-2024-05-10.tar.gz
4. ./configure; make; make check

The attached patch fixes it (and produces no regressions).

>From 4241ba74e6ec9393f467e9bf1e51ab7147db3b21 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email-masked]>
Date: Fri, 10 May 2024 17:38:18 +0200
Subject: [PATCH] tests: Fix test failure on NetBSD when run as root.

* tests/write-error: Also test whether the process is running under uid 0.
---
 tests/write-error | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/write-error b/tests/write-error
index de8b557..b53eddb 100755
--- a/tests/write-error
+++ b/tests/write-error
@@ -24,7 +24,7 @@ fail=0
 mkdir d || framework_failure_
 echo > d/f || framework_failure_
 chmod a-w d || framework_failure_
-if test -w d; then
+if test -w d || test `id -u` = 0; then
   echo >&2 "$0: being root, skipping this test"
   fail=77
 else
-- 
2.34.1