diff options
author | Bruno Haible <bruno@clisp.org> | 2021-08-30 01:44:03 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2021-08-30 01:44:03 +0200 |
commit | 1968e3a57ac44a8e782de06454a6b7df4e4a4c33 (patch) | |
tree | c31ecb30821d79106438e660d6168cca66d49af2 /tests | |
parent | 6aafd2a92b4bb48937f3e767e51a4b7abf2f2217 (diff) | |
download | gnulib-1968e3a57ac44a8e782de06454a6b7df4e4a4c33.tar.gz |
getcwd tests: Avoid test failure when running under QEMU user-mode.
* modules/getcwd-tests (Files): Add qemu.h.
(Depends-on): Add stdbool.
* tests/test-getcwd.c: Include qemu.h.
(test_long_name): Skip this test when running under QEMU user-mode.
(main): Consider return code 77 from test_long_name.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-getcwd.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c index 061c69eb12..051d4f26a0 100644 --- a/tests/test-getcwd.c +++ b/tests/test-getcwd.c @@ -27,6 +27,7 @@ #include <sys/stat.h> #include "pathmax.h" +#include "qemu.h" #include "macros.h" #if !(HAVE_GETPAGESIZE || defined getpagesize) @@ -138,6 +139,13 @@ test_long_name (void) this should be done in a compile test. */ return 0; #else + /* For a process running under QEMU user-mode, the "/" directory is not + really the root directory, but the value of the QEMU_LD_PREFIX environment + variable or of the -L command-line option. This causes the logic from + glibc/sysdeps/posix/getcwd.c to fail. In this case, skip the test. */ + if (is_running_under_qemu_user ()) + return 77; + char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) + DIR_NAME_SIZE + BUF_SLOP]; char *cwd = getcwd (buf, PATH_MAX); @@ -256,5 +264,7 @@ test_long_name (void) int main (int argc, char **argv) { - return test_abort_bug () * 10 + test_long_name (); + int err1 = test_abort_bug (); + int err2 = test_long_name (); + return err1 * 10 + (err1 != 0 && err2 == 77 ? 0 : err2); } |