#include <afs/vldbint.h>
#include <afs/cellconfig.h>
-#include <tap/basic.h>
+#include <tests/tap/basic.h>
#include "common.h"
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",
- "listaddrs", "-config", dirname, "-noauth", NULL);
+ build = getenv("C_TAP_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", "-noresolve", NULL);
+ exit(1);
}
close(outpipe[1]);
buffer = malloc(4096);
{
char *dirname;
struct afsconf_dir *dir;
- struct afsconf_cell info;
- int code;
- int i;
- pid_t serverPid;
+ int code, secIndex;
+ pid_t serverPid = 0;
struct rx_securityClass *secClass;
- struct rx_connection *serverconns[MAXSERVERS];
struct ubik_client *ubikClient = NULL;
- int secIndex;
+ int ret = 0;
+ char *argv0 = afstest_GetProgname(argv);
- plan(5);
+ /* 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);
code = rx_Init(0);
code = afstest_AddDESKeyFile(dir);
if (code) {
- afs_com_err("vos-t", code, "while adding test DES keyfile");
- exit(1);
+ 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");
- exit(1);
+ 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("vos-t", code, "while getting a fake token");
- exit(1);
+ afs_com_err(argv0, code, "while getting anonymous secClass");
+ ret = 1;
+ goto out;
}
- 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");
- exit(1);
+ afs_com_err(argv0, code, "while building ubik client");
+ ret = 1;
+ goto out;
}
- 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);
- is_int(0, code, "Server exited cleanly");
+out:
+ if (serverPid != 0) {
+ code = afstest_StopServer(serverPid);
+ is_int(0, code, "Server exited cleanly");
+ }
- return 0;
+ afstest_UnlinkTestConfig(dirname);
+ return ret;
}