]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Drop /private CWD prefix in commandhelper
authorRoman Bolshakov <r.bolshakov@yadro.com>
Wed, 21 Aug 2019 16:13:18 +0000 (19:13 +0300)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 23 Aug 2019 10:26:26 +0000 (11:26 +0100)
/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

index 1312f3ee527c82c78e22d7e76e5d9a8c07e010d7..872564b1444231ec0bd76f60374b18e289b32a91 100644 (file)
@@ -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));