Home | History | Annotate | Line # | Download | only in rpc.pcnfsd
pcnfsd_test.c revision 1.1
      1  1.1  jtc /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_test.c 1.2 92/01/27 18:00:39 SMI */
      2  1.1  jtc #include <stdio.h>
      3  1.1  jtc #include <rpc/rpc.h>
      4  1.1  jtc #include <malloc.h>
      5  1.1  jtc #include "pcnfsd.h"
      6  1.1  jtc 
      7  1.1  jtc CLIENT *cl;
      8  1.1  jtc CLIENT *cl2;
      9  1.1  jtc char *server;
     10  1.1  jtc char spooldirbuff[256];
     11  1.1  jtc char filenamebuff[256];
     12  1.1  jtc char last_id[32] = "";
     13  1.1  jtc 
     14  1.1  jtc void free_pr_list_item();
     15  1.1  jtc void free_pr_queue_item();
     16  1.1  jtc void good();
     17  1.1  jtc void bad();
     18  1.1  jtc 
     19  1.1  jtc 
     20  1.1  jtc main(argc, argv)
     21  1.1  jtc int argc;
     22  1.1  jtc char *argv[];
     23  1.1  jtc {
     24  1.1  jtc 
     25  1.1  jtc char *host_name;
     26  1.1  jtc char *printer;
     27  1.1  jtc char *user_name;
     28  1.1  jtc char *passwd;
     29  1.1  jtc char *transport = "udp";
     30  1.1  jtc 
     31  1.1  jtc 	if((argc < 6) || (argc > 7)) {
     32  1.1  jtc 		fprintf(stderr, "usage: %s server host printer user password [transport]\n",
     33  1.1  jtc 			argv[0]);
     34  1.1  jtc 		exit(1);
     35  1.1  jtc 	}
     36  1.1  jtc 
     37  1.1  jtc 	server = argv[1];
     38  1.1  jtc 	host_name = argv[2];
     39  1.1  jtc 	printer = argv[3];
     40  1.1  jtc 	user_name = argv[4];
     41  1.1  jtc 	passwd = argv[5];
     42  1.1  jtc 	if (argc == 7)
     43  1.1  jtc 		transport = argv[6];
     44  1.1  jtc 
     45  1.1  jtc 	cl = clnt_create(server, PCNFSDPROG, PCNFSDVERS, transport);
     46  1.1  jtc 	if(cl == NULL) {
     47  1.1  jtc 		clnt_pcreateerror(server);
     48  1.1  jtc 		exit(1);
     49  1.1  jtc 	}
     50  1.1  jtc 	cl2 = clnt_create(server, PCNFSDPROG, PCNFSDV2, transport);
     51  1.1  jtc 	if(cl2 == NULL) {
     52  1.1  jtc 		clnt_pcreateerror(server);
     53  1.1  jtc 		exit(1);
     54  1.1  jtc 	}
     55  1.1  jtc 	good();
     56  1.1  jtc 	test_v2_info();
     57  1.1  jtc 	good();
     58  1.1  jtc 	test_v2_auth(host_name, user_name, passwd);
     59  1.1  jtc 	bad("Invalid password");
     60  1.1  jtc 	test_v2_auth(host_name, user_name, "bogus");
     61  1.1  jtc 	good();
     62  1.1  jtc 	test_v2_list();
     63  1.1  jtc 	good();
     64  1.1  jtc 	test_v2_init(host_name, printer);
     65  1.1  jtc 	good();
     66  1.1  jtc 	test_v2_start(host_name, printer, user_name, "foo", "foo");
     67  1.1  jtc 	good();
     68  1.1  jtc 	test_v2_start(host_name, printer, user_name, "bar", "bar");
     69  1.1  jtc 	bad("No such file to print");
     70  1.1  jtc 	test_v2_start(host_name, printer, user_name, "bletch", "gack");
     71  1.1  jtc 	good();
     72  1.1  jtc 	test_v2_queue(printer, user_name, FALSE);
     73  1.1  jtc 	if(strlen(last_id)) {
     74  1.1  jtc 		bad("Cancelling job with bad username");
     75  1.1  jtc 		test_v2_cancel(host_name, printer, "nosuchuser", last_id);
     76  1.1  jtc 		good();
     77  1.1  jtc 		test_v2_cancel(host_name, printer, user_name, last_id);
     78  1.1  jtc 	}
     79  1.1  jtc 	bad("Cancelling unknown job");
     80  1.1  jtc 	test_v2_cancel(host_name, printer, user_name, "99999");
     81  1.1  jtc 	bad("Cancelling job on invalid printer");
     82  1.1  jtc 	test_v2_cancel(host_name, "nosuchprinter", user_name, last_id);
     83  1.1  jtc 	good();
     84  1.1  jtc 	test_v2_queue(printer, user_name, TRUE);
     85  1.1  jtc 	bad("Checking queue on invalid printer");
     86  1.1  jtc 	test_v2_queue("nosuchprinter", user_name, TRUE);
     87  1.1  jtc 	good();
     88  1.1  jtc 	test_v2_stat(printer);
     89  1.1  jtc 	bad("Checking status of invalid printer");
     90  1.1  jtc 	test_v2_stat("nosuchprinter");
     91  1.1  jtc 	good();
     92  1.1  jtc 	test_v2_map();
     93  1.1  jtc 	exit(0);
     94  1.1  jtc /*NOTREACHED*/
     95  1.1  jtc }
     96  1.1  jtc 
     97  1.1  jtc #define zchar           0x5b
     98  1.1  jtc 
     99  1.1  jtc void
    100  1.1  jtc scramble(s1, s2)
    101  1.1  jtc char           *s1;
    102  1.1  jtc char           *s2;
    103  1.1  jtc {
    104  1.1  jtc         while (*s1)
    105  1.1  jtc               {
    106  1.1  jtc               *s2++ = (*s1 ^ zchar) & 0x7f;
    107  1.1  jtc               s1++;
    108  1.1  jtc               }
    109  1.1  jtc         *s2 = 0;
    110  1.1  jtc }
    111  1.1  jtc 
    112  1.1  jtc 
    113  1.1  jtc 
    114  1.1  jtc test_v2_info()
    115  1.1  jtc {
    116  1.1  jtc v2_info_args a;
    117  1.1  jtc v2_info_results *rp;
    118  1.1  jtc int          *gp;
    119  1.1  jtc int             i;
    120  1.1  jtc 
    121  1.1  jtc 	a.vers = "Sun Microsystems PCNFSD test subsystem V1";
    122  1.1  jtc 	a.cm = "-";
    123  1.1  jtc 	printf("\ninvoking pr_info_2\n");
    124  1.1  jtc 
    125  1.1  jtc 	rp = pcnfsd2_info_2(&a, cl2);
    126  1.1  jtc 
    127  1.1  jtc 	if(rp == NULL) {
    128  1.1  jtc 		clnt_perror(cl2, server);
    129  1.1  jtc 		return(1);
    130  1.1  jtc 	}
    131  1.1  jtc 
    132  1.1  jtc 	printf("results: vers = '%s', cm = '%s'\n",
    133  1.1  jtc 		rp->vers, rp->cm);
    134  1.1  jtc 	printf("facilities_len = %d\n", rp->facilities.facilities_len);
    135  1.1  jtc 	if (rp->facilities.facilities_len) {
    136  1.1  jtc 		gp = rp->facilities.facilities_val;
    137  1.1  jtc 		for(i = 0; i < rp->facilities.facilities_len; i++)
    138  1.1  jtc 			printf(" procedure %2d: %6d\n", i, *gp++);
    139  1.1  jtc 		printf("\n");
    140  1.1  jtc 	}
    141  1.1  jtc /* free up allocated strings */
    142  1.1  jtc 	if(rp->cm)
    143  1.1  jtc 		free(rp->cm);
    144  1.1  jtc 	if(rp->facilities.facilities_val)
    145  1.1  jtc 		free(rp->facilities.facilities_val);
    146  1.1  jtc 	if(rp->vers)
    147  1.1  jtc 		free(rp->vers);
    148  1.1  jtc 
    149  1.1  jtc 	return(0);
    150  1.1  jtc }
    151  1.1  jtc 
    152  1.1  jtc test_v2_auth(host_name, user_name , pwrd)
    153  1.1  jtc char *host_name;
    154  1.1  jtc char *user_name;
    155  1.1  jtc char *pwrd;
    156  1.1  jtc {
    157  1.1  jtc v2_auth_args a;
    158  1.1  jtc v2_auth_results *rp;
    159  1.1  jtc char            uname[32];
    160  1.1  jtc char            pw[64];
    161  1.1  jtc u_int          *gp;
    162  1.1  jtc int             i;
    163  1.1  jtc 
    164  1.1  jtc 	scramble(user_name, uname);
    165  1.1  jtc 	scramble(pwrd, pw);
    166  1.1  jtc 	a.system = host_name;
    167  1.1  jtc 	a.id = uname;
    168  1.1  jtc 	a.pw = pw;
    169  1.1  jtc 	a.cm = "-";
    170  1.1  jtc 	printf("\ninvoking pr_auth_2\n");
    171  1.1  jtc 
    172  1.1  jtc 	rp = pcnfsd2_auth_2(&a, cl2);
    173  1.1  jtc 
    174  1.1  jtc 	if(rp == NULL) {
    175  1.1  jtc 		clnt_perror(cl2, server);
    176  1.1  jtc 		return(1);
    177  1.1  jtc 	}
    178  1.1  jtc 
    179  1.1  jtc 	if(rp->stat == AUTH_RES_FAIL)
    180  1.1  jtc 		printf("results: stat = AUTH_RES_FAIL\n");
    181  1.1  jtc 	else {
    182  1.1  jtc 	printf("results: stat = %d, uid = %u, gid = %u,\n homedir= '%s', cm = '%s'\n",
    183  1.1  jtc 		rp->stat, rp->uid, rp->gid, rp->home, rp->cm);
    184  1.1  jtc 	printf("gids_len = %d", rp->gids.gids_len);
    185  1.1  jtc 	if (rp->gids.gids_len) {
    186  1.1  jtc 		gp = rp->gids.gids_val;
    187  1.1  jtc 		for(i = 0; i < rp->gids.gids_len; i++)
    188  1.1  jtc 			printf(" %u", *gp++);
    189  1.1  jtc 		printf("\n");
    190  1.1  jtc 	}
    191  1.1  jtc 	}
    192  1.1  jtc /* free up allocated strings */
    193  1.1  jtc 	if(rp->cm)
    194  1.1  jtc 		free(rp->cm);
    195  1.1  jtc 	if(rp->gids.gids_val)
    196  1.1  jtc 		free(rp->gids.gids_val);
    197  1.1  jtc 	if(rp->home)
    198  1.1  jtc 		free(rp->home);
    199  1.1  jtc 
    200  1.1  jtc 	return(0);
    201  1.1  jtc }
    202  1.1  jtc 
    203  1.1  jtc test_v2_init(host_name, printer)
    204  1.1  jtc char *host_name;
    205  1.1  jtc char *printer;
    206  1.1  jtc {
    207  1.1  jtc v2_pr_init_args a;
    208  1.1  jtc v2_pr_init_results *rp;
    209  1.1  jtc 
    210  1.1  jtc 	a.system = host_name;
    211  1.1  jtc 	a.pn = printer;
    212  1.1  jtc 	a.cm = "-";
    213  1.1  jtc 	printf("\ninvoking pr_init_2\n");
    214  1.1  jtc 
    215  1.1  jtc 	rp = pcnfsd2_pr_init_2(&a, cl2);
    216  1.1  jtc 
    217  1.1  jtc 	if(rp == NULL) {
    218  1.1  jtc 		clnt_perror(cl2, server);
    219  1.1  jtc 		return(1);
    220  1.1  jtc 	}
    221  1.1  jtc 	printf("results: stat = %d, dir = '%s', cm = '%s'\n",
    222  1.1  jtc 		rp->stat, rp->dir, rp->cm);
    223  1.1  jtc 	strcpy(spooldirbuff, rp->dir);
    224  1.1  jtc /* free up allocated strings */
    225  1.1  jtc 	if(rp->cm)
    226  1.1  jtc 		free(rp->cm);
    227  1.1  jtc 	if(rp->dir)
    228  1.1  jtc 		free(rp->dir);
    229  1.1  jtc 	return(0);
    230  1.1  jtc }
    231  1.1  jtc 
    232  1.1  jtc 
    233  1.1  jtc test_v2_start(host_name, printer, user_name, tag1, tag2)
    234  1.1  jtc char *host_name;
    235  1.1  jtc char *printer;
    236  1.1  jtc char *user_name;
    237  1.1  jtc char *tag1;
    238  1.1  jtc char *tag2;
    239  1.1  jtc {
    240  1.1  jtc v2_pr_start_args a;
    241  1.1  jtc v2_pr_start_results *rp;
    242  1.1  jtc FILE *fp;
    243  1.1  jtc 	printf("\ntesting start print v2\n");
    244  1.1  jtc 
    245  1.1  jtc 	if(strcmp(server, "localhost")) {
    246  1.1  jtc 		printf("sorry - can only test start print on 'localhost'\n");
    247  1.1  jtc 		return(1);
    248  1.1  jtc 	}
    249  1.1  jtc 
    250  1.1  jtc 	sprintf(filenamebuff, "%s/%s", spooldirbuff, tag1);
    251  1.1  jtc 
    252  1.1  jtc 	fp = fopen(filenamebuff, "w");
    253  1.1  jtc 	if(fp == NULL) {
    254  1.1  jtc 		perror("creating test file");
    255  1.1  jtc 		return(1);
    256  1.1  jtc 	}
    257  1.1  jtc 	(void)fputs("foo bar bletch\n", fp);
    258  1.1  jtc 	(void)fclose(fp);
    259  1.1  jtc 
    260  1.1  jtc 	a.system = host_name;
    261  1.1  jtc 	a.pn = printer;
    262  1.1  jtc 	a.user = user_name;
    263  1.1  jtc 	a.file = tag2;
    264  1.1  jtc 	a.opts = "xxxx";
    265  1.1  jtc 	a.copies = 1;
    266  1.1  jtc 	a.cm = "-";
    267  1.1  jtc 
    268  1.1  jtc 	printf("\ninvoking pr_start_2\n");
    269  1.1  jtc 
    270  1.1  jtc 	rp = pcnfsd2_pr_start_2(&a, cl2);
    271  1.1  jtc 
    272  1.1  jtc 	if(rp == NULL) {
    273  1.1  jtc 		clnt_perror(cl2, server);
    274  1.1  jtc 		return(1);
    275  1.1  jtc 	}
    276  1.1  jtc 	printf("results: stat = %d, jobid = '%s', cm = '%s'\n",
    277  1.1  jtc 		rp->stat, rp->id, rp->cm);
    278  1.1  jtc 	if(rp->stat == PS_RES_OK)
    279  1.1  jtc 		strcpy(last_id, rp->id);
    280  1.1  jtc /* free up allocated strings */
    281  1.1  jtc 	if(rp->cm)
    282  1.1  jtc 		free(rp->cm);
    283  1.1  jtc 	if(rp->id)
    284  1.1  jtc 		free(rp->id);
    285  1.1  jtc 	return(0);
    286  1.1  jtc }
    287  1.1  jtc 
    288  1.1  jtc 
    289  1.1  jtc test_v2_cancel(host_name, printer, user_name, id)
    290  1.1  jtc char *host_name;
    291  1.1  jtc char *printer;
    292  1.1  jtc char *user_name;
    293  1.1  jtc char *id;
    294  1.1  jtc {
    295  1.1  jtc v2_pr_cancel_args a;
    296  1.1  jtc v2_pr_cancel_results *rp;
    297  1.1  jtc 	printf("\ntesting cancel print v2\n");
    298  1.1  jtc 
    299  1.1  jtc 	a.system = host_name;
    300  1.1  jtc 	a.pn = printer;
    301  1.1  jtc 	a.user = user_name;
    302  1.1  jtc 	a.id = id;
    303  1.1  jtc 	a.cm = "-";
    304  1.1  jtc 
    305  1.1  jtc 	printf("\ninvoking pr_cancel_2 for job %s on printer %s\n",
    306  1.1  jtc 		id, printer);
    307  1.1  jtc 
    308  1.1  jtc 	rp = pcnfsd2_pr_cancel_2(&a, cl2);
    309  1.1  jtc 
    310  1.1  jtc 	if(rp == NULL) {
    311  1.1  jtc 		clnt_perror(cl2, server);
    312  1.1  jtc 		return(1);
    313  1.1  jtc 	}
    314  1.1  jtc 	printf("results: stat = %d, cm = '%s'\n",
    315  1.1  jtc 		rp->stat, rp->cm);
    316  1.1  jtc /* free up allocated strings */
    317  1.1  jtc 	if(rp->cm)
    318  1.1  jtc 		free(rp->cm);
    319  1.1  jtc 	return(0);
    320  1.1  jtc }
    321  1.1  jtc test_v2_list()
    322  1.1  jtc {
    323  1.1  jtc char a;
    324  1.1  jtc v2_pr_list_results *rp;
    325  1.1  jtc pr_list curr;
    326  1.1  jtc 
    327  1.1  jtc 
    328  1.1  jtc 	printf("\ninvoking pr_list_2\n");
    329  1.1  jtc 
    330  1.1  jtc 	rp = pcnfsd2_pr_list_2(&a, cl2);
    331  1.1  jtc 
    332  1.1  jtc 	if(rp == NULL) {
    333  1.1  jtc 		clnt_perror(cl2, server);
    334  1.1  jtc 		return(1);
    335  1.1  jtc 	}
    336  1.1  jtc 	printf("results: cm = '%s', printerlist:\n", rp->cm);
    337  1.1  jtc 	curr = rp->printers;
    338  1.1  jtc 	while(curr) {
    339  1.1  jtc 		printf("  name '%s' ", curr->pn);
    340  1.1  jtc 		if(strlen(curr->remhost))
    341  1.1  jtc 			printf("remote: srvr '%s', name '%s'",
    342  1.1  jtc 				curr->remhost,
    343  1.1  jtc 				curr->device);
    344  1.1  jtc 		else
    345  1.1  jtc 			printf("local device = '%s'", curr->device);
    346  1.1  jtc 		printf(", cm = '%s'\n", curr->cm);
    347  1.1  jtc 		curr = curr->pr_next;
    348  1.1  jtc 	}
    349  1.1  jtc 	printf("end of list\n");
    350  1.1  jtc /* free up allocated strings */
    351  1.1  jtc 	if(rp->cm)
    352  1.1  jtc 		free(rp->cm);
    353  1.1  jtc 	if(rp->printers) {
    354  1.1  jtc 		printf("freeing results\n");
    355  1.1  jtc 		free_pr_list_item(rp->printers);
    356  1.1  jtc 	}
    357  1.1  jtc 	return(0);
    358  1.1  jtc }
    359  1.1  jtc 
    360  1.1  jtc 
    361  1.1  jtc void
    362  1.1  jtc free_pr_list_item(curr)
    363  1.1  jtc pr_list curr;
    364  1.1  jtc {
    365  1.1  jtc 	if(curr->pn)
    366  1.1  jtc 		free(curr->pn);
    367  1.1  jtc 	if(curr->remhost)
    368  1.1  jtc 		free(curr->remhost);
    369  1.1  jtc 	if(curr->device)
    370  1.1  jtc 		free(curr->device);
    371  1.1  jtc 	if(curr->cm)
    372  1.1  jtc 		free(curr->cm);
    373  1.1  jtc 	if(curr->pr_next)
    374  1.1  jtc 		free_pr_list_item(curr->pr_next); /* recurse */
    375  1.1  jtc 	free(curr);
    376  1.1  jtc }
    377  1.1  jtc 
    378  1.1  jtc 
    379  1.1  jtc 
    380  1.1  jtc test_v2_queue(printer, user_name, private)
    381  1.1  jtc char *printer;
    382  1.1  jtc char *user_name;
    383  1.1  jtc int private;
    384  1.1  jtc {
    385  1.1  jtc struct v2_pr_queue_args a;
    386  1.1  jtc v2_pr_queue_results *rp;
    387  1.1  jtc pr_queue curr;
    388  1.1  jtc 
    389  1.1  jtc 	a.pn = printer;
    390  1.1  jtc 	a.system = "foo";
    391  1.1  jtc 	a.user = user_name;
    392  1.1  jtc 	a.just_mine = private;
    393  1.1  jtc 	a.cm = "no";
    394  1.1  jtc 
    395  1.1  jtc 	printf("\ninvoking pr_queue_2 (just_mine = %d)\n", private);
    396  1.1  jtc 
    397  1.1  jtc 	rp = pcnfsd2_pr_queue_2(&a, cl2);
    398  1.1  jtc 
    399  1.1  jtc 	if(rp == NULL) {
    400  1.1  jtc 		clnt_perror(cl2, server);
    401  1.1  jtc 		return(1);
    402  1.1  jtc 	}
    403  1.1  jtc 	printf("results: stat = %d, qlen = %d, qshown = %d cm = '%s', queue:\n",
    404  1.1  jtc 		rp->stat, rp->qlen, rp->qshown, rp->cm);
    405  1.1  jtc 	curr = rp->jobs;
    406  1.1  jtc 	while(curr) {
    407  1.1  jtc 		printf("rank = %2d, id = '%s', size = '%s', status = '%s'\n",
    408  1.1  jtc 			curr->position,
    409  1.1  jtc 			curr->id,
    410  1.1  jtc 			curr->size,
    411  1.1  jtc 			curr->status);
    412  1.1  jtc 		printf("            user = '%s', file = '%s', cm = '%s'\n",
    413  1.1  jtc 			curr->user,
    414  1.1  jtc 			curr->file,
    415  1.1  jtc 			curr->cm);
    416  1.1  jtc 		curr = curr->pr_next;
    417  1.1  jtc 	}
    418  1.1  jtc 	printf("end of list\n");
    419  1.1  jtc /* free up allocated strings */
    420  1.1  jtc 	if(rp->cm)
    421  1.1  jtc 		free(rp->cm);
    422  1.1  jtc 	if(rp->jobs) {
    423  1.1  jtc 		printf("freeing results\n");
    424  1.1  jtc 		free_pr_queue_item(rp->jobs);
    425  1.1  jtc 	}
    426  1.1  jtc 	return(0);
    427  1.1  jtc }
    428  1.1  jtc 
    429  1.1  jtc 
    430  1.1  jtc 
    431  1.1  jtc void
    432  1.1  jtc free_pr_queue_item(curr)
    433  1.1  jtc pr_queue curr;
    434  1.1  jtc {
    435  1.1  jtc 	if(curr->id)
    436  1.1  jtc 		free(curr->id);
    437  1.1  jtc 	if(curr->size)
    438  1.1  jtc 		free(curr->size);
    439  1.1  jtc 	if(curr->status)
    440  1.1  jtc 		free(curr->status);
    441  1.1  jtc 	if(curr->system)
    442  1.1  jtc 		free(curr->system);
    443  1.1  jtc 	if(curr->user)
    444  1.1  jtc 		free(curr->user);
    445  1.1  jtc 	if(curr->file)
    446  1.1  jtc 		free(curr->file);
    447  1.1  jtc 	if(curr->cm)
    448  1.1  jtc 		free(curr->cm);
    449  1.1  jtc 	if(curr->pr_next)
    450  1.1  jtc 		free_pr_queue_item(curr->pr_next); /* recurse */
    451  1.1  jtc 	free(curr);
    452  1.1  jtc }
    453  1.1  jtc 
    454  1.1  jtc 
    455  1.1  jtc 
    456  1.1  jtc test_v2_stat(printer)
    457  1.1  jtc char *printer;
    458  1.1  jtc {
    459  1.1  jtc v2_pr_status_args a;
    460  1.1  jtc v2_pr_status_results *rp;
    461  1.1  jtc 
    462  1.1  jtc 	printf("\ntesting status print v2\n");
    463  1.1  jtc 
    464  1.1  jtc 	a.pn = printer;
    465  1.1  jtc 	a.cm = "-";
    466  1.1  jtc 
    467  1.1  jtc 	printf("\ninvoking pr_status_2\n");
    468  1.1  jtc 
    469  1.1  jtc 	rp = pcnfsd2_pr_status_2(&a, cl2);
    470  1.1  jtc 
    471  1.1  jtc 	if(rp == NULL) {
    472  1.1  jtc 		clnt_perror(cl2, server);
    473  1.1  jtc 		return(1);
    474  1.1  jtc 	}
    475  1.1  jtc 	printf("results: stat = %d, cm = '%s'\n",
    476  1.1  jtc 		rp->stat, rp->cm);
    477  1.1  jtc 	if(rp->stat == PI_RES_OK) {
    478  1.1  jtc 		printf("avail = %s, ", (rp->avail ? "YES" : "NO"));
    479  1.1  jtc 		printf("printing = %s, ", (rp->printing ? "YES" : "NO"));
    480  1.1  jtc 		printf("needs_operator = %s, ", (rp->needs_operator ? "YES" : "NO"));
    481  1.1  jtc 		printf("qlen = %d, status = '%s'\n", rp->qlen, rp->status);
    482  1.1  jtc 	}
    483  1.1  jtc /* free up allocated strings */
    484  1.1  jtc 	if(rp->cm)
    485  1.1  jtc 		free(rp->cm);
    486  1.1  jtc 	if(rp->status)
    487  1.1  jtc 		free(rp->status);
    488  1.1  jtc 	return(0);
    489  1.1  jtc }
    490  1.1  jtc 
    491  1.1  jtc struct mapreq_arg_item * make_mapreq_entry(t, i, n, next)
    492  1.1  jtc mapreq	t;
    493  1.1  jtc int i;
    494  1.1  jtc char *n;
    495  1.1  jtc struct mapreq_arg_item *next;
    496  1.1  jtc {
    497  1.1  jtc struct mapreq_arg_item *x;
    498  1.1  jtc 	x = (struct mapreq_arg_item *)malloc(sizeof(struct mapreq_arg_item));
    499  1.1  jtc 	if(x == NULL) {
    500  1.1  jtc 		fprintf(stderr, "out of memory\n");
    501  1.1  jtc 		exit(123);
    502  1.1  jtc 	}
    503  1.1  jtc 	x->req = t;
    504  1.1  jtc 	x->id = i;
    505  1.1  jtc 	x->name = (n ? n : "");
    506  1.1  jtc 	x->mapreq_next = next;
    507  1.1  jtc 	return(x);
    508  1.1  jtc }
    509  1.1  jtc 
    510  1.1  jtc test_v2_map()
    511  1.1  jtc {
    512  1.1  jtc v2_mapid_args a;
    513  1.1  jtc v2_mapid_results *rp;
    514  1.1  jtc struct mapreq_res_item *rip;
    515  1.1  jtc 
    516  1.1  jtc 	a.cm = "-";
    517  1.1  jtc 	a.req_list = make_mapreq_entry(MAP_REQ_UID, 906, NULL,
    518  1.1  jtc 		make_mapreq_entry(MAP_REQ_GID, 1, NULL,
    519  1.1  jtc 		 make_mapreq_entry(MAP_REQ_UNAME, 0, "root",
    520  1.1  jtc 		   make_mapreq_entry(MAP_REQ_GNAME, 0, "wheel",
    521  1.1  jtc 		      make_mapreq_entry(MAP_REQ_UNAME, 0, "bogus", NULL)))));
    522  1.1  jtc 
    523  1.1  jtc 	printf("\ninvoking pr_mapid_2\n");
    524  1.1  jtc 	rp = pcnfsd2_mapid_2(&a, cl2);
    525  1.1  jtc 
    526  1.1  jtc 	if(rp == NULL) {
    527  1.1  jtc 		clnt_perror(cl2, server);
    528  1.1  jtc 		return(1);
    529  1.1  jtc 	}
    530  1.1  jtc 	printf("results: cm = '%s', result list %s\n",
    531  1.1  jtc 		rp->cm, rp->res_list ? "follows" : "omitted");
    532  1.1  jtc 	rip = rp->res_list;
    533  1.1  jtc 	while(rip) {
    534  1.1  jtc 		printf("request type = %d, status = %d, id = %d, name = '%s'\n",
    535  1.1  jtc 			rip->req, rip->stat, rip->id,
    536  1.1  jtc 			(rip->name ? rip->name : "(NULL)"));
    537  1.1  jtc 		rip = rip->mapreq_next;
    538  1.1  jtc 	}
    539  1.1  jtc /* XXX should free up results */
    540  1.1  jtc 
    541  1.1  jtc 
    542  1.1  jtc 
    543  1.1  jtc return(0);
    544  1.1  jtc }
    545  1.1  jtc 
    546  1.1  jtc 
    547  1.1  jtc void
    548  1.1  jtc good()
    549  1.1  jtc {
    550  1.1  jtc printf("\n");
    551  1.1  jtc printf("********************************************************\n");
    552  1.1  jtc printf("********************************************************\n");
    553  1.1  jtc printf("**      The following test is expected to SUCCEED     **\n");
    554  1.1  jtc printf("********************************************************\n");
    555  1.1  jtc printf("********************************************************\n");
    556  1.1  jtc }
    557  1.1  jtc 
    558  1.1  jtc void
    559  1.1  jtc bad(reason)
    560  1.1  jtc char *reason;
    561  1.1  jtc {
    562  1.1  jtc printf("\n");
    563  1.1  jtc printf("********************************************************\n");
    564  1.1  jtc printf("********************************************************\n");
    565  1.1  jtc printf("**      The following test is expected to FAIL        **\n");
    566  1.1  jtc printf("**                    Reason:                         **\n");
    567  1.1  jtc printf("** %50s **\n", reason);
    568  1.1  jtc printf("********************************************************\n");
    569  1.1  jtc printf("********************************************************\n");
    570  1.1  jtc }
    571