From 7fcac5f59f80f4deca8a55d77a1d9842dc6b5449 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 22 Oct 2014 18:13:49 +0200 Subject: [PATCH] tests: switch from get_current_dir_name to getcwd(0, NULL) get_current_dir_name exists on GNU libc only, so not portable. On the other hand, while POSIX leaves a null buffer argument for getcwd as unspecified behaviour, basically the most used/important Unix implementations (GNU libc, FreeBSD's libc, etc) allow such value, returning a new allocated buffer with the current directory. In any case, the change just affects two tests, so even if it hits a libc not implementing this behaviour for getcwd, only tests are affected. --- tests/c-api/test-pwd.c | 2 +- tests/events/test-libvirt-auth-callbacks.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/c-api/test-pwd.c b/tests/c-api/test-pwd.c index 60b978c36..61b88ec34 100644 --- a/tests/c-api/test-pwd.c +++ b/tests/c-api/test-pwd.c @@ -28,7 +28,7 @@ int main (int argc, char *argv[]) { - char *cwd = get_current_dir_name(); + char *cwd = getcwd(NULL, 0); printf("%s", cwd); exit (EXIT_SUCCESS); diff --git a/tests/events/test-libvirt-auth-callbacks.c b/tests/events/test-libvirt-auth-callbacks.c index 7c26bbe33..383f20f70 100644 --- a/tests/events/test-libvirt-auth-callbacks.c +++ b/tests/events/test-libvirt-auth-callbacks.c @@ -70,9 +70,9 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - cwd = get_current_dir_name (); + cwd = getcwd (NULL, 0); if (cwd == NULL) { - perror ("get_current_dir_name"); + perror ("getcwd"); exit (EXIT_FAILURE); }