si_testr.c
4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*************************************************************************
*
* File: si_testr.c
*
* This file contains then main routine for BCP SI iosim tests for
* the random test env.
*
*/
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include "../iomap.h"
#include "../iotest.h"
#include "../sim.h"
#include "../simipc.h"
#include "../bcptestsi.h"
#include "../trace.h"
#include "../bcp_util.h"
#include "../bcptest.h"
/***********************************************************************
* Extern definitions
*/
extern void IoTestAll(int testid, char* arg1, char* arg2, int seed);
extern int IoCmd(int code, int data);
/***********************************************************************
* Macro definitions
*/
#define TEST_CMD_FILE "all.tst"
#define OPTARG "d:0:t:s:qh"
/***********************************************************************
* Global definitions
*/
int IpcFd = -1;
unsigned long Dflags;
char *CmdFile = TEST_CMD_FILE;
FILE *LogFp, *CmdFp;
int ConfigRdramV = 0;
int NumberStallCycles = 0;
/***********************************************************************
* Local static definitions
*/
//static FILE *dumpFp = NULL;
static void usage(void);
//static void convertTst2C(char *);
int
main(int argc, char **argv)
{
int c, testid=0, seed=0, req_quit=0;
char *file;
FILE *fp = NULL;
extern char *optarg;
extern int optind, opterr, optopt;
char *arg[2] = {0,0};
int i;
optind = 1;
Dflags = 0;
LogFp = stderr;
while ((c = getopt(argc, argv, OPTARG)) != EOF) {
switch (c) {
case 'd': { /* Debug flag */
Dflags = strtoul(optarg, NULL, 16);
printf("Debug flag=0x%08lx\n", Dflags);
break;
}
case 'o': { /* Log file */
file = optarg;
printf("Log file = %s\n", file);
if ((fp = fopen(file, "w+")) == NULL) {
printf("Unable to open log: %s\n",
file);
}
else
LogFp = fp;
break;
}
case 't': { /* id of test to run */
testid = strtoul(optarg,NULL,10);
printf("testid=%d\n", testid);
break;
}
case 's': { /* seed that overrides any other method of getting seed */
seed = strtoul(optarg,NULL,16);
printf("seed=0x%08x\n", seed);
break;
}
case 'q': { /* shut down simulator on exit */
req_quit=1;
printf("shut down simulator on exit\n");
break;
}
case 'h': { /* Help */
usage();
exit(0);
}
default:
break;
}
} /* while */
if ( (argc-optind-1) > (int)(sizeof arg/sizeof arg[0]) ) {
usage();
exit(1);
}
for(i=0; optind<argc; ++i,++optind) {
arg[i] = argv[optind];
}
ExceptionHandlerInit();
IpcInit(NULL);
FindServer();
do_keep_alive_socket(1);
IoTestAll(testid,arg[0],arg[1],seed);
if (fp)
fclose(fp);
if (IpcFd != -1)
IpcClose(IpcFd);
do_keep_alive_socket(0);
/* exit simulator */
if(req_quit)
IoCmd(REQ_QUIT, 0);
exit(0);
}
void IoTestAll(int testid, char* arg1, char* arg2, int seed)
{
int i, ret, errCount;
i = errCount = 0;
i++;
ret = SiTestRandEnv(testid, arg1, arg2, seed);
if (ret == -1 || errorTotal) errCount++;
fprintf(LogFp,
"\n\n SiTestRandEnv(%d, 0, 0, %#08x) -> %s\n\n",
testid, seed, errCount ? "Failed":"Passed");
fprintf(LogFp,
"\n***** THE END (total test = %d, error count = %d) *****\n\n",
i, errCount);
}
static void
usage(void)
{
printf("Usage: si_testr <options> [test_arg1] [test_arg2]\n");
printf(" test_arg1 and test_arg2 are test specific (default NULL)");
printf(" -o <log_file>\n");
printf(" -t <testid>\n");
printf(" Decimal number identifying test to run\n");
printf(" Default is testid==0\n");
printf(" -s <seed>\n");
printf(" Hex seed that overrides default method of getting seed\n");
printf(" Only used if <seed> is non-zero\n");
printf(" -d <debug_flags in hex>\n");
printf(" -q\n");
printf(" Shut down the simulator on exit\n");
}