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