4
* Expected SUCCESSes for all tests: 3
9
* Test of hash_engineID(). SUCCESSes: 0
10
* Test of LCD Engine ID and Time List. SUCCESSes: 3
12
* FIX Devise a test for {set,get}_enginetime(..., FALSE).
15
static char *rcsid = "$Id: etimetest.c,v 5.0 2002/04/20 07:30:22 hardaker Exp $"; /* */
18
#include <net-snmp/net-snmp-config.h>
21
#include <sys/types.h>
25
#ifdef HAVE_NETINET_IN_H
26
#include <netinet/in.h>
33
#include "snmp_debug.h"
36
static u_int dummy_etime, dummy_eboot; /* For ISENGINEKNOWN(). */
42
extern int optind, optopt, opterr;
51
#define USAGE "Usage: %s [-h][-s <seconds>][-aeH]"
52
#define OPTIONLIST "aehHs:"
54
int doalltests = 0, dohashindex = 0, doetimetest = 0;
56
#define ALLOPTIONS (doalltests + dohashindex + doetimetest)
60
#define LOCAL_MAXBUF (1024 * 8)
63
#define OUTPUT(o) fprintf(stdout, "\n\n%s\n\n", o);
68
fprintf(stdout, "\nSUCCESS: %s\n", s); \
71
#define FAILED(e, f) \
73
if (e != SNMPERR_SUCCESS) { \
74
fprintf(stdout, "\nFAILED: %s\n", f); \
86
#define BLAT "alk;djf;an riu;alicenmrul;aiknglksajhe1 adcfalcenrco2"
94
void usage(FILE * ofp);
97
int test_hashindex(void);
103
main(int argc, char **argv)
105
int rval = SNMPERR_SUCCESS, failcount = 0;
108
local_progname = argv[0];
113
while ((ch = getopt(argc, argv, OPTIONLIST)) != EOF) {
125
sleeptime = atoi(optarg);
147
} /* endwhile getopt */
153
} else if (ALLOPTIONS != 1) {
163
FAILED(rval, "sc_init()");
166
if (dohashindex || doalltests) {
167
failcount += test_hashindex();
169
if (doetimetest || doalltests) {
170
failcount += test_etime();
177
rval = sc_shutdown(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_SHUTDOWN,
179
FAILED(rval, "sc_shutdown()");
196
" -e Exercise the list of enginetimes."
200
" -H Test hash_engineID()."
202
" -s <seconds> Seconds to pause. (Default: 0.)"
203
NL NL, local_progname);
211
/*******************************************************************-o-******
215
* Number of failures.
221
test_dosomething(void)
223
int rval = SNMPERR_SUCCESS, failcount = 0;
225
test_dosomething_quit:
228
} /* end test_dosomething() */
235
/*******************************************************************-o-******
239
* Number of failures.
242
* Test hash_engineID().
247
int /* rval = SNMPERR_SUCCESS, */
251
OUTPUT("Visual spot check of hash index outputs. "
252
"(Success or failure not noted.)");
255
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
258
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
261
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
264
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
267
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
270
fprintf(stdout, "%s = %d\n", s, hash_engineID(s, strlen(s)));
273
OUTPUT("Visual spot check -- DONE.");
277
} /* end test_hashindex() */
283
/*******************************************************************-o-******
287
* Number of failures.
289
* Test of LCD Engine ID and Time List.
294
int rval = SNMPERR_SUCCESS, failcount = 0;
298
* ------------------------------------ -o-
300
OUTPUT("Query of empty list, two set actions.");
303
rval = ISENGINEKNOWN("A", 1);
305
FAILED(SNMPERR_GENERR, "Query of empty list returned TRUE.")
309
rval = set_enginetime("BB", 2, 2, 20, TRUE);
310
FAILED(rval, "set_enginetime()");
313
rval = set_enginetime("CCC", 3, 31, 90127, TRUE);
314
FAILED(rval, "set_enginetime()");
317
SUCCESS("Check of empty list, and two additions.");
322
* ------------------------------------ -o-
324
OUTPUT("Add entries using macros, test for existence with macros.");
327
rval = ENSURE_ENGINE_RECORD("DDDD", 4);
328
FAILED(rval, "ENSURE_ENGINE_RECORD()");
331
rval = MAKENEW_ENGINE_RECORD("EEEEE", 5);
332
if (rval == SNMPERR_SUCCESS) {
334
"MAKENEW_ENGINE_RECORD returned success for "
339
rval = MAKENEW_ENGINE_RECORD("BB", 2);
340
FAILED(rval, "MAKENEW_ENGINE_RECORD().");
344
("Added entries with macros, tested for existence with macros.");
349
* ------------------------------------ -o-
351
OUTPUT("Dump the list and then sleep.");
353
#ifdef SNMP_TESTING_CODE
357
fprintf(stdout, "\nSleeping for %d second%s... ",
358
sleeptime, (sleeptime == 1) ? "" : "s");
362
fprintf(stdout, "\n");
367
* ------------------------------------ -o-
370
("Retrieve data from real/stubbed records, update real/stubbed.");
374
rval = get_enginetime("BB", 2, &eboot, &etime, TRUE);
375
FAILED(rval, "get_enginetime().");
377
fprintf(stdout, "BB = <%d,%d>\n", eboot, etime);
378
if ((etime < 20) || (eboot < 2)) {
379
FAILED(SNMPERR_GENERR,
380
"get_enginetime() returned bad values. (1)");
383
rval = get_enginetime("DDDD", 4, &eboot, &etime, FALSE);
384
FAILED(rval, "get_enginetime().");
386
fprintf(stdout, "DDDD = <%d,%d>\n", eboot, etime);
387
if ((etime < sleeptime) || (eboot != 0)) {
388
FAILED(SNMPERR_GENERR,
389
"get_enginetime() returned bad values. (2)");
393
rval = set_enginetime("CCC", 3, 234, 10000, TRUE);
394
FAILED(rval, "set_enginetime().");
397
rval = set_enginetime("EEEEE", 5, 9876, 55555, TRUE);
398
FAILED(rval, "set_enginetime().");
401
SUCCESS("Retrieval and updates.");
406
* ------------------------------------ -o-
408
OUTPUT("Sleep again, then dump the list one last time.");
410
fprintf(stdout, "Sleeping for %d second%s... ",
411
sleeptime, (sleeptime == 1) ? "" : "s");
415
fprintf(stdout, "\n");
417
#ifdef SNMP_TESTING_CODE
423
} /* end test_etime() */