2011-05-31 09:30:41 +01:00
|
|
|
#include <afsconfig.h>
|
|
|
|
#include <afs/param.h>
|
|
|
|
|
|
|
|
#include <roken.h>
|
|
|
|
|
2012-04-08 23:31:25 +01:00
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2011-05-31 09:30:41 +01:00
|
|
|
#include <rx/rx.h>
|
|
|
|
#include <ubik.h>
|
|
|
|
|
|
|
|
#include <afs/com_err.h>
|
|
|
|
#include <afs/vldbint.h>
|
|
|
|
#include <afs/cellconfig.h>
|
|
|
|
|
2012-05-07 21:52:16 +01:00
|
|
|
#include <tests/tap/basic.h>
|
2011-05-31 09:30:41 +01:00
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
/* This checks for a bug in vos where it would fail to allocate additional
|
|
|
|
* space for the results of multi homed VL_GetAddrsU, and so would segfault
|
|
|
|
* if a host with a small number of addresses was immediately followed by
|
|
|
|
* a host with a large number of addresses.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TestListAddrs(struct ubik_client *client, char *dirname)
|
|
|
|
{
|
|
|
|
int code;
|
|
|
|
bulkaddrs addrs;
|
2020-01-21 21:40:12 +00:00
|
|
|
char *vos;
|
|
|
|
char *cmd = NULL;
|
|
|
|
struct afstest_cmdinfo cmdinfo;
|
2011-05-31 09:30:41 +01:00
|
|
|
|
|
|
|
afs_uint32 addrsA[] = {0x0a000000};
|
|
|
|
afs_uint32 addrsB[] = {0x0a000001, 0x0a000002, 0x0a000003, 0x0a000004,
|
|
|
|
0x0a000005, 0x0a000006, 0x0a000007, 0x0a000008,
|
|
|
|
0x0a000009, 0x0a00000a, 0x0a00000b, 0x0a00000c,
|
|
|
|
0x0a00000d, 0x0a00000e, 0x0a00000f};
|
2023-03-17 14:42:41 +00:00
|
|
|
unsigned char uuidA[] = {0x4F, 0x44, 0x94, 0x47, 0x76, 0xBA, 0x47, 0x2C, 0x97, 0x1A,
|
2011-05-31 09:30:41 +01:00
|
|
|
0x86, 0x6B, 0xC0, 0x10, 0x1A, 0x4B};
|
2023-03-17 14:42:41 +00:00
|
|
|
unsigned char uuidB[] = {0x5D, 0x2A, 0x39, 0x36, 0x94, 0xB2, 0x48, 0x90, 0xA8, 0xD2,
|
2011-05-31 09:30:41 +01:00
|
|
|
0x7F, 0xBC, 0x1B, 0x29, 0xDA, 0x9B};
|
|
|
|
char expecting[] = "10.0.0.0\n10.0.0.1\n10.0.0.2\n10.0.0.3\n10.0.0.4\n"
|
|
|
|
"10.0.0.5\n10.0.0.6\n10.0.0.7\n10.0.0.8\n10.0.0.9\n"
|
|
|
|
"10.0.0.10\n10.0.0.11\n10.0.0.12\n10.0.0.13\n"
|
|
|
|
"10.0.0.14\n10.0.0.15\n";
|
|
|
|
|
|
|
|
addrs.bulkaddrs_len = 1;
|
|
|
|
addrs.bulkaddrs_val = addrsA;
|
|
|
|
code = ubik_VL_RegisterAddrs(client, 0, (afsUUID *)uuidA, 0, &addrs);
|
|
|
|
is_int(0, code, "First address registration succeeds");
|
|
|
|
|
|
|
|
addrs.bulkaddrs_len = 15;
|
|
|
|
addrs.bulkaddrs_val = addrsB;
|
|
|
|
code = ubik_VL_RegisterAddrs(client, 0, (afsUUID *)uuidB, 0, &addrs);
|
|
|
|
is_int(0, code, "Second address registration succeeds");
|
|
|
|
|
|
|
|
/* Now we need to run vos ListAddrs and see what happens ... */
|
2020-01-21 21:40:12 +00:00
|
|
|
vos = afstest_obj_path("src/volser/vos");
|
|
|
|
|
|
|
|
cmd = afstest_asprintf("'%s' listaddrs -config '%s' "
|
|
|
|
"-noauth -noresolve",
|
|
|
|
vos, dirname);
|
|
|
|
|
|
|
|
memset(&cmdinfo, 0, sizeof(cmdinfo));
|
|
|
|
cmdinfo.exit_code = 0;
|
|
|
|
cmdinfo.output = expecting;
|
|
|
|
cmdinfo.fd = STDOUT_FILENO;
|
|
|
|
cmdinfo.command = cmd;
|
|
|
|
|
|
|
|
is_command(&cmdinfo, "vos output matches");
|
|
|
|
|
|
|
|
free(vos);
|
|
|
|
free(cmd);
|
2011-05-31 09:30:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *dirname;
|
|
|
|
struct afsconf_dir *dir;
|
2012-04-20 15:34:26 +01:00
|
|
|
int code, secIndex;
|
2019-12-31 18:25:32 +00:00
|
|
|
pid_t serverPid = 0;
|
2011-05-31 09:30:41 +01:00
|
|
|
struct rx_securityClass *secClass;
|
|
|
|
struct ubik_client *ubikClient = NULL;
|
2012-09-20 00:14:31 +01:00
|
|
|
int ret = 0;
|
2019-12-31 18:04:48 +00:00
|
|
|
char *argv0 = afstest_GetProgname(argv);
|
2011-05-31 09:30:41 +01:00
|
|
|
|
2013-02-17 18:29:38 +00:00
|
|
|
/* Skip all tests if the current hostname can't be resolved */
|
|
|
|
afstest_SkipTestsIfBadHostname();
|
2012-09-23 02:07:51 +01:00
|
|
|
/* Skip all tests if the current hostname is on the loopback network */
|
|
|
|
afstest_SkipTestsIfLoopbackNetIsDefault();
|
2020-01-10 15:54:20 +00:00
|
|
|
/* Skip all tests if a vlserver is already running on this system. */
|
|
|
|
afstest_SkipTestsIfServerRunning("afs3-vlserver");
|
2012-09-23 02:07:51 +01:00
|
|
|
|
2013-02-17 18:29:38 +00:00
|
|
|
plan(6);
|
|
|
|
|
2011-05-31 09:30:41 +01:00
|
|
|
code = rx_Init(0);
|
|
|
|
|
2021-04-01 06:12:43 +01:00
|
|
|
dirname = afstest_BuildTestConfig(NULL);
|
2011-05-31 09:30:41 +01:00
|
|
|
|
|
|
|
dir = afsconf_Open(dirname);
|
|
|
|
|
|
|
|
code = afstest_StartVLServer(dirname, &serverPid);
|
|
|
|
if (code) {
|
2019-12-31 18:04:48 +00:00
|
|
|
afs_com_err(argv0, code, "while starting the vlserver");
|
2012-09-20 00:14:31 +01:00
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2011-05-31 09:30:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
code = afsconf_ClientAuthSecure(dir, &secClass, &secIndex);
|
2012-04-20 15:34:26 +01:00
|
|
|
is_int(code, 0, "Successfully got security class");
|
2011-05-31 09:30:41 +01:00
|
|
|
if (code) {
|
2019-12-31 18:04:48 +00:00
|
|
|
afs_com_err(argv0, code, "while getting anonymous secClass");
|
2012-09-20 00:14:31 +01:00
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2011-05-31 09:30:41 +01:00
|
|
|
}
|
|
|
|
|
2012-04-20 15:34:26 +01:00
|
|
|
code = afstest_GetUbikClient(dir, AFSCONF_VLDBSERVICE, USER_SERVICE_ID,
|
|
|
|
secClass, secIndex, &ubikClient);
|
|
|
|
is_int(code, 0, "Successfully built ubik client structure");
|
2011-05-31 09:30:41 +01:00
|
|
|
if (code) {
|
2019-12-31 18:04:48 +00:00
|
|
|
afs_com_err(argv0, code, "while building ubik client");
|
2012-09-20 00:14:31 +01:00
|
|
|
ret = 1;
|
|
|
|
goto out;
|
2011-05-31 09:30:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TestListAddrs(ubikClient, dirname);
|
|
|
|
|
2012-09-20 00:14:31 +01:00
|
|
|
out:
|
2019-12-31 18:25:32 +00:00
|
|
|
if (serverPid != 0) {
|
|
|
|
code = afstest_StopServer(serverPid);
|
|
|
|
is_int(0, code, "Server exited cleanly");
|
|
|
|
}
|
|
|
|
|
tests: Generalize temp dir management
Currently, afstest_BuildTestConfig calls afstest_mkdtemp (our thin
wrapper around mkdtemp) to create its temporary config dir. We may
want to make new tests, though, that create a temp dir for other
purposes. To make that easier, move a little more code into
afstest_mkdtemp, so the caller doesn't need to construct the template.
To allow callers to clean up such temporary dirs, change
afstest_UnlinkTestConfig into a more general function,
afstest_rmdtemp. Allow this new function to remove all files in a dir,
not just files one-level-deep. To avoid needing to write our own
traversal and removal logic, just run 'rm -rf' via a new function,
afstest_systemlp().
Move these temp dir-related functions from config.c into files.c,
since they are no longer specific to config dirs.
Change-Id: I16750a2f30e98c9ca2e14dfb7d3fc9bc5d456e8d
Reviewed-on: https://gerrit.openafs.org/14632
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2020-07-02 03:18:04 +01:00
|
|
|
afstest_rmdtemp(dirname);
|
2012-09-20 00:14:31 +01:00
|
|
|
return ret;
|
2011-05-31 09:30:41 +01:00
|
|
|
}
|