ai.c
3.49 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
#include <sys/types.h>
#ifdef __sgi__
#include <sys/sbd.h>
#endif
#include <sys/stat.h>
#include <sys/mman.h>
#ifdef __sgi__
#include <sys/sema.h>
#endif
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <getopt.h>
#include <rcp.h>
#include "diag.h"
#include <dbg_comm.h>
#define AI_TEST_BASE 1
int ai_status_rd(TEST_REF *test_ref);
int ai_length_reg(TEST_REF *test_ref);
int ai_pintests(TEST_REF *test_ref);
int ai_sounds(TEST_REF *test_ref);
static int Failed;
/*
* Create an array of tests, each of which corresponds to a separate menu
* item callable from the master ide menu.
*/
static TEST_REF TestRefs[] = {
{"AI Hard-Wired Status Read", AI_TEST_BASE+0, ai_status_rd},
{"AI Length Reg Tests", AI_TEST_BASE+1, ai_length_reg},
{"AI Pin Level Test", AI_TEST_BASE+2, ai_pintests},
{"AI Sound Buffer Play Test", AI_TEST_BASE+3, ai_sounds},
{"END OF TESTS",0,0}
};
static char *addr, *mask, *count;
static int NumFailures = 0;
static int aiInit();
static int aiDo(TEST_REF *test_ref);
int NameValid;
char Name[80];
/*
* diagnostic entry point:
*
* Each separately invokable ide diagnostic command corresponds to an
* independent ".c" module; the entry point herein must match
* the test name as specified in the rdpcmd.awk script. These command
* names correspond to the names you see from the ide menu. For this
* module, there will be an ide command "rdp_bp" (until this
* silly module is retired, that is).
*/
int aiEntry()
{
int c;
int testNum;
/*
* Sample of how to parse command line args received from ide
*/
while ((c = getopt(pGlobalComm->argc, pGlobalComm->argv, "ht:n:")) != EOF) {
switch(c) {
case 'h':
/*
* Print out the available subtests, then return without
* invoking any subtests (which is done by calling diaginit()).
*/
dgListSubTests(TestRefs);
return(0);
break;
case 't':
testNum = atoi(optarg);
pGlobalComm->entryNum = -(testNum);
break;
case 'n':
NameValid = 1;
strcpy(Name, optarg);
break;
default:
printf("weird option character %c = 0x%x\n", c, c);
break;
}
}
/*
* IDE will call our one-time initialization function rdp_bpInit(),
* then invoke rdp_bpDo() for as many tests as we've put into the
* global test array "TestRefs", declared at the top of this module.
*/
diaginit(TestRefs, aiInit, aiDo);
if (NumFailures) {
errlog(INFO, "... test %s FAILED, %d failures.",
ideTestName, NumFailures);
} else {
errlog(INFO, "... test %s PASSED", ideTestName);
}
}
static int aiInit()
{
char *env;
errlog(INFO, "Starting test %s ... ", ideTestName);
NumFailures = 0;
/*
* Setup the diagnostic communication link to the target system.
*
* (this uses the global ide variable "commtype", which by default
* is set to DG_VERILOG.)
*/
dgInitComm();
return(0);
}
static int aiDo(TEST_REF *test_ref)
{
int error_count;
errlog(INFO,
"%s: starting subtest %s (%d) ...",
ideTestName, test_ref->name, test_ref->num);
/*
* Invoke the actual test from the "TEST_REF" array statically declared
* as a global within this test module.
*/
if (error_count = test_ref->fnc(test_ref)) {
Failed = 1;
errlog(INFO, "... subtest %s FAILED, %d failures",
test_ref->name, error_count);
} else {
errlog(INFO, "... subtest %s PASSED", test_ref->name);
}
return 0;
}