1 | /*
|
---|
2 | * $ZEL$
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "test_3100.h"
|
---|
6 |
|
---|
7 | u_int32_t* buf;
|
---|
8 | int bufsize;
|
---|
9 |
|
---|
10 | struct path* pathes;
|
---|
11 | int numpathes;
|
---|
12 |
|
---|
13 | static void
|
---|
14 | printusage(int argc, char* argv[])
|
---|
15 | {
|
---|
16 | printf("usage: %s [-h] pathnames...\n",
|
---|
17 | argv[0]);
|
---|
18 | }
|
---|
19 |
|
---|
20 | static void
|
---|
21 | printhelp(int argc, char* argv[])
|
---|
22 | {
|
---|
23 | printf("printhelp not yet implemented\n");
|
---|
24 | }
|
---|
25 |
|
---|
26 | static int
|
---|
27 | getoptions(int argc, char* argv[])
|
---|
28 | {
|
---|
29 | extern char *optarg;
|
---|
30 | extern int optind;
|
---|
31 | extern int opterr;
|
---|
32 | extern int optopt;
|
---|
33 | int errflag, c, i;
|
---|
34 | const char* args="h";
|
---|
35 |
|
---|
36 | optarg=0; errflag=0;
|
---|
37 |
|
---|
38 | while (!errflag && ((c=getopt(argc, argv, args))!=-1)) {
|
---|
39 | switch (c) {
|
---|
40 | case 'h': printhelp(argc, argv); break;
|
---|
41 | default: errflag++;
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | if (errflag || optind==argc) {
|
---|
46 | printusage(argc, argv);
|
---|
47 | return -1;
|
---|
48 | }
|
---|
49 |
|
---|
50 | numpathes=argc-optind;
|
---|
51 | pathes=malloc(numpathes*sizeof(struct path));
|
---|
52 | for (i=0; i<numpathes; i++) {
|
---|
53 | pathes[i].name=argv[optind+i];
|
---|
54 | pathes[i].p=-1;
|
---|
55 | }
|
---|
56 |
|
---|
57 | return 0;
|
---|
58 | }
|
---|
59 |
|
---|
60 | typedef int(*testfunc)(struct path*);
|
---|
61 | struct testfunc {
|
---|
62 | testfunc func;
|
---|
63 | char* name;
|
---|
64 | };
|
---|
65 |
|
---|
66 | struct testfunc funcs[]={
|
---|
67 | init_path, "INIT",
|
---|
68 | check_reopen, "REOPEN",
|
---|
69 | /*check_RESET,*/
|
---|
70 | check_MAPSIZE, "MAPSIZE",
|
---|
71 | check_mmap, "MMAP", /* requires check_MAPSIZE */
|
---|
72 | check_IDENT, "IDENT", /* can use check_mmap */
|
---|
73 |
|
---|
74 | /*check_rw,*/
|
---|
75 | check_VME_BLOCK_READ, "VME_BLOCK_READ",
|
---|
76 |
|
---|
77 | #if 0
|
---|
78 | check_SETVMESPACE,
|
---|
79 | check_VME_PROBE,
|
---|
80 | check_VME_READ,
|
---|
81 | check_VME_WRITE,
|
---|
82 | check_VME_BLOCK_WRITE,
|
---|
83 | check_CONTROL_READ,
|
---|
84 | check_CONTROL_WRITE,
|
---|
85 | check_CONTROL_READ,
|
---|
86 | check_CONTROL_WRITE,
|
---|
87 | check_PIPE,
|
---|
88 | check_LAST_ERROR,
|
---|
89 | check_FIFOMODE,
|
---|
90 |
|
---|
91 | check_BIGENDIAN,
|
---|
92 |
|
---|
93 | check_IRQ_CTL,
|
---|
94 | check_IRQ_GET,
|
---|
95 | check_IRQ_ACK,
|
---|
96 | check_IRQ_WAIT,
|
---|
97 |
|
---|
98 | check_MINDMALEN,
|
---|
99 |
|
---|
100 | check_FRONT_IO,
|
---|
101 | check_FRONT_PULSE,
|
---|
102 | check_FRONT_LATCH,
|
---|
103 |
|
---|
104 | check_VME_SUPER_BLOCK_READ,
|
---|
105 | check_WRITE_PIPE,
|
---|
106 |
|
---|
107 | check_DMA_ALLOC,
|
---|
108 | check_DMA_FREE,
|
---|
109 |
|
---|
110 | check_DUMP,
|
---|
111 | #endif
|
---|
112 | };
|
---|
113 | int numfuncs=sizeof(funcs)/sizeof(struct testfunc);
|
---|
114 |
|
---|
115 | int main(int argc, char* argv[])
|
---|
116 | {
|
---|
117 | int res=0, i, j;
|
---|
118 |
|
---|
119 | printf("\n==== SIS1100/3100 Test; V2.01 ====\n\n");
|
---|
120 |
|
---|
121 | #if SIS1100_Version>0
|
---|
122 | printf("%s is compiled for version %d.%d of sis1100 driver\n",
|
---|
123 | argv[0],
|
---|
124 | MAJORVERSION,
|
---|
125 | MINORVERSION);
|
---|
126 | #else
|
---|
127 | printf("the version %s is compiled for is not known; we assume %d.%d\n",
|
---|
128 | argv[0],
|
---|
129 | MAJORVERSION,
|
---|
130 | MINORVERSION);
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | if (getoptions(argc, argv)<0) return 1;
|
---|
134 |
|
---|
135 | bufsize=1024000;
|
---|
136 | buf=calloc(bufsize, 4);
|
---|
137 | if (!buf) {
|
---|
138 | printf("\ncannot allocate %d words\n", bufsize);
|
---|
139 | return -1;
|
---|
140 | }
|
---|
141 |
|
---|
142 | srandom(17);
|
---|
143 |
|
---|
144 | for (i=0; i<numfuncs; i++) {
|
---|
145 | printf("\nTesting %s:\n", funcs[i].name);
|
---|
146 | for (j=0; j<numpathes; j++) {
|
---|
147 | if (funcs[i].func(pathes+j)<0) {res=i+3; goto raus;}
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | raus:
|
---|
152 | for (j=0; j<numpathes; j++) done_path(pathes+j);
|
---|
153 | return res;
|
---|
154 | }
|
---|