6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
13 static char *rcsid_test_c = "$Header$";
16 #include <mit-copyright.h>
25 extern ss_request_table moira_test;
26 extern int sending_version_no;
47 ss = ss_create_invocation("moira", "2.0", (char *)NULL,
48 &moira_test, &status);
50 com_err(whoami, status, "Unable to create invocation");
53 ss_listen(ss, &status);
55 com_err(whoami, status, 0);
63 int status = mr_noop();
64 if (status) ss_perror(ss, status, "");
69 sending_version_no = MR_VERSION_2;
74 sending_version_no = MR_VERSION_1;
77 test_connect(argc, argv)
81 char *server = "", *index();
87 status = mr_connect(server);
88 if (status) ss_perror(ss, status, "");
93 int status = mr_disconnect();
94 if (status) ss_perror(ss, status, "");
102 bzero(host, sizeof(host));
104 if (status = mr_host(host, sizeof(host) - 1))
105 ss_perror(ss, status, "");
107 printf("You are connected to host %s\n", host);
114 status = mr_auth("mrtest");
115 if (status) ss_perror(ss, status, "");
118 test_script(argc, argv)
123 char input[BUFSIZ], *cp, *index();
124 int status, oldstdout, oldstderr;
127 ss_perror(ss, 0, "too many levels deep in script files\n");
132 ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
136 inp = fopen(argv[1], "r");
138 ss_perror(ss, 0, "Cannot open input file %s", argv[1]);
143 printf("Redirecting output to %s\n", argv[2]);
147 status = open(argv[2], O_CREAT|O_WRONLY|O_APPEND, 0664);
152 ss_perror(ss, errno, "Unable to redirect output to %s\n", argv[2]);
164 if (fgets(input, BUFSIZ, inp) == NULL)
166 if ((cp = index(input, '\n')) != (char *)NULL)
172 if (input[0] == '%') {
173 for (cp = &input[1]; *cp && isspace(*cp); cp++);
174 printf("Comment: %s\n", cp);
177 printf("Executing: %s\n", input);
178 ss_execute_line(ss, input, &status);
179 if (status == SS_ET_COMMAND_NOT_FOUND) {
180 printf("Bad command: %s\n", input);
199 char *concat(str1, str2)
203 extern char *malloc();
206 int len = strlen(str2) + 1 ;
208 bcopy(str2, rtn, len);
210 int len1 = strlen(str1);
211 int len2 = strlen(str2) + 1;
212 rtn = malloc(len1+len2);
213 bcopy(str1, rtn, len1);
214 bcopy(str2, rtn+len1, len2);
222 print_reply(argc, argv)
227 for (i = 0; i < argc; i++) {
228 if (i != 0) printf(", ");
229 printf("%s", argv[i]);
236 test_query(argc, argv)
242 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
247 status = mr_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
248 printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
249 if (status) ss_perror(ss, status, "");
252 test_access(argc, argv)
258 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
261 status = mr_access(argv[1], argc-2, argv+2);
262 if (status) ss_perror(ss, status, "");
272 if (status = mr_do_update())
273 ss_perror(ss, status, " while triggering dcm");
277 test_motd(argc, argv)
284 if (status = mr_motd(&motd))
285 ss_perror(ss, status, " while getting motd");
287 printf("%s\n", motd);
289 printf("No message of the day.\n");