summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/db')
-rw-r--r--src/regress/lib/libc/db/Makefile22
-rw-r--r--src/regress/lib/libc/db/README69
-rw-r--r--src/regress/lib/libc/db/dbtest.c733
-rw-r--r--src/regress/lib/libc/db/run.test707
4 files changed, 0 insertions, 1531 deletions
diff --git a/src/regress/lib/libc/db/Makefile b/src/regress/lib/libc/db/Makefile
deleted file mode 100644
index 7d2882594d..0000000000
--- a/src/regress/lib/libc/db/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# $OpenBSD: Makefile,v 1.10 2002/09/02 20:01:43 avsm Exp $
2# $NetBSD: Makefile,v 1.11 1995/12/12 01:54:15 cgd Exp $
3
4PROG= dbtest
5
6# add -DSTATISTICS to CFLAGS to get usage statistics. Note that
7# for this to work, libc must be compiled with -DSTATISTICS as well
8CFLAGS+= -g -D__DBINTERFACE_PRIVATE -DDEBUG
9CLEANFILES+= t1 t2 t3 log
10
11DBTARGETS=1 2 3 4 5 6 7 8 9 10 11 12 13 20
12
13.for DT in ${DBTARGETS}
14db-${DT}: ${PROG}
15 sh ${.CURDIR}/run.test ${DT}
16REGRESS_TARGETS+=db-${DT}
17.PHONY: db-${DT}
18.endfor
19
20REGRESS_SLOW_TARGETS+=db-3 db-12 db-20
21
22.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/db/README b/src/regress/lib/libc/db/README
deleted file mode 100644
index 23a1b77221..0000000000
--- a/src/regress/lib/libc/db/README
+++ /dev/null
@@ -1,69 +0,0 @@
1# $OpenBSD: README,v 1.3 2001/01/29 02:05:40 niklas Exp $
2# $NetBSD: README,v 1.5 1996/05/03 21:54:19 cgd Exp $
3# @(#)README 8.8 (Berkeley) 7/31/94
4
5To run the tests, enter "make regress".
6
7Fairly large files (the command files) are built in this directory during
8the test runs, and even larger files (the database files) are created in
9"/var/tmp". If the latter directory doesn't exist, set the environmental
10variable TMPDIR to a directory where the files can be built.
11
12=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
13The script file consists of lines with an initial character which is
14the command for that line, or an initial character indicating a key
15or data entry for a previous command.
16
17Legal command characters are as follows:
18
19c: compare a record
20 + must be followed by [kK][dD]; the data value in the database
21 associated with the specified key is compared to the specified
22 data value.
23e: echo a string
24 + writes out the rest of the line into the output file; if the
25 last character is not a carriage-return, a newline is appended.
26f: set the flags for the next command
27 + no value zero's the flags
28g: do a get command
29 + must be followed by [kK]
30 + writes out the retrieved data DBT.
31o [r]: dump [reverse]
32 + dump the database out, if 'r' is set, in reverse order.
33p: do a put command
34 + must be followed by [kK][dD]
35r: do a del command
36 + must be followed by [kK] unless R_CURSOR flag set.
37S: sync the database
38s: do a seq command
39 + must be followed by [kK] if R_CURSOR flag set.
40 + writes out the retrieved data DBT.
41
42Legal key/data characters are as follows:
43
44D [file]: data file
45 + set the current data value to the contents of the file
46d [data]:
47 + set the current key value to the contents of the line.
48K [file]: key file
49 + set the current key value to the contents of the file
50k [data]:
51 + set the current key value to the contents of the line.
52
53Blank lines, lines with leading white space, and lines with leading
54hash marks (#) are ignored.
55
56Options to dbtest are as follows:
57
58 -d: Set the DB_LOCK flag.
59 -f: Use the file argument as the database file.
60 -i: Use the rest of the argument to set elements in the info
61 structure. If the type is btree, then "-i cachesize=10240"
62 will set BTREEINFO.cachesize to 10240.
63 -o: The rest of the argument is the output file instead of
64 using stdout.
65 -s: Don't delete the database file before opening it, i.e.
66 use the database file from a previous run.
67
68Dbtest requires two arguments, the type of access "hash", "recno"
69or "btree", and the script name or "-" to indicate stdin.
diff --git a/src/regress/lib/libc/db/dbtest.c b/src/regress/lib/libc/db/dbtest.c
deleted file mode 100644
index c28ec0db5e..0000000000
--- a/src/regress/lib/libc/db/dbtest.c
+++ /dev/null
@@ -1,733 +0,0 @@
1/* $OpenBSD: dbtest.c,v 1.12 2009/10/27 23:59:32 deraadt Exp $ */
2/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
3
4/*-
5 * Copyright (c) 1992, 1993, 1994
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <sys/param.h>
34#include <sys/stat.h>
35
36#include <ctype.h>
37#include <errno.h>
38#include <fcntl.h>
39#include <limits.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43#include <stdarg.h>
44#include <unistd.h>
45
46#include <db.h>
47
48enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
49
50void compare(DBT *, DBT *);
51DBTYPE dbtype(char *);
52void dump(DB *, int);
53void dberr(const char *, ...);
54void get(DB *, DBT *);
55void getdata(DB *, DBT *, DBT *);
56void put(DB *, DBT *, DBT *);
57void rem(DB *, DBT *);
58char *sflags(int);
59void synk(DB *);
60void *rfile(char *, size_t *);
61void seq(DB *, DBT *);
62u_int setflags(char *);
63void *setinfo(DBTYPE, char *);
64void usage(void);
65void *xmalloc(char *, size_t);
66
67DBTYPE type; /* Database type. */
68void *infop; /* Iflags. */
69u_long lineno; /* Current line in test script. */
70u_int flags; /* Current DB flags. */
71int ofd = STDOUT_FILENO; /* Standard output fd. */
72
73DB *XXdbp; /* Global for gdb. */
74int XXlineno; /* Fast breakpoint for gdb. */
75
76int
77main(int argc, char *argv[])
78{
79 extern int optind;
80 extern char *optarg;
81 enum S command, state;
82 DB *dbp;
83 DBT data, key, keydata;
84 size_t len;
85 int ch, oflags, sflag;
86 char *fname, *infoarg, *p, *t, buf[8 * 1024];
87
88 infoarg = NULL;
89 fname = NULL;
90 oflags = O_CREAT | O_RDWR;
91 sflag = 0;
92 while ((ch = getopt(argc, argv, "f:i:lo:s")) != -1)
93 switch (ch) {
94 case 'f':
95 fname = optarg;
96 break;
97 case 'i':
98 infoarg = optarg;
99 break;
100 case 'l':
101 oflags |= DB_LOCK;
102 break;
103 case 'o':
104 if ((ofd = open(optarg,
105 O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
106 dberr("%s: %s", optarg, strerror(errno));
107 break;
108 case 's':
109 sflag = 1;
110 break;
111 case '?':
112 default:
113 usage();
114 }
115 argc -= optind;
116 argv += optind;
117
118 if (argc != 2)
119 usage();
120
121 /* Set the type. */
122 type = dbtype(*argv++);
123
124 /* Open the descriptor file. */
125 if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL)
126 dberr("%s: %s", *argv, strerror(errno));
127
128 /* Set up the db structure as necessary. */
129 if (infoarg == NULL)
130 infop = NULL;
131 else
132 for (p = strtok(infoarg, ",\t "); p != NULL;
133 p = strtok(0, ",\t "))
134 if (*p != '\0')
135 infop = setinfo(type, p);
136
137 /*
138 * Open the DB. Delete any preexisting copy, you almost never
139 * want it around, and it often screws up tests.
140 */
141 if (fname == NULL) {
142 p = getenv("TMPDIR");
143 if (p == NULL)
144 p = "/var/tmp";
145 (void)snprintf(buf, sizeof buf, "%s/__dbtest", p);
146 fname = buf;
147 (void)unlink(buf);
148 } else if (!sflag)
149 (void)unlink(fname);
150
151 if ((dbp = dbopen(fname,
152 oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL)
153 dberr("dbopen: %s", strerror(errno));
154 XXdbp = dbp;
155
156 state = COMMAND;
157 for (lineno = 1;
158 (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) {
159 /* Delete the newline, displaying the key/data is easier. */
160 if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL)
161 *t = '\0';
162 if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#')
163 continue;
164
165 /* Convenient gdb break point. */
166 if (XXlineno == lineno)
167 XXlineno = 1;
168 switch (*p) {
169 case 'c': /* compare */
170 if (state != COMMAND)
171 dberr("line %lu: not expecting command",
172 lineno);
173 state = KEY;
174 command = COMPARE;
175 break;
176 case 'e': /* echo */
177 if (state != COMMAND)
178 dberr("line %lu: not expecting command",
179 lineno);
180 /* Don't display the newline, if CR at EOL. */
181 if (p[len - 2] == '\r')
182 --len;
183 if (write(ofd, p + 1, len - 1) != len - 1 ||
184 write(ofd, "\n", 1) != 1)
185 dberr("write: %s", strerror(errno));
186 break;
187 case 'g': /* get */
188 if (state != COMMAND)
189 dberr("line %lu: not expecting command",
190 lineno);
191 state = KEY;
192 command = GET;
193 break;
194 case 'p': /* put */
195 if (state != COMMAND)
196 dberr("line %lu: not expecting command",
197 lineno);
198 state = KEY;
199 command = PUT;
200 break;
201 case 'r': /* remove */
202 if (state != COMMAND)
203 dberr("line %lu: not expecting command",
204 lineno);
205 if (flags == R_CURSOR) {
206 rem(dbp, &key);
207 state = COMMAND;
208 } else {
209 state = KEY;
210 command = REMOVE;
211 }
212 break;
213 case 'S': /* sync */
214 if (state != COMMAND)
215 dberr("line %lu: not expecting command",
216 lineno);
217 synk(dbp);
218 state = COMMAND;
219 break;
220 case 's': /* seq */
221 if (state != COMMAND)
222 dberr("line %lu: not expecting command",
223 lineno);
224 if (flags == R_CURSOR) {
225 state = KEY;
226 command = SEQ;
227 } else
228 seq(dbp, &key);
229 break;
230 case 'f':
231 flags = setflags(p + 1);
232 break;
233 case 'D': /* data file */
234 if (state != DATA)
235 dberr("line %lu: not expecting data", lineno);
236 data.data = rfile(p + 1, &data.size);
237 goto ldata;
238 case 'd': /* data */
239 if (state != DATA)
240 dberr("line %lu: not expecting data", lineno);
241 data.data = xmalloc(p + 1, len - 1);
242 data.size = len - 1;
243ldata: switch (command) {
244 case COMPARE:
245 compare(&keydata, &data);
246 break;
247 case PUT:
248 put(dbp, &key, &data);
249 break;
250 default:
251 dberr("line %lu: command doesn't take data",
252 lineno);
253 }
254 if (type != DB_RECNO)
255 free(key.data);
256 free(data.data);
257 state = COMMAND;
258 break;
259 case 'K': /* key file */
260 if (state != KEY)
261 dberr("line %lu: not expecting a key", lineno);
262 if (type == DB_RECNO)
263 dberr("line %lu: 'K' not available for recno",
264 lineno);
265 key.data = rfile(p + 1, &key.size);
266 goto lkey;
267 case 'k': /* key */
268 if (state != KEY)
269 dberr("line %lu: not expecting a key", lineno);
270 if (type == DB_RECNO) {
271 static recno_t recno;
272 recno = atoi(p + 1);
273 key.data = &recno;
274 key.size = sizeof(recno);
275 } else {
276 key.data = xmalloc(p + 1, len - 1);
277 key.size = len - 1;
278 }
279lkey: switch (command) {
280 case COMPARE:
281 getdata(dbp, &key, &keydata);
282 state = DATA;
283 break;
284 case GET:
285 get(dbp, &key);
286 if (type != DB_RECNO)
287 free(key.data);
288 state = COMMAND;
289 break;
290 case PUT:
291 state = DATA;
292 break;
293 case REMOVE:
294 rem(dbp, &key);
295 if ((type != DB_RECNO) && (flags != R_CURSOR))
296 free(key.data);
297 state = COMMAND;
298 break;
299 case SEQ:
300 seq(dbp, &key);
301 if ((type != DB_RECNO) && (flags != R_CURSOR))
302 free(key.data);
303 state = COMMAND;
304 break;
305 default:
306 dberr("line %lu: command doesn't take a key",
307 lineno);
308 }
309 break;
310 case 'o':
311 dump(dbp, p[1] == 'r');
312 break;
313 default:
314 dberr("line %lu: %s: unknown command character",
315 lineno, p);
316 }
317 }
318#ifdef STATISTICS
319 /*
320 * -l must be used (DB_LOCK must be set) for this to be
321 * used, otherwise a page will be locked and it will fail.
322 */
323 if (type == DB_BTREE && oflags & DB_LOCK)
324 __bt_stat(dbp);
325#endif
326 if (dbp->close(dbp))
327 dberr("db->close: %s", strerror(errno));
328 (void)close(ofd);
329 exit(0);
330}
331
332#define NOOVERWRITE "put failed, would overwrite key\n"
333
334void
335compare(db1, db2)
336 DBT *db1, *db2;
337{
338 register size_t len;
339 register u_char *p1, *p2;
340
341 if (db1->size != db2->size)
342 printf("compare failed: key->data len %lu != data len %lu\n",
343 db1->size, db2->size);
344
345 len = MIN(db1->size, db2->size);
346 for (p1 = db1->data, p2 = db2->data; len--;)
347 if (*p1++ != *p2++) {
348 printf("compare failed at offset %d\n",
349 p1 - (u_char *)db1->data);
350 break;
351 }
352}
353
354void
355get(dbp, kp)
356 DB *dbp;
357 DBT *kp;
358{
359 DBT data;
360
361 switch (dbp->get(dbp, kp, &data, flags)) {
362 case 0:
363 (void)write(ofd, data.data, data.size);
364 if (ofd == STDOUT_FILENO)
365 (void)write(ofd, "\n", 1);
366 break;
367 case -1:
368 dberr("line %lu: get: %s", lineno, strerror(errno));
369 /* NOTREACHED */
370 case 1:
371#define NOSUCHKEY "get failed, no such key\n"
372 if (ofd != STDOUT_FILENO)
373 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
374 else
375 (void)fprintf(stderr, "%d: %.*s: %s",
376 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
377#undef NOSUCHKEY
378 break;
379 }
380}
381
382void
383getdata(dbp, kp, dp)
384 DB *dbp;
385 DBT *kp, *dp;
386{
387 switch (dbp->get(dbp, kp, dp, flags)) {
388 case 0:
389 return;
390 case -1:
391 dberr("line %lu: getdata: %s", lineno, strerror(errno));
392 /* NOTREACHED */
393 case 1:
394 dberr("line %lu: getdata failed, no such key", lineno);
395 /* NOTREACHED */
396 }
397}
398
399void
400put(dbp, kp, dp)
401 DB *dbp;
402 DBT *kp, *dp;
403{
404 switch (dbp->put(dbp, kp, dp, flags)) {
405 case 0:
406 break;
407 case -1:
408 dberr("line %lu: put: %s", lineno, strerror(errno));
409 /* NOTREACHED */
410 case 1:
411 (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1);
412 break;
413 }
414}
415
416void
417rem(dbp, kp)
418 DB *dbp;
419 DBT *kp;
420{
421 switch (dbp->del(dbp, kp, flags)) {
422 case 0:
423 break;
424 case -1:
425 dberr("line %lu: rem: %s", lineno, strerror(errno));
426 /* NOTREACHED */
427 case 1:
428#define NOSUCHKEY "rem failed, no such key\n"
429 if (ofd != STDOUT_FILENO)
430 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
431 else if (flags != R_CURSOR)
432 (void)fprintf(stderr, "%d: %.*s: %s",
433 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
434 else
435 (void)fprintf(stderr,
436 "%d: rem of cursor failed\n", lineno);
437#undef NOSUCHKEY
438 break;
439 }
440}
441
442void
443synk(dbp)
444 DB *dbp;
445{
446 switch (dbp->sync(dbp, flags)) {
447 case 0:
448 break;
449 case -1:
450 dberr("line %lu: synk: %s", lineno, strerror(errno));
451 /* NOTREACHED */
452 }
453}
454
455void
456seq(dbp, kp)
457 DB *dbp;
458 DBT *kp;
459{
460 DBT data;
461
462 switch (dbp->seq(dbp, kp, &data, flags)) {
463 case 0:
464 (void)write(ofd, data.data, data.size);
465 if (ofd == STDOUT_FILENO)
466 (void)write(ofd, "\n", 1);
467 break;
468 case -1:
469 dberr("line %lu: seq: %s", lineno, strerror(errno));
470 /* NOTREACHED */
471 case 1:
472#define NOSUCHKEY "seq failed, no such key\n"
473 if (ofd != STDOUT_FILENO)
474 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
475 else if (flags == R_CURSOR)
476 (void)fprintf(stderr, "%d: %.*s: %s",
477 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
478 else
479 (void)fprintf(stderr,
480 "%d: seq (%s) failed\n", lineno, sflags(flags));
481#undef NOSUCHKEY
482 break;
483 }
484}
485
486void
487dump(dbp, rev)
488 DB *dbp;
489 int rev;
490{
491 DBT key, data;
492 int flags, nflags;
493
494 if (rev) {
495 flags = R_LAST;
496 nflags = R_PREV;
497 } else {
498 flags = R_FIRST;
499 nflags = R_NEXT;
500 }
501 for (;; flags = nflags)
502 switch (dbp->seq(dbp, &key, &data, flags)) {
503 case 0:
504 (void)write(ofd, data.data, data.size);
505 if (ofd == STDOUT_FILENO)
506 (void)write(ofd, "\n", 1);
507 break;
508 case 1:
509 goto done;
510 case -1:
511 dberr("line %lu: (dump) seq: %s",
512 lineno, strerror(errno));
513 /* NOTREACHED */
514 }
515done: return;
516}
517
518u_int
519setflags(s)
520 char *s;
521{
522 char *p;
523
524 for (; isspace(*s); ++s);
525 if (*s == '\n' || *s == '\0')
526 return (0);
527 if ((p = strchr(s, '\n')) != NULL)
528 *p = '\0';
529 if (!strcmp(s, "R_CURSOR")) return (R_CURSOR);
530 if (!strcmp(s, "R_FIRST")) return (R_FIRST);
531 if (!strcmp(s, "R_IAFTER")) return (R_IAFTER);
532 if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE);
533 if (!strcmp(s, "R_LAST")) return (R_LAST);
534 if (!strcmp(s, "R_NEXT")) return (R_NEXT);
535 if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE);
536 if (!strcmp(s, "R_PREV")) return (R_PREV);
537 if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR);
538
539 dberr("line %lu: %s: unknown flag", lineno, s);
540 /* NOTREACHED */
541}
542
543char *
544sflags(flags)
545 int flags;
546{
547 switch (flags) {
548 case R_CURSOR: return ("R_CURSOR");
549 case R_FIRST: return ("R_FIRST");
550 case R_IAFTER: return ("R_IAFTER");
551 case R_IBEFORE: return ("R_IBEFORE");
552 case R_LAST: return ("R_LAST");
553 case R_NEXT: return ("R_NEXT");
554 case R_NOOVERWRITE: return ("R_NOOVERWRITE");
555 case R_PREV: return ("R_PREV");
556 case R_SETCURSOR: return ("R_SETCURSOR");
557 }
558
559 return ("UNKNOWN!");
560}
561
562DBTYPE
563dbtype(s)
564 char *s;
565{
566 if (!strcmp(s, "btree"))
567 return (DB_BTREE);
568 if (!strcmp(s, "hash"))
569 return (DB_HASH);
570 if (!strcmp(s, "recno"))
571 return (DB_RECNO);
572 dberr("%s: unknown type (use btree, hash or recno)", s);
573 /* NOTREACHED */
574}
575
576void *
577setinfo(type, s)
578 DBTYPE type;
579 char *s;
580{
581 static BTREEINFO ib;
582 static HASHINFO ih;
583 static RECNOINFO rh;
584 char *eq;
585
586 if ((eq = strchr(s, '=')) == NULL)
587 dberr("%s: illegal structure set statement", s);
588 *eq++ = '\0';
589 if (!isdigit(*eq))
590 dberr("%s: structure set statement must be a number", s);
591
592 switch (type) {
593 case DB_BTREE:
594 if (!strcmp("flags", s)) {
595 ib.flags = atoi(eq);
596 return (&ib);
597 }
598 if (!strcmp("cachesize", s)) {
599 ib.cachesize = atoi(eq);
600 return (&ib);
601 }
602 if (!strcmp("maxkeypage", s)) {
603 ib.maxkeypage = atoi(eq);
604 return (&ib);
605 }
606 if (!strcmp("minkeypage", s)) {
607 ib.minkeypage = atoi(eq);
608 return (&ib);
609 }
610 if (!strcmp("lorder", s)) {
611 ib.lorder = atoi(eq);
612 return (&ib);
613 }
614 if (!strcmp("psize", s)) {
615 ib.psize = atoi(eq);
616 return (&ib);
617 }
618 break;
619 case DB_HASH:
620 if (!strcmp("bsize", s)) {
621 ih.bsize = atoi(eq);
622 return (&ih);
623 }
624 if (!strcmp("ffactor", s)) {
625 ih.ffactor = atoi(eq);
626 return (&ih);
627 }
628 if (!strcmp("nelem", s)) {
629 ih.nelem = atoi(eq);
630 return (&ih);
631 }
632 if (!strcmp("cachesize", s)) {
633 ih.cachesize = atoi(eq);
634 return (&ih);
635 }
636 if (!strcmp("lorder", s)) {
637 ih.lorder = atoi(eq);
638 return (&ih);
639 }
640 break;
641 case DB_RECNO:
642 if (!strcmp("flags", s)) {
643 rh.flags = atoi(eq);
644 return (&rh);
645 }
646 if (!strcmp("cachesize", s)) {
647 rh.cachesize = atoi(eq);
648 return (&rh);
649 }
650 if (!strcmp("lorder", s)) {
651 rh.lorder = atoi(eq);
652 return (&rh);
653 }
654 if (!strcmp("reclen", s)) {
655 rh.reclen = atoi(eq);
656 return (&rh);
657 }
658 if (!strcmp("bval", s)) {
659 rh.bval = atoi(eq);
660 return (&rh);
661 }
662 if (!strcmp("psize", s)) {
663 rh.psize = atoi(eq);
664 return (&rh);
665 }
666 break;
667 }
668 dberr("%s: unknown structure value", s);
669 /* NOTREACHED */
670}
671
672void *
673rfile(name, lenp)
674 char *name;
675 size_t *lenp;
676{
677 struct stat sb;
678 void *p;
679 int fd;
680 char *np;
681
682 for (; isspace(*name); ++name);
683 if ((np = strchr(name, '\n')) != NULL)
684 *np = '\0';
685 if ((fd = open(name, O_RDONLY, 0)) < 0 ||
686 fstat(fd, &sb))
687 dberr("%s: %s\n", name, strerror(errno));
688#ifdef NOT_PORTABLE
689 if (sb.st_size > (off_t)SIZE_T_MAX)
690 dberr("%s: %s\n", name, strerror(E2BIG));
691#endif
692 if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
693 dberr("%s", strerror(errno));
694 (void)read(fd, p, (int)sb.st_size);
695 *lenp = sb.st_size;
696 (void)close(fd);
697 return (p);
698}
699
700void *
701xmalloc(text, len)
702 char *text;
703 size_t len;
704{
705 void *p;
706
707 if ((p = (void *)malloc(len)) == NULL)
708 dberr("%s", strerror(errno));
709 memmove(p, text, len);
710 return (p);
711}
712
713void
714usage()
715{
716 (void)fprintf(stderr,
717 "usage: dbtest [-l] [-f file] [-i info] [-o file] type script\n");
718 exit(1);
719}
720
721void
722dberr(const char *fmt, ...)
723{
724 va_list ap;
725
726 va_start(ap, fmt);
727 (void)fprintf(stderr, "dbtest: ");
728 (void)vfprintf(stderr, fmt, ap);
729 va_end(ap);
730 (void)fprintf(stderr, "\n");
731 exit(1);
732 /* NOTREACHED */
733}
diff --git a/src/regress/lib/libc/db/run.test b/src/regress/lib/libc/db/run.test
deleted file mode 100644
index 0d6837e360..0000000000
--- a/src/regress/lib/libc/db/run.test
+++ /dev/null
@@ -1,707 +0,0 @@
1#!/bin/sh -
2#
3# $OpenBSD: run.test,v 1.3 2001/01/29 02:05:41 niklas Exp $
4# $NetBSD: run.test,v 1.8 1996/05/03 21:57:51 cgd Exp $
5# @(#)run.test 8.10 (Berkeley) 7/26/94
6#
7
8# db regression tests
9main()
10{
11
12 PROG=./dbtest
13 TMP1=t1
14 TMP2=t2
15 TMP3=t3
16
17 if [ -f /usr/share/dict/words ]; then
18 DICT=/usr/share/dict/words
19 elif [ -f /usr/dict/words ]; then
20 DICT=/usr/dict/words
21 else
22 echo 'run.test: no dictionary'
23 exit 1
24 fi
25
26 if [ $# -eq 0 ]; then
27 for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do
28 test$t
29 done
30 else
31 while [ $# -gt 0 ]
32 do case "$1" in
33 test*)
34 $1;;
35 [0-9]*)
36 test$1;;
37 btree)
38 for t in 1 2 3 7 8 9 10 12 13; do
39 test$t
40 done;;
41 hash)
42 for t in 1 2 3 8 13 20; do
43 test$t
44 done;;
45 recno)
46 for t in 1 2 3 4 5 6 7 10 11; do
47 test$t
48 done;;
49 *)
50 echo "run.test: unknown test $1"
51 echo "usage: run.test test# | type"
52 exit 1
53 esac
54 shift
55 done
56 fi
57 rm -f $TMP1 $TMP2 $TMP3
58 exit 0
59}
60
61# Take the first hundred entries in the dictionary, and make them
62# be key/data pairs.
63test1()
64{
65 echo "Test 1: btree, hash: small key, small data pairs"
66 sed 200q $DICT > $TMP1
67 for type in btree hash; do
68 rm -f $TMP2 $TMP3
69 for i in `sed 200q $DICT`; do
70 echo p
71 echo k$i
72 echo d$i
73 echo g
74 echo k$i
75 done > $TMP2
76 $PROG -o $TMP3 $type $TMP2
77 if (cmp -s $TMP1 $TMP3) ; then :
78 else
79 echo "test1: type $type: failed"
80 exit 1
81 fi
82 done
83 echo "Test 1: recno: small key, small data pairs"
84 rm -f $TMP2 $TMP3
85 sed 200q $DICT |
86 awk '{
87 ++i;
88 printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
89 }' > $TMP2
90 $PROG -o $TMP3 recno $TMP2
91 if (cmp -s $TMP1 $TMP3) ; then :
92 else
93 echo "test1: type recno: failed"
94 exit 1
95 fi
96}
97
98# Take the first 200 entries in the dictionary, and give them
99# each a medium size data entry.
100test2()
101{
102 echo "Test 2: btree, hash: small key, medium data pairs"
103 mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
104 echo $mdata |
105 awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1
106 for type in hash btree; do
107 rm -f $TMP2 $TMP3
108 for i in `sed 200q $DICT`; do
109 echo p
110 echo k$i
111 echo d$mdata
112 echo g
113 echo k$i
114 done > $TMP2
115 $PROG -o $TMP3 $type $TMP2
116 if (cmp -s $TMP1 $TMP3) ; then :
117 else
118 echo "test2: type $type: failed"
119 exit 1
120 fi
121 done
122 echo "Test 2: recno: small key, medium data pairs"
123 rm -f $TMP2 $TMP3
124 echo $mdata |
125 awk '{ for (i = 1; i < 201; ++i)
126 printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
127 }' > $TMP2
128 $PROG -o $TMP3 recno $TMP2
129 if (cmp -s $TMP1 $TMP3) ; then :
130 else
131 echo "test2: type recno: failed"
132 exit 1
133 fi
134}
135
136# Insert the programs in /bin with their paths as their keys.
137test3()
138{
139 echo "Test 3: hash: small key, big data pairs"
140 rm -f $TMP1
141 (find /bin -type f -print | xargs cat) > $TMP1
142 for type in hash; do
143 rm -f $TMP2 $TMP3
144 for i in `find /bin -type f -print`; do
145 echo p
146 echo k$i
147 echo D$i
148 echo g
149 echo k$i
150 done > $TMP2
151 $PROG -o $TMP3 $type $TMP2
152 if (cmp -s $TMP1 $TMP3) ; then :
153 else
154 echo "test3: $type: failed"
155 exit 1
156 fi
157 done
158 echo "Test 3: btree: small key, big data pairs"
159 for psize in 512 16384 65536; do
160 echo " page size $psize"
161 for type in btree; do
162 rm -f $TMP2 $TMP3
163 for i in `find /bin -type f -print`; do
164 echo p
165 echo k$i
166 echo D$i
167 echo g
168 echo k$i
169 done > $TMP2
170 $PROG -i psize=$psize -o $TMP3 $type $TMP2
171 if (cmp -s $TMP1 $TMP3) ; then :
172 else
173 echo "test3: $type: page size $psize: failed"
174 exit 1
175 fi
176 done
177 done
178 echo "Test 3: recno: big data pairs"
179 rm -f $TMP2 $TMP3
180 find /bin -type f -print |
181 awk '{
182 ++i;
183 printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i);
184 }' > $TMP2
185 for psize in 512 16384 65536; do
186 echo " page size $psize"
187 $PROG -i psize=$psize -o $TMP3 recno $TMP2
188 if (cmp -s $TMP1 $TMP3) ; then :
189 else
190 echo "test3: recno: page size $psize: failed"
191 exit 1
192 fi
193 done
194}
195
196# Do random recno entries.
197test4()
198{
199 echo "Test 4: recno: random entries"
200 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
201 awk '{
202 for (i = 37; i <= 37 + 88 * 17; i += 17) {
203 if (i % 41)
204 s = substr($0, 1, i % 41);
205 else
206 s = substr($0, 1);
207 printf("input key %d: %s\n", i, s);
208 }
209 for (i = 1; i <= 15; ++i) {
210 if (i % 41)
211 s = substr($0, 1, i % 41);
212 else
213 s = substr($0, 1);
214 printf("input key %d: %s\n", i, s);
215 }
216 for (i = 19234; i <= 19234 + 61 * 27; i += 27) {
217 if (i % 41)
218 s = substr($0, 1, i % 41);
219 else
220 s = substr($0, 1);
221 printf("input key %d: %s\n", i, s);
222 }
223 exit
224 }' > $TMP1
225 rm -f $TMP2 $TMP3
226 cat $TMP1 |
227 awk 'BEGIN {
228 i = 37;
229 incr = 17;
230 }
231 {
232 printf("p\nk%d\nd%s\n", i, $0);
233 if (i == 19234 + 61 * 27)
234 exit;
235 if (i == 37 + 88 * 17) {
236 i = 1;
237 incr = 1;
238 } else if (i == 15) {
239 i = 19234;
240 incr = 27;
241 } else
242 i += incr;
243 }
244 END {
245 for (i = 37; i <= 37 + 88 * 17; i += 17)
246 printf("g\nk%d\n", i);
247 for (i = 1; i <= 15; ++i)
248 printf("g\nk%d\n", i);
249 for (i = 19234; i <= 19234 + 61 * 27; i += 27)
250 printf("g\nk%d\n", i);
251 }' > $TMP2
252 $PROG -o $TMP3 recno $TMP2
253 if (cmp -s $TMP1 $TMP3) ; then :
254 else
255 echo "test4: type recno: failed"
256 exit 1
257 fi
258}
259
260# Do reverse order recno entries.
261test5()
262{
263 echo "Test 5: recno: reverse order entries"
264 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
265 awk ' {
266 for (i = 1500; i; --i) {
267 if (i % 34)
268 s = substr($0, 1, i % 34);
269 else
270 s = substr($0, 1);
271 printf("input key %d: %s\n", i, s);
272 }
273 exit;
274 }' > $TMP1
275 rm -f $TMP2 $TMP3
276 cat $TMP1 |
277 awk 'BEGIN {
278 i = 1500;
279 }
280 {
281 printf("p\nk%d\nd%s\n", i, $0);
282 --i;
283 }
284 END {
285 for (i = 1500; i; --i)
286 printf("g\nk%d\n", i);
287 }' > $TMP2
288 $PROG -o $TMP3 recno $TMP2
289 if (cmp -s $TMP1 $TMP3) ; then :
290 else
291 echo "test5: type recno: failed"
292 exit 1
293 fi
294}
295
296# Do alternating order recno entries.
297test6()
298{
299 echo "Test 6: recno: alternating order entries"
300 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
301 awk ' {
302 for (i = 1; i < 1200; i += 2) {
303 if (i % 34)
304 s = substr($0, 1, i % 34);
305 else
306 s = substr($0, 1);
307 printf("input key %d: %s\n", i, s);
308 }
309 for (i = 2; i < 1200; i += 2) {
310 if (i % 34)
311 s = substr($0, 1, i % 34);
312 else
313 s = substr($0, 1);
314 printf("input key %d: %s\n", i, s);
315 }
316 exit;
317 }' > $TMP1
318 rm -f $TMP2 $TMP3
319 cat $TMP1 |
320 awk 'BEGIN {
321 i = 1;
322 even = 0;
323 }
324 {
325 printf("p\nk%d\nd%s\n", i, $0);
326 i += 2;
327 if (i >= 1200) {
328 if (even == 1)
329 exit;
330 even = 1;
331 i = 2;
332 }
333 }
334 END {
335 for (i = 1; i < 1200; ++i)
336 printf("g\nk%d\n", i);
337 }' > $TMP2
338 $PROG -o $TMP3 recno $TMP2
339 sort -o $TMP1 $TMP1
340 sort -o $TMP3 $TMP3
341 if (cmp -s $TMP1 $TMP3) ; then :
342 else
343 echo "test6: type recno: failed"
344 exit 1
345 fi
346}
347
348# Delete cursor record
349test7()
350{
351 echo "Test 7: btree, recno: delete cursor record"
352 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
353 awk '{
354 for (i = 1; i <= 120; ++i)
355 printf("%05d: input key %d: %s\n", i, i, $0);
356 printf("%05d: input key %d: %s\n", 120, 120, $0);
357 printf("seq failed, no such key\n");
358 printf("%05d: input key %d: %s\n", 1, 1, $0);
359 printf("%05d: input key %d: %s\n", 2, 2, $0);
360 exit;
361 }' > $TMP1
362 rm -f $TMP2 $TMP3
363
364 for type in btree recno; do
365 cat $TMP1 |
366 awk '{
367 if (i == 120)
368 exit;
369 printf("p\nk%d\nd%s\n", ++i, $0);
370 }
371 END {
372 printf("fR_NEXT\n");
373 for (i = 1; i <= 120; ++i)
374 printf("s\n");
375 printf("fR_CURSOR\ns\nk120\n");
376 printf("r\n");
377 printf("fR_NEXT\ns\n");
378 printf("fR_CURSOR\ns\nk1\n");
379 printf("r\n");
380 printf("fR_FIRST\ns\n");
381 }' > $TMP2
382 $PROG -o $TMP3 recno $TMP2
383 if (cmp -s $TMP1 $TMP3) ; then :
384 else
385 echo "test7: type $type: failed"
386 exit 1
387 fi
388 done
389}
390
391# Make sure that overflow pages are reused.
392test8()
393{
394 echo "Test 8: btree, hash: repeated small key, big data pairs"
395 rm -f $TMP1
396 echo "" |
397 awk 'BEGIN {
398 for (i = 1; i <= 10; ++i) {
399 printf("p\nkkey1\nD/bin/sh\n");
400 printf("p\nkkey2\nD/bin/csh\n");
401 if (i % 8 == 0) {
402 printf("c\nkkey2\nD/bin/csh\n");
403 printf("c\nkkey1\nD/bin/sh\n");
404 printf("e\t%d of 10 (comparison)\n", i);
405 } else
406 printf("e\t%d of 10 \n", i);
407 printf("r\nkkey1\nr\nkkey2\n");
408 }
409 }' > $TMP1
410 $PROG btree $TMP1
411# $PROG hash $TMP1
412 # No explicit test for success.
413}
414
415# Test btree duplicate keys
416test9()
417{
418 echo "Test 9: btree: duplicate keys"
419 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
420 awk '{
421 for (i = 1; i <= 543; ++i)
422 printf("%05d: input key %d: %s\n", i, i, $0);
423 exit;
424 }' > $TMP1
425 rm -f $TMP2 $TMP3
426
427 for type in btree; do
428 cat $TMP1 |
429 awk '{
430 if (i++ % 2)
431 printf("p\nkduplicatekey\nd%s\n", $0);
432 else
433 printf("p\nkunique%dkey\nd%s\n", i, $0);
434 }
435 END {
436 printf("o\n");
437 }' > $TMP2
438 $PROG -iflags=1 -o $TMP3 $type $TMP2
439 sort -o $TMP3 $TMP3
440 if (cmp -s $TMP1 $TMP3) ; then :
441 else
442 echo "test9: type $type: failed"
443 exit 1
444 fi
445 done
446}
447
448# Test use of cursor flags without initialization
449test10()
450{
451 echo "Test 10: btree, recno: test cursor flag use"
452 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
453 awk '{
454 for (i = 1; i <= 20; ++i)
455 printf("%05d: input key %d: %s\n", i, i, $0);
456 exit;
457 }' > $TMP1
458 rm -f $TMP2 $TMP3
459
460 # Test that R_CURSOR doesn't succeed before cursor initialized
461 for type in btree recno; do
462 cat $TMP1 |
463 awk '{
464 if (i == 10)
465 exit;
466 printf("p\nk%d\nd%s\n", ++i, $0);
467 }
468 END {
469 printf("fR_CURSOR\nr\n");
470 printf("eR_CURSOR SHOULD HAVE FAILED\n");
471 }' > $TMP2
472 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
473 if [ -s $TMP3 ] ; then
474 echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED"
475 exit 1
476 fi
477 done
478 for type in btree recno; do
479 cat $TMP1 |
480 awk '{
481 if (i == 10)
482 exit;
483 printf("p\nk%d\nd%s\n", ++i, $0);
484 }
485 END {
486 printf("fR_CURSOR\np\nk1\ndsome data\n");
487 printf("eR_CURSOR SHOULD HAVE FAILED\n");
488 }' > $TMP2
489 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
490 if [ -s $TMP3 ] ; then
491 echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED"
492 exit 1
493 fi
494 done
495}
496
497# Test insert in reverse order.
498test11()
499{
500 echo "Test 11: recno: reverse order insert"
501 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
502 awk '{
503 for (i = 1; i <= 779; ++i)
504 printf("%05d: input key %d: %s\n", i, i, $0);
505 exit;
506 }' > $TMP1
507 rm -f $TMP2 $TMP3
508
509 for type in recno; do
510 cat $TMP1 |
511 awk '{
512 if (i == 0) {
513 i = 1;
514 printf("p\nk1\nd%s\n", $0);
515 printf("%s\n", "fR_IBEFORE");
516 } else
517 printf("p\nk1\nd%s\n", $0);
518 }
519 END {
520 printf("or\n");
521 }' > $TMP2
522 $PROG -o $TMP3 $type $TMP2
523 if (cmp -s $TMP1 $TMP3) ; then :
524 else
525 echo "test11: type $type: failed"
526 exit 1
527 fi
528 done
529}
530
531# Take the first 20000 entries in the dictionary, reverse them, and give
532# them each a small size data entry. Use a small page size to make sure
533# the btree split code gets hammered.
534test12()
535{
536 echo "Test 12: btree: lots of keys, small page size"
537 mdata=abcdefghijklmnopqrstuvwxy
538 echo $mdata |
539 awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1
540 for type in btree; do
541 rm -f $TMP2 $TMP3
542 for i in `sed 20000q $DICT | rev`; do
543 echo p
544 echo k$i
545 echo d$mdata
546 echo g
547 echo k$i
548 done > $TMP2
549 $PROG -i psize=512 -o $TMP3 $type $TMP2
550 if (cmp -s $TMP1 $TMP3) ; then :
551 else
552 echo "test12: type $type: failed"
553 exit 1
554 fi
555 done
556}
557
558# Test different byte orders.
559test13()
560{
561 echo "Test 13: btree, hash: differing byte orders"
562 sed 50q $DICT > $TMP1
563 for order in 1234 4321; do
564 for type in btree hash; do
565 rm -f byte.file $TMP2 $TMP3
566 for i in `sed 50q $DICT`; do
567 echo p
568 echo k$i
569 echo d$i
570 echo g
571 echo k$i
572 done > $TMP2
573 $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
574 if (cmp -s $TMP1 $TMP3) ; then :
575 else
576 echo "test13: $type/$order put failed"
577 exit 1
578 fi
579 for i in `sed 50q $DICT`; do
580 echo g
581 echo k$i
582 done > $TMP2
583 $PROG -s \
584 -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
585 if (cmp -s $TMP1 $TMP3) ; then :
586 else
587 echo "test13: $type/$order get failed"
588 exit 1
589 fi
590 done
591 done
592 rm -f byte.file
593}
594
595# Try a variety of bucketsizes and fill factors for hashing
596test20()
597{
598 echo\
599 "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536"
600 echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
601 awk '{
602 for (i = 1; i <= 10000; ++i) {
603 if (i % 34)
604 s = substr($0, 1, i % 34);
605 else
606 s = substr($0, 1);
607 printf("%s\n", s);
608 }
609 exit;
610 }' > $TMP1
611 sed 10000q $DICT |
612 awk 'BEGIN {
613 ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"
614 }
615 {
616 if (++i % 34)
617 s = substr(ds, 1, i % 34);
618 else
619 s = substr(ds, 1);
620 printf("p\nk%s\nd%s\n", $0, s);
621 }' > $TMP2
622 sed 10000q $DICT |
623 awk '{
624 ++i;
625 printf("g\nk%s\n", $0);
626 }' >> $TMP2
627 bsize=256
628 for ffactor in 11 14 21; do
629 echo " bucketsize $bsize, fill factor $ffactor"
630 $PROG -o$TMP3 \
631 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
632 hash $TMP2
633 if (cmp -s $TMP1 $TMP3) ; then :
634 else
635 echo "test20: type hash:\
636bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
637 exit 1
638 fi
639 done
640 bsize=512
641 for ffactor in 21 28 43; do
642 echo " bucketsize $bsize, fill factor $ffactor"
643 $PROG -o$TMP3 \
644 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
645 hash $TMP2
646 if (cmp -s $TMP1 $TMP3) ; then :
647 else
648 echo "test20: type hash:\
649bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
650 exit 1
651 fi
652 done
653 bsize=1024
654 for ffactor in 43 57 85; do
655 echo " bucketsize $bsize, fill factor $ffactor"
656 $PROG -o$TMP3 \
657 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
658 hash $TMP2
659 if (cmp -s $TMP1 $TMP3) ; then :
660 else
661 echo "test20: type hash:\
662bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
663 exit 1
664 fi
665 done
666 bsize=2048
667 for ffactor in 85 114 171; do
668 echo " bucketsize $bsize, fill factor $ffactor"
669 $PROG -o$TMP3 \
670 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
671 hash $TMP2
672 if (cmp -s $TMP1 $TMP3) ; then :
673 else
674 echo "test20: type hash:\
675bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
676 exit 1
677 fi
678 done
679 bsize=4096
680 for ffactor in 171 228 341; do
681 echo " bucketsize $bsize, fill factor $ffactor"
682 $PROG -o$TMP3 \
683 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
684 hash $TMP2
685 if (cmp -s $TMP1 $TMP3) ; then :
686 else
687 echo "test20: type hash:\
688bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
689 exit 1
690 fi
691 done
692 bsize=8192
693 for ffactor in 341 455 683; do
694 echo " bucketsize $bsize, fill factor $ffactor"
695 $PROG -o$TMP3 \
696 -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\
697 hash $TMP2
698 if (cmp -s $TMP1 $TMP3) ; then :
699 else
700 echo "test20: type hash:\
701bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed"
702 exit 1
703 fi
704 done
705}
706
707main $*