12 #include <afs/cellconfig.h>
14 #include <tests/tap/basic.h>
18 /* Start up the VLserver, using the configuration in dirname, and putting our
23 afstest_StartVLServer(char *dirname, pid_t *serverPid)
32 } else if (pid == 0) {
33 char *binPath, *logPath, *dbPath, *build;
36 build = getenv("C_TAP_BUILD");
41 if (asprintf(&binPath, "%s/../src/tvlserver/vlserver", build) < 0 ||
42 asprintf(&logPath, "%s/VLLog", dirname) < 0 ||
43 asprintf(&dbPath, "%s/vldb", dirname) < 0) {
44 fprintf(stderr, "Out of memory building vlserver arguments\n");
47 execl(binPath, "vlserver",
48 "-logfile", logPath, "-database", dbPath, "-config", dirname, NULL);
49 fprintf(stderr, "Running %s failed\n", binPath);
53 if (waitpid(pid, &status, WNOHANG) != 0) {
54 fprintf(stderr, "Error starting vlserver\n");
58 diag("Sleeping for a few seconds to let the vlserver startup");
61 if (waitpid(pid, &status, WNOHANG) != 0) {
62 fprintf(stderr, "vlserver died during startup\n");
72 afstest_StopServer(pid_t serverPid)
76 kill(serverPid, SIGTERM);
78 waitpid(serverPid, &status, 0);
80 if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
81 fprintf(stderr, "Server died exited on signal %d\n", WTERMSIG(status));
84 if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
85 fprintf(stderr, "Server exited with code %d\n", WEXITSTATUS(status));
92 afstest_StartTestRPCService(const char *configPath,
96 afs_int32 (*proc) (struct rx_call *))
98 struct afsconf_dir *dir;
99 struct rx_securityClass **classes;
100 afs_int32 numClasses;
102 struct rx_service *service;
104 dir = afsconf_Open(configPath);
106 fprintf(stderr, "Server: Unable to open config directory\n");
110 code = rx_Init(htons(port));
112 fprintf(stderr, "Server: Unable to initialise RX\n");
116 if (signal_pid != 0) {
117 kill(signal_pid, SIGUSR1);
120 afsconf_BuildServerSecurityObjects(dir, &classes, &numClasses);
121 service = rx_NewService(0, serviceId, "test", classes, numClasses,
123 if (service == NULL) {
124 fprintf(stderr, "Server: Unable to start to test service\n");
130 return 0; /* Not reached, we donated ourselves to StartServer */