12 #include <afs/authcon.h>
13 #include <afs/cellconfig.h>
15 #include <tests/tap/basic.h>
19 /* Start up the VLserver, using the configuration in dirname, and putting our
24 afstest_StartVLServer(char *dirname, pid_t *serverPid)
33 } else if (pid == 0) {
34 char *binPath, *logPath, *dbPath, *build;
37 build = getenv("C_TAP_BUILD");
42 if (asprintf(&binPath, "%s/../src/tvlserver/vlserver", build) < 0 ||
43 asprintf(&logPath, "%s/VLLog", dirname) < 0 ||
44 asprintf(&dbPath, "%s/vldb", dirname) < 0) {
45 fprintf(stderr, "Out of memory building vlserver arguments\n");
48 execl(binPath, "vlserver",
49 "-logfile", logPath, "-database", dbPath, "-config", dirname, NULL);
50 fprintf(stderr, "Running %s failed\n", binPath);
54 if (waitpid(pid, &status, WNOHANG) != 0) {
55 fprintf(stderr, "Error starting vlserver\n");
59 diag("Sleeping for a few seconds to let the vlserver startup");
62 if (waitpid(pid, &status, WNOHANG) != 0) {
63 fprintf(stderr, "vlserver died during startup\n");
73 afstest_StopServer(pid_t serverPid)
77 kill(serverPid, SIGTERM);
79 waitpid(serverPid, &status, 0);
81 if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
82 fprintf(stderr, "Server died exited on signal %d\n", WTERMSIG(status));
85 if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
86 fprintf(stderr, "Server exited with code %d\n", WEXITSTATUS(status));
93 afstest_StartTestRPCService(const char *configPath,
97 afs_int32 (*proc) (struct rx_call *))
99 struct afsconf_dir *dir;
100 struct rx_securityClass **classes;
101 afs_int32 numClasses;
103 struct rx_service *service;
104 struct afsconf_bsso_info bsso;
106 memset(&bsso, 0, sizeof(bsso));
108 dir = afsconf_Open(configPath);
110 fprintf(stderr, "Server: Unable to open config directory\n");
114 code = rx_Init(htons(port));
116 fprintf(stderr, "Server: Unable to initialise RX\n");
120 if (signal_pid != 0) {
121 kill(signal_pid, SIGUSR1);
125 afsconf_BuildServerSecurityObjects_int(&bsso, &classes, &numClasses);
126 service = rx_NewService(0, serviceId, "test", classes, numClasses,
128 if (service == NULL) {
129 fprintf(stderr, "Server: Unable to start to test service\n");
135 return 0; /* Not reached, we donated ourselves to StartServer */