cmd: Convert to using libtool
[openafs.git] / tests / volser / vos-t.c
index e1ffec6..dc8f64e 100644 (file)
@@ -3,6 +3,8 @@
 
 #include <roken.h>
 
+#include <sys/wait.h>
+
 #include <rx/rx.h>
 #include <ubik.h>
 
@@ -10,7 +12,7 @@
 #include <afs/vldbint.h>
 #include <afs/cellconfig.h>
 
-#include <tap/basic.h>
+#include <tests/tap/basic.h>
 
 #include "common.h"
 
@@ -58,12 +60,20 @@ TestListAddrs(struct ubik_client *client, char *dirname)
     pipe(outpipe);
     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 = "..";
+
+       asprintf(&binPath, "%s/../src/volser/vos", build);
+       execl(binPath, "vos",
              "listaddrs", "-config", dirname, "-noauth", NULL);
+       exit(1);
     }
     close(outpipe[1]);
     buffer = malloc(4096);
@@ -79,16 +89,12 @@ main(int argc, char **argv)
 {
     char *dirname;
     struct afsconf_dir *dir;
-    struct afsconf_cell info;
-    int code;
-    int i;
+    int code, secIndex;
     pid_t serverPid;
     struct rx_securityClass *secClass;
-    struct rx_connection *serverconns[MAXSERVERS];
     struct ubik_client *ubikClient = NULL;
-    int secIndex;
 
-    plan(5);
+    plan(6);
 
     code = rx_Init(0);
 
@@ -110,31 +116,24 @@ main(int argc, char **argv)
 
     /* Let it figure itself out ... */
     sleep(5);
-
     code = afsconf_ClientAuthSecure(dir, &secClass, &secIndex);
+    is_int(code, 0, "Successfully got security class");
     if (code) {
-       afs_com_err("vos-t", code, "while getting a fake token");
-       exit(1);
+       afs_com_err("authname-t", code, "while getting anonymous secClass");
+        exit(1);
     }
 
-    code = afsconf_GetCellInfo(dir, NULL, AFSCONF_VLDBSERVICE, &info);
+    code = afstest_GetUbikClient(dir, AFSCONF_VLDBSERVICE, USER_SERVICE_ID,
+                                secClass, secIndex, &ubikClient);
+    is_int(code, 0, "Successfully built ubik client structure");
     if (code) {
-       afs_com_err("vos-t", code, " while getting addresses from cellservdb");
+       afs_com_err("vos-t", code, "while building ubik client");
        exit(1);
     }
-    ok(info.numServers < MAXSERVERS, "Number of servers is within range");
-
-    for (i = 0; i < info.numServers; i++)
-       serverconns[i] = rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
-                                         info.hostAddr[i].sin_port,
-                                         USER_SERVICE_ID,
-                                         secClass, secIndex);
-
-    code = ubik_ClientInit(serverconns, &ubikClient);
 
     TestListAddrs(ubikClient, dirname);
 
-    code = afstest_StopVLServer(serverPid);
+    code = afstest_StopServer(serverPid);
     is_int(0, code, "Server exited cleanly");
 
     return 0;