* link, linkat tests: Fix test failures on Android/Termux
@ 2023-01-11 17:17 Bruno Haible
0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2023-01-11 17:17 UTC (permalink / raw)
To: bug-gnulib
[-- Attachment #1: Type: text/plain, Size: 891 bytes --]
On Android 11, within the Termux app, these tests fail:
FAIL: test-link
===============
link: Permission denied
FAIL test-link (exit status: 1)
FAIL: test-linkat
=================
link: Permission denied
../../gltests/test-link.h:32: assertion '0 <= fd' failed
Aborted
FAIL test-linkat (exit status: 134)
It's apparently a problem with permissions, as I don't see it in my
Android 4.3 environment.
The workaround is to mark the test SKIPped in this situation.
2023-01-11 Bruno Haible <bruno@clisp.org>
link, linkat tests: Fix test failures on Android/Termux.
* tests/test-link.h (test_link): On Android, treat an EACCES failure
like EPERM.
* tests/test-linkat.c (main): When test_link is marked skipped, skip the
rest of the test as well.
2023-01-11 Bruno Haible <bruno@clisp.org>
link tests: Correct indentation.
* tests/test-link.h (test_link): Correct indentation.
[-- Attachment #2: 0001-link-tests-Correct-indentation.patch --]
[-- Type: text/x-patch, Size: 1614 bytes --]
From ed72fd292b3238c0ed46fb7b1f22a080469d0666 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 11 Jan 2023 14:54:55 +0100
Subject: [PATCH 1/2] link tests: Correct indentation.
* tests/test-link.h (test_link): Correct indentation.
---
ChangeLog | 5 +++++
tests/test-link.h | 20 ++++++++++----------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9045623e99..60de99cd2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-01-11 Bruno Haible <bruno@clisp.org>
+
+ link tests: Correct indentation.
+ * tests/test-link.h (test_link): Correct indentation.
+
2023-01-11 Bruno Haible <bruno@clisp.org>
Fix link errors on Android 4.3.
diff --git a/tests/test-link.h b/tests/test-link.h
index 623f6c70c7..a9298c8a2d 100644
--- a/tests/test-link.h
+++ b/tests/test-link.h
@@ -40,16 +40,16 @@ test_link (int (*func) (char const *, char const *), bool print)
file systems, but there, st_nlink and st_ino are reliable. */
ret = func (BASE "a", BASE "b");
if (!ret)
- {
- struct stat st;
- ASSERT (stat (BASE "b", &st) == 0);
- if (st.st_ino && st.st_nlink != 2)
- {
- ASSERT (unlink (BASE "b") == 0);
- errno = EPERM;
- ret = -1;
- }
- }
+ {
+ struct stat st;
+ ASSERT (stat (BASE "b", &st) == 0);
+ if (st.st_ino && st.st_nlink != 2)
+ {
+ ASSERT (unlink (BASE "b") == 0);
+ errno = EPERM;
+ ret = -1;
+ }
+ }
if (ret == -1)
{
/* If the device does not support hard links, errno is
--
2.34.1
[-- Attachment #3: 0002-link-linkat-tests-Fix-test-failures-on-Android-Termu.patch --]
[-- Type: text/x-patch, Size: 2333 bytes --]
From 8c9d6d51b3d7b2fdd5cea182ee7031559d3b5e97 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 11 Jan 2023 18:15:59 +0100
Subject: [PATCH 2/2] link, linkat tests: Fix test failures on Android/Termux.
* tests/test-link.h (test_link): On Android, treat an EACCES failure
like EPERM.
* tests/test-linkat.c (main): When test_link is marked skipped, skip the
rest of the test as well.
---
ChangeLog | 8 ++++++++
tests/test-link.h | 7 ++++++-
tests/test-linkat.c | 5 +++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 60de99cd2e..044e8cd29b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-11 Bruno Haible <bruno@clisp.org>
+
+ link, linkat tests: Fix test failures on Android/Termux.
+ * tests/test-link.h (test_link): On Android, treat an EACCES failure
+ like EPERM.
+ * tests/test-linkat.c (main): When test_link is marked skipped, skip the
+ rest of the test as well.
+
2023-01-11 Bruno Haible <bruno@clisp.org>
link tests: Correct indentation.
diff --git a/tests/test-link.h b/tests/test-link.h
index a9298c8a2d..f6aaea85b6 100644
--- a/tests/test-link.h
+++ b/tests/test-link.h
@@ -53,11 +53,16 @@ test_link (int (*func) (char const *, char const *), bool print)
if (ret == -1)
{
/* If the device does not support hard links, errno is
- EPERM on Linux, EOPNOTSUPP on FreeBSD. */
+ EPERM on Linux,
+ EOPNOTSUPP on FreeBSD,
+ EACCES on Android within Termux. */
switch (errno)
{
case EPERM:
case EOPNOTSUPP:
+ #if defined __ANDROID__
+ case EACCES:
+ #endif
if (print)
fputs ("skipping test: "
"hard links not supported on this file system\n",
diff --git a/tests/test-linkat.c b/tests/test-linkat.c
index 16378b7246..44c1bb945e 100644
--- a/tests/test-linkat.c
+++ b/tests/test-linkat.c
@@ -138,6 +138,11 @@ main (void)
dfd1 = AT_FDCWD;
ASSERT (test_link (do_link, false) == result);
+ /* Skip the rest of the test if the file system does not support hard links
+ and symlinks. */
+ if (result)
+ return result;
+
/* Create locations to manipulate. */
ASSERT (mkdir (BASE "sub1", 0700) == 0);
ASSERT (mkdir (BASE "sub2", 0700) == 0);
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-11 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 17:17 link, linkat tests: Fix test failures on Android/Termux Bruno Haible
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).