tests: skip vos tests when a vlserver is already running
[openafs.git] / tests / volser / vos-t.c
index 57161f4..758535e 100644 (file)
@@ -78,7 +78,7 @@ TestListAddrs(struct ubik_client *client, char *dirname)
            exit(1);
        }
        execl(binPath, "vos",
-             "listaddrs", "-config", dirname, "-noauth", NULL);
+             "listaddrs", "-config", dirname, "-noauth", "-noresolve", NULL);
        exit(1);
     }
     close(outpipe[1]);
@@ -96,15 +96,18 @@ main(int argc, char **argv)
     char *dirname;
     struct afsconf_dir *dir;
     int code, secIndex;
-    pid_t serverPid;
+    pid_t serverPid = 0;
     struct rx_securityClass *secClass;
     struct ubik_client *ubikClient = NULL;
     int ret = 0;
+    char *argv0 = afstest_GetProgname(argv);
 
     /* 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();
+    /* Skip all tests if a vlserver is already running on this system. */
+    afstest_SkipTestsIfServerRunning("afs3-vlserver");
 
     plan(6);
 
@@ -116,24 +119,22 @@ main(int argc, char **argv)
 
     code = afstest_AddDESKeyFile(dir);
     if (code) {
-       afs_com_err("vos-t", code, "while adding test DES keyfile");
+       afs_com_err(argv0, code, "while adding test DES keyfile");
        ret = 1;
        goto out;
     }
 
     code = afstest_StartVLServer(dirname, &serverPid);
     if (code) {
-       afs_com_err("vos-t", code, "while starting the vlserver");
+       afs_com_err(argv0, code, "while starting the vlserver");
        ret = 1;
        goto out;
     }
 
-    /* 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("authname-t", code, "while getting anonymous secClass");
+       afs_com_err(argv0, code, "while getting anonymous secClass");
        ret = 1;
        goto out;
     }
@@ -142,17 +143,19 @@ main(int argc, char **argv)
                                 secClass, secIndex, &ubikClient);
     is_int(code, 0, "Successfully built ubik client structure");
     if (code) {
-       afs_com_err("vos-t", code, "while building ubik client");
+       afs_com_err(argv0, code, "while building ubik client");
        ret = 1;
        goto out;
     }
 
     TestListAddrs(ubikClient, dirname);
 
-    code = afstest_StopServer(serverPid);
-    is_int(0, code, "Server exited cleanly");
-
 out:
+    if (serverPid != 0) {
+       code = afstest_StopServer(serverPid);
+       is_int(0, code, "Server exited cleanly");
+    }
+
     afstest_UnlinkTestConfig(dirname);
     return ret;
 }