[libvirt] [PATCH 06/11] tests: Drop /private CWD prefix in commandhelper

Roman Bolshakov posted 11 patches 6 years, 5 months ago
[libvirt] [PATCH 06/11] tests: Drop /private CWD prefix in commandhelper
Posted by Roman Bolshakov 6 years, 5 months ago
/tmp is a symbolic link to /private/tmp on macOS. That causes failures
in commandtest, because getcwd returns /private/tmp and the expected
output doesn't match to "CWD: /tmp".

Rathern than making a copy of commanddata solely for macOS, the /private
prefix is stripped.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
 tests/commandhelper.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 1312f3ee52..358c37e014 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -130,7 +130,16 @@ int main(int argc, char **argv) {
     if (strlen(cwd) > strlen(".../commanddata") &&
         STREQ(cwd + strlen(cwd) - strlen("/commanddata"), "/commanddata"))
         strcpy(cwd, ".../commanddata");
+#ifdef __APPLE__
+    char *noprivateprefix = NULL;
+    if (strstr(cwd, "/private"))
+        noprivateprefix = cwd + strlen("/private");
+    else
+        noprivateprefix = cwd;
+    fprintf(log, "CWD:%s\n", noprivateprefix);
+#else
     fprintf(log, "CWD:%s\n", cwd);
+#endif
     free(cwd);
 
     fprintf(log, "UMASK:%04o\n", umask(0));
-- 
2.22.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/11] tests: Drop /private CWD prefix in commandhelper
Posted by Daniel P. Berrangé 6 years, 5 months ago
On Wed, Aug 21, 2019 at 07:13:18PM +0300, Roman Bolshakov wrote:
> /tmp is a symbolic link to /private/tmp on macOS. That causes failures
> in commandtest, because getcwd returns /private/tmp and the expected
> output doesn't match to "CWD: /tmp".
> 
> Rathern than making a copy of commanddata solely for macOS, the /private
> prefix is stripped.
> 
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  tests/commandhelper.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/tests/commandhelper.c b/tests/commandhelper.c
> index 1312f3ee52..358c37e014 100644
> --- a/tests/commandhelper.c
> +++ b/tests/commandhelper.c
> @@ -130,7 +130,16 @@ int main(int argc, char **argv) {
>      if (strlen(cwd) > strlen(".../commanddata") &&
>          STREQ(cwd + strlen(cwd) - strlen("/commanddata"), "/commanddata"))
>          strcpy(cwd, ".../commanddata");
> +#ifdef __APPLE__
> +    char *noprivateprefix = NULL;
> +    if (strstr(cwd, "/private"))

s/strstr/STRPREFIX/

> +        noprivateprefix = cwd + strlen("/private");
> +    else
> +        noprivateprefix = cwd;
> +    fprintf(log, "CWD:%s\n", noprivateprefix);
> +#else
>      fprintf(log, "CWD:%s\n", cwd);
> +#endif

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list