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 sms_test;
26 extern int sending_version_no;
47 ss = ss_create_invocation("sms", "2.0", (char *)NULL,
50 com_err(whoami, status, "Unable to create invocation");
53 ss_listen(ss, &status);
55 com_err(whoami, status, 0);
63 int status = sms_noop();
64 if (status) ss_perror(ss, status, 0);
69 sending_version_no = SMS_VERSION_2;
74 sending_version_no = SMS_VERSION_1;
77 test_connect(argc, argv)
81 char *server = "", serverbuf[256], *index();
86 if (index(server, ':') == NULL) {
88 sprintf(serverbuf, "%s:%s", argv[1], "sms_db");
91 status = sms_connect(server);
92 if (status) ss_perror(ss, status, 0);
97 int status = sms_disconnect();
98 if (status) ss_perror(ss, status, 0);
105 status = sms_auth("smstest");
106 if (status) ss_perror(ss, status, 0);
109 test_script(argc, argv)
114 char input[BUFSIZ], *cp, *index();
115 int status, oldstdout, oldstderr;
118 ss_perror(ss, 0, "too many levels deep in script files\n");
123 ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
127 inp = fopen(argv[1], "r");
129 ss_perror(ss, 0, "Cannot open input file %s", argv[1]);
134 printf("Redirecting output to %s\n", argv[2]);
138 status = open(argv[2], O_CREAT|O_WRONLY|O_APPEND, 0664);
143 ss_perror(ss, errno, "Unable to redirect output to %s\n", argv[2]);
155 if (fgets(input, BUFSIZ, inp) == NULL)
157 if ((cp = index(input, '\n')) != (char *)NULL)
163 if (input[0] == '%') {
164 for (cp = &input[1]; *cp && isspace(*cp); cp++);
165 printf("Comment: %s\n", cp);
168 printf("Executing: %s\n", input);
169 ss_execute_line(ss, input, &status);
170 if (status == SS_ET_COMMAND_NOT_FOUND) {
171 printf("Bad command: %s\n", input);
190 char *concat(str1, str2)
194 extern char *malloc();
197 int len = strlen(str2) + 1 ;
199 bcopy(str2, rtn, len);
201 int len1 = strlen(str1);
202 int len2 = strlen(str2) + 1;
203 rtn = malloc(len1+len2);
204 bcopy(str1, rtn, len1);
205 bcopy(str2, rtn+len1, len2);
213 print_reply(argc, argv)
218 for (i = 0; i < argc; i++) {
219 if (i != 0) printf(", ");
220 printf("%s", argv[i]);
227 test_query(argc, argv)
233 ss_perror(ss, 0, "Usage: query handle [ args ... ]");
238 status = sms_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
239 printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
240 if (status) ss_perror(ss, status, 0);
243 test_access(argc, argv)
249 ss_perror(ss, 0, "Usage: access handle [ args ... ]");
252 status = sms_access(argv[1], argc-2, argv+2);
253 if (status) ss_perror(ss, status, 0);
263 if (status = sms_do_update())
264 ss_perror(ss, status, " while triggering dcm");