xref: /csrg-svn/sys/vax/stand/drtest.c (revision 9973)
1*9973Ssam /*	drtest.c	4.1	82/12/26	*/
2*9973Ssam 
3*9973Ssam /*
4*9973Ssam  * Standalone program to test a disk driver by reading
5*9973Ssam  * every sector on the disk in chunks of CHUNK.
6*9973Ssam  */
7*9973Ssam extern	struct hpst  {
8*9973Ssam 	short nsect;
9*9973Ssam 	short ntrak;
10*9973Ssam 	short nspc;
11*9973Ssam 	short ncyl;
12*9973Ssam 	short *off;
13*9973Ssam } hpst[] ;
14*9973Ssam 
15*9973Ssam extern	struct upst  {
16*9973Ssam 	short nsect;
17*9973Ssam 	short ntrak;
18*9973Ssam 	short nspc;
19*9973Ssam 	short ncyl;
20*9973Ssam 	short *off;
21*9973Ssam } upst[] ;
22*9973Ssam extern struct updevice;
23*9973Ssam extern struct hpdevice;
24*9973Ssam extern char up_type[];
25*9973Ssam extern char hp_type[];
26*9973Ssam 
27*9973Ssam #define CHUNK 32
28*9973Ssam 
29*9973Ssam main()
30*9973Ssam {
31*9973Ssam 	char buf[50], buffer[CHUNK*512];
32*9973Ssam 	int unit,fd,chunk,j;
33*9973Ssam 	register struct upst *st;
34*9973Ssam 	register i;
35*9973Ssam 
36*9973Ssam 	printf("Testprogram for stand-alone hp or up driver\n");
37*9973Ssam askunit:
38*9973Ssam 	printf("Enter device name (e.g, hp(0,0) ) or q to quit >");
39*9973Ssam 	gets(buf);
40*9973Ssam 	unit = (int)*(buf+3) - '0';
41*9973Ssam 	if (unit <0 || unit > 3 ) {
42*9973Ssam 		printf("unit number out of range\n");
43*9973Ssam 		goto askunit;
44*9973Ssam 	}
45*9973Ssam 	if ((fd=open(buf,0)) < 0) {
46*9973Ssam 		printf("Can't open %s \n",buf);
47*9973Ssam 		goto askunit;
48*9973Ssam 	}
49*9973Ssam 	switch(*buf) {
50*9973Ssam 
51*9973Ssam 	case 'u':
52*9973Ssam 		st = &upst[up_type[unit]];
53*9973Ssam 		break;
54*9973Ssam 
55*9973Ssam 	case 'h':
56*9973Ssam 		st = (struct upst *)&hpst[hp_type[unit]];
57*9973Ssam 		break;
58*9973Ssam 
59*9973Ssam 	default:
60*9973Ssam 		printf("Illegal device name\n");
61*9973Ssam 		goto askunit;
62*9973Ssam 	}
63*9973Ssam 
64*9973Ssam 	chunk = st->nsect;
65*9973Ssam 	printf("Testing %s\n",buf);
66*9973Ssam 	printf("Start ...Make sure %s is online\n",buf);
67*9973Ssam 	lseek(fd,0,0);
68*9973Ssam 	for (i=0;i < st->ncyl;i++) {
69*9973Ssam 		for (j=8;j<st->ntrak+8;j++) {
70*9973Ssam 			lseek(fd,(i*st->nspc+((j%st->ntrak)*st->nsect))*512,0);
71*9973Ssam 			read(fd,buffer, chunk*512);
72*9973Ssam 		}
73*9973Ssam 		printf("%d\015",i);
74*9973Ssam 	}
75*9973Ssam 	goto askunit;
76*9973Ssam }
77