opr: export softsig functions
[openafs.git] / tests / volser / vos-t.c
index a247e0e..57161f4 100644 (file)
@@ -12,7 +12,7 @@
 #include <afs/vldbint.h>
 #include <afs/cellconfig.h>
 
-#include <tap/basic.h>
+#include <tests/tap/basic.h>
 
 #include "common.h"
 
@@ -57,15 +57,29 @@ TestListAddrs(struct ubik_client *client, char *dirname)
     is_int(0, code, "Second address registration succeeds");
 
     /* Now we need to run vos ListAddrs and see what happens ... */
-    pipe(outpipe);
+    if (pipe(outpipe) < 0) {
+       perror("pipe");
+       exit(1);
+    }
     pid = fork();
     if (pid == 0) {
+       char *build, *binPath;
+
        dup2(outpipe[1], STDOUT_FILENO); /* Redirect stdout into pipe */
        close(outpipe[0]);
        close(outpipe[1]);
 
-       execl("../../src/volser/vos", "vos",
+       build = getenv("BUILD");
+       if (build == NULL)
+           build = "..";
+
+       if (asprintf(&binPath, "%s/../src/volser/vos", build) < 0) {
+           fprintf(stderr, "Out of memory building vos arguments\n");
+           exit(1);
+       }
+       execl(binPath, "vos",
              "listaddrs", "-config", dirname, "-noauth", NULL);
+       exit(1);
     }
     close(outpipe[1]);
     buffer = malloc(4096);
@@ -85,6 +99,12 @@ main(int argc, char **argv)
     pid_t serverPid;
     struct rx_securityClass *secClass;
     struct ubik_client *ubikClient = NULL;
+    int ret = 0;
+
+    /* Skip all tests if the current hostname can't be resolved */
+    afstest_SkipTestsIfBadHostname();
+    /* Skip all tests if the current hostname is on the loopback network */
+    afstest_SkipTestsIfLoopbackNetIsDefault();
 
     plan(6);
 
@@ -97,13 +117,15 @@ main(int argc, char **argv)
     code = afstest_AddDESKeyFile(dir);
     if (code) {
        afs_com_err("vos-t", code, "while adding test DES keyfile");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     code = afstest_StartVLServer(dirname, &serverPid);
     if (code) {
        afs_com_err("vos-t", code, "while starting the vlserver");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     /* Let it figure itself out ... */
@@ -112,7 +134,8 @@ main(int argc, char **argv)
     is_int(code, 0, "Successfully got security class");
     if (code) {
        afs_com_err("authname-t", code, "while getting anonymous secClass");
-        exit(1);
+       ret = 1;
+       goto out;
     }
 
     code = afstest_GetUbikClient(dir, AFSCONF_VLDBSERVICE, USER_SERVICE_ID,
@@ -120,13 +143,16 @@ main(int argc, char **argv)
     is_int(code, 0, "Successfully built ubik client structure");
     if (code) {
        afs_com_err("vos-t", code, "while building ubik client");
-       exit(1);
+       ret = 1;
+       goto out;
     }
 
     TestListAddrs(ubikClient, dirname);
 
-    code = afstest_StopVLServer(serverPid);
+    code = afstest_StopServer(serverPid);
     is_int(0, code, "Server exited cleanly");
 
-    return 0;
+out:
+    afstest_UnlinkTestConfig(dirname);
+    return ret;
 }