ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/src/trunk/lib/libc/db/test/hash.tests/tverify.c
Revision: 10622
Committed: Sat Jun 9 16:18:54 2018 UTC (5 years, 10 months ago) by laffer1
Content type: text/plain
File size: 3434 byte(s)
Log Message:
tag ests

File Contents

# Content
1 /* $MidnightBSD$ */
2 /*-
3 * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Margo Seltzer.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34 #ifndef lint
35 static char copyright[] =
36 "@(#) Copyright (c) 1991, 1993\n\
37 The Regents of the University of California. All rights reserved.\n";
38 #endif /* not lint */
39
40 #if defined(LIBC_SCCS) && !defined(lint)
41 static char sccsid[] = "@(#)tverify.c 8.1 (Berkeley) 6/4/93";
42 #endif /* LIBC_SCCS and not lint */
43 #include <sys/cdefs.h>
44 __FBSDID("$FreeBSD: stable/10/lib/libc/db/test/hash.tests/tverify.c 165903 2007-01-09 00:28:16Z imp $");
45
46 #include <sys/types.h>
47 #include <sys/file.h>
48 #include <stdio.h>
49 #include <db.h>
50
51 #define INITIAL 25000
52 #define MAXWORDS 25000 /* # of elements in search table */
53
54 typedef struct { /* info to be stored */
55 int num, siz;
56 } info;
57
58 char wp1[8192];
59 char wp2[8192];
60 main(argc, argv)
61 char **argv;
62 {
63 DBT key, res;
64 DB *dbp;
65 HASHINFO ctl;
66 int trash;
67 int stat;
68
69 int i = 0;
70
71 ctl.nelem = INITIAL;
72 ctl.hash = NULL;
73 ctl.bsize = 64;
74 ctl.ffactor = 1;
75 ctl.cachesize = 1024 * 1024; /* 1 MEG */
76 ctl.lorder = 0;
77 if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) {
78 /* create table */
79 fprintf(stderr, "cannot open: hash table\n" );
80 exit(1);
81 }
82
83 key.data = wp1;
84 while ( fgets(wp1, 8192, stdin) &&
85 fgets(wp2, 8192, stdin) &&
86 i++ < MAXWORDS) {
87 /*
88 * put info in structure, and structure in the item
89 */
90 key.size = strlen(wp1);
91
92 stat = (dbp->get)(dbp, &key, &res,0);
93 if (stat < 0) {
94 fprintf ( stderr, "Error retrieving %s\n", key.data );
95 exit(1);
96 } else if ( stat > 0 ) {
97 fprintf ( stderr, "%s not found\n", key.data );
98 exit(1);
99 }
100 if ( memcmp ( res.data, wp2, res.size ) ) {
101 fprintf ( stderr, "data for %s is incorrect. Data was %s. Should have been %s\n", key.data, res.data, wp2 );
102 }
103 }
104 (dbp->close)(dbp);
105 exit(0);
106 }

Properties

Name Value
svn:keywords MidnightBSD=%H