xref: /minix3/tests/lib/libc/db/t_db_hash_seq.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: t_db_hash_seq.c,v 1.2 2015/06/22 22:35:51 christos Exp $	*/
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc /*-
4*0a6a1f1dSLionel Sambuc  * Copyright (c) 2015 The NetBSD Foundation, Inc.
5*0a6a1f1dSLionel Sambuc  * All rights reserved.
6*0a6a1f1dSLionel Sambuc  *
7*0a6a1f1dSLionel Sambuc  * This code is derived from software contributed to The NetBSD Foundation
8*0a6a1f1dSLionel Sambuc  * by Christos Zoulas.
9*0a6a1f1dSLionel Sambuc  *
10*0a6a1f1dSLionel Sambuc  * Redistribution and use in source and binary forms, with or without
11*0a6a1f1dSLionel Sambuc  * modification, are permitted provided that the following conditions
12*0a6a1f1dSLionel Sambuc  * are met:
13*0a6a1f1dSLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
14*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
15*0a6a1f1dSLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
16*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
17*0a6a1f1dSLionel Sambuc  *    documentation and/or other materials provided with the distribution.
18*0a6a1f1dSLionel Sambuc  *
19*0a6a1f1dSLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*0a6a1f1dSLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*0a6a1f1dSLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*0a6a1f1dSLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*0a6a1f1dSLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*0a6a1f1dSLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*0a6a1f1dSLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*0a6a1f1dSLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*0a6a1f1dSLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*0a6a1f1dSLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*0a6a1f1dSLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
30*0a6a1f1dSLionel Sambuc  */
31*0a6a1f1dSLionel Sambuc #include <sys/cdefs.h>
32*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: t_db_hash_seq.c,v 1.2 2015/06/22 22:35:51 christos Exp $");
33*0a6a1f1dSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc #include <sys/types.h>
35*0a6a1f1dSLionel Sambuc #include <sys/socket.h>
36*0a6a1f1dSLionel Sambuc #include <db.h>
37*0a6a1f1dSLionel Sambuc #include <stdio.h>
38*0a6a1f1dSLionel Sambuc #include <string.h>
39*0a6a1f1dSLionel Sambuc #include <errno.h>
40*0a6a1f1dSLionel Sambuc #include <stdlib.h>
41*0a6a1f1dSLionel Sambuc #include <fcntl.h>
42*0a6a1f1dSLionel Sambuc #include <syslog.h>
43*0a6a1f1dSLionel Sambuc #include <netinet/in.h>
44*0a6a1f1dSLionel Sambuc 
45*0a6a1f1dSLionel Sambuc #define ATF
46*0a6a1f1dSLionel Sambuc 
47*0a6a1f1dSLionel Sambuc struct conf {
48*0a6a1f1dSLionel Sambuc 	struct sockaddr_storage	c_ss;
49*0a6a1f1dSLionel Sambuc 	int			c_lmask;
50*0a6a1f1dSLionel Sambuc 	int			c_port;
51*0a6a1f1dSLionel Sambuc 	int			c_proto;
52*0a6a1f1dSLionel Sambuc 	int			c_family;
53*0a6a1f1dSLionel Sambuc 	int			c_uid;
54*0a6a1f1dSLionel Sambuc 	int			c_nfail;
55*0a6a1f1dSLionel Sambuc 	char			c_name[128];
56*0a6a1f1dSLionel Sambuc 	int			c_rmask;
57*0a6a1f1dSLionel Sambuc 	int			c_duration;
58*0a6a1f1dSLionel Sambuc };
59*0a6a1f1dSLionel Sambuc 
60*0a6a1f1dSLionel Sambuc struct dbinfo {
61*0a6a1f1dSLionel Sambuc 	int count;
62*0a6a1f1dSLionel Sambuc 	time_t last;
63*0a6a1f1dSLionel Sambuc 	char id[64];
64*0a6a1f1dSLionel Sambuc };
65*0a6a1f1dSLionel Sambuc 
66*0a6a1f1dSLionel Sambuc #ifdef ATF
67*0a6a1f1dSLionel Sambuc #include <atf-c.h>
68*0a6a1f1dSLionel Sambuc 
69*0a6a1f1dSLionel Sambuc #define DO_ERR(msg, ...)	ATF_REQUIRE_MSG(0, msg, __VA_ARGS__)
70*0a6a1f1dSLionel Sambuc #define DO_WARNX(msg, ...)	ATF_REQUIRE_MSG(0, msg, __VA_ARGS__)
71*0a6a1f1dSLionel Sambuc #else
72*0a6a1f1dSLionel Sambuc #include <err.h>
73*0a6a1f1dSLionel Sambuc 
74*0a6a1f1dSLionel Sambuc #define DO_ERR(fmt, ...)	err(EXIT_FAILURE, fmt, __VA_ARGS__)
75*0a6a1f1dSLionel Sambuc #define DO_WARNX(fmt, ...)	warnx(fmt, __VA_ARGS__)
76*0a6a1f1dSLionel Sambuc #endif
77*0a6a1f1dSLionel Sambuc 
78*0a6a1f1dSLionel Sambuc #define DO_DEBUG(fmt, ...)	fprintf(stderr, fmt, __VA_ARGS__)
79*0a6a1f1dSLionel Sambuc 
80*0a6a1f1dSLionel Sambuc static HASHINFO openinfo = {
81*0a6a1f1dSLionel Sambuc 	4096,		/* bsize */
82*0a6a1f1dSLionel Sambuc 	32,		/* ffactor */
83*0a6a1f1dSLionel Sambuc 	256,		/* nelem */
84*0a6a1f1dSLionel Sambuc 	8 * 1024 * 1024,/* cachesize */
85*0a6a1f1dSLionel Sambuc 	NULL,		/* hash() */
86*0a6a1f1dSLionel Sambuc 	0		/* lorder */
87*0a6a1f1dSLionel Sambuc };
88*0a6a1f1dSLionel Sambuc 
89*0a6a1f1dSLionel Sambuc static int debug = 0;
90*0a6a1f1dSLionel Sambuc 
91*0a6a1f1dSLionel Sambuc static int
state_close(DB * db)92*0a6a1f1dSLionel Sambuc state_close(DB *db)
93*0a6a1f1dSLionel Sambuc {
94*0a6a1f1dSLionel Sambuc 	if (db == NULL)
95*0a6a1f1dSLionel Sambuc 		return -1;
96*0a6a1f1dSLionel Sambuc 	if ((*db->close)(db) == -1)
97*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: can't close db", __func__);
98*0a6a1f1dSLionel Sambuc 	return 0;
99*0a6a1f1dSLionel Sambuc }
100*0a6a1f1dSLionel Sambuc 
101*0a6a1f1dSLionel Sambuc static DB *
state_open(const char * dbname,int flags,mode_t perm)102*0a6a1f1dSLionel Sambuc state_open(const char *dbname, int flags, mode_t perm)
103*0a6a1f1dSLionel Sambuc {
104*0a6a1f1dSLionel Sambuc 	DB *db;
105*0a6a1f1dSLionel Sambuc 
106*0a6a1f1dSLionel Sambuc 	db = dbopen(dbname, flags, perm, DB_HASH, &openinfo);
107*0a6a1f1dSLionel Sambuc 	if (db == NULL) {
108*0a6a1f1dSLionel Sambuc 		if (errno == ENOENT && (flags & O_CREAT) == 0)
109*0a6a1f1dSLionel Sambuc 			return NULL;
110*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: can't open `%s'", __func__, dbname);
111*0a6a1f1dSLionel Sambuc 	}
112*0a6a1f1dSLionel Sambuc 	return db;
113*0a6a1f1dSLionel Sambuc }
114*0a6a1f1dSLionel Sambuc 
115*0a6a1f1dSLionel Sambuc static int
state_sizecheck(const DBT * t)116*0a6a1f1dSLionel Sambuc state_sizecheck(const DBT *t)
117*0a6a1f1dSLionel Sambuc {
118*0a6a1f1dSLionel Sambuc 	if (sizeof(struct conf) == t->size)
119*0a6a1f1dSLionel Sambuc 		return 0;
120*0a6a1f1dSLionel Sambuc 	DO_WARNX("Key size mismatch %zu != %zu", sizeof(struct conf), t->size);
121*0a6a1f1dSLionel Sambuc 	return 0;
122*0a6a1f1dSLionel Sambuc }
123*0a6a1f1dSLionel Sambuc 
124*0a6a1f1dSLionel Sambuc static int
state_del(DB * db,const struct conf * c)125*0a6a1f1dSLionel Sambuc state_del(DB *db, const struct conf *c)
126*0a6a1f1dSLionel Sambuc {
127*0a6a1f1dSLionel Sambuc 	int rv;
128*0a6a1f1dSLionel Sambuc 	DBT k;
129*0a6a1f1dSLionel Sambuc 
130*0a6a1f1dSLionel Sambuc 	if (db == NULL)
131*0a6a1f1dSLionel Sambuc 		return -1;
132*0a6a1f1dSLionel Sambuc 
133*0a6a1f1dSLionel Sambuc 	k.data = __UNCONST(c);
134*0a6a1f1dSLionel Sambuc 	k.size = sizeof(*c);
135*0a6a1f1dSLionel Sambuc 
136*0a6a1f1dSLionel Sambuc 	switch (rv = (*db->del)(db, &k, 1)) {
137*0a6a1f1dSLionel Sambuc 	case 0:
138*0a6a1f1dSLionel Sambuc 	case 1:
139*0a6a1f1dSLionel Sambuc 		if (debug > 1) {
140*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%s: returns %d", __func__, rv);
141*0a6a1f1dSLionel Sambuc 			(*db->sync)(db, 0);
142*0a6a1f1dSLionel Sambuc 		}
143*0a6a1f1dSLionel Sambuc 		return 0;
144*0a6a1f1dSLionel Sambuc 	default:
145*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: failed", __func__);
146*0a6a1f1dSLionel Sambuc 		return -1;
147*0a6a1f1dSLionel Sambuc 	}
148*0a6a1f1dSLionel Sambuc }
149*0a6a1f1dSLionel Sambuc 
150*0a6a1f1dSLionel Sambuc #if 0
151*0a6a1f1dSLionel Sambuc static int
152*0a6a1f1dSLionel Sambuc state_get(DB *db, const struct conf *c, struct dbinfo *dbi)
153*0a6a1f1dSLionel Sambuc {
154*0a6a1f1dSLionel Sambuc 	int rv;
155*0a6a1f1dSLionel Sambuc 	DBT k, v;
156*0a6a1f1dSLionel Sambuc 
157*0a6a1f1dSLionel Sambuc 	if (db == NULL)
158*0a6a1f1dSLionel Sambuc 		return -1;
159*0a6a1f1dSLionel Sambuc 
160*0a6a1f1dSLionel Sambuc 	k.data = __UNCONST(c);
161*0a6a1f1dSLionel Sambuc 	k.size = sizeof(*c);
162*0a6a1f1dSLionel Sambuc 
163*0a6a1f1dSLionel Sambuc 	switch (rv = (*db->get)(db, &k, &v, 0)) {
164*0a6a1f1dSLionel Sambuc 	case 0:
165*0a6a1f1dSLionel Sambuc 	case 1:
166*0a6a1f1dSLionel Sambuc 		if (rv)
167*0a6a1f1dSLionel Sambuc 			memset(dbi, 0, sizeof(*dbi));
168*0a6a1f1dSLionel Sambuc 		else
169*0a6a1f1dSLionel Sambuc 			memcpy(dbi, v.data, sizeof(*dbi));
170*0a6a1f1dSLionel Sambuc 		if (debug > 1)
171*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%s: returns %d", __func__, rv);
172*0a6a1f1dSLionel Sambuc 		return 0;
173*0a6a1f1dSLionel Sambuc 	default:
174*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: failed", __func__);
175*0a6a1f1dSLionel Sambuc 		return -1;
176*0a6a1f1dSLionel Sambuc 	}
177*0a6a1f1dSLionel Sambuc }
178*0a6a1f1dSLionel Sambuc #endif
179*0a6a1f1dSLionel Sambuc 
180*0a6a1f1dSLionel Sambuc static int
state_put(DB * db,const struct conf * c,const struct dbinfo * dbi)181*0a6a1f1dSLionel Sambuc state_put(DB *db, const struct conf *c, const struct dbinfo *dbi)
182*0a6a1f1dSLionel Sambuc {
183*0a6a1f1dSLionel Sambuc 	int rv;
184*0a6a1f1dSLionel Sambuc 	DBT k, v;
185*0a6a1f1dSLionel Sambuc 
186*0a6a1f1dSLionel Sambuc 	if (db == NULL)
187*0a6a1f1dSLionel Sambuc 		return -1;
188*0a6a1f1dSLionel Sambuc 
189*0a6a1f1dSLionel Sambuc 	k.data = __UNCONST(c);
190*0a6a1f1dSLionel Sambuc 	k.size = sizeof(*c);
191*0a6a1f1dSLionel Sambuc 	v.data = __UNCONST(dbi);
192*0a6a1f1dSLionel Sambuc 	v.size = sizeof(*dbi);
193*0a6a1f1dSLionel Sambuc 
194*0a6a1f1dSLionel Sambuc 	switch (rv = (*db->put)(db, &k, &v, 0)) {
195*0a6a1f1dSLionel Sambuc 	case 0:
196*0a6a1f1dSLionel Sambuc 		if (debug > 1) {
197*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%s: returns %d", __func__, rv);
198*0a6a1f1dSLionel Sambuc 			(*db->sync)(db, 0);
199*0a6a1f1dSLionel Sambuc 		}
200*0a6a1f1dSLionel Sambuc 		return 0;
201*0a6a1f1dSLionel Sambuc 	case 1:
202*0a6a1f1dSLionel Sambuc 		errno = EEXIST;
203*0a6a1f1dSLionel Sambuc 		/*FALLTHROUGH*/
204*0a6a1f1dSLionel Sambuc 	default:
205*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: failed", __func__);
206*0a6a1f1dSLionel Sambuc 	}
207*0a6a1f1dSLionel Sambuc }
208*0a6a1f1dSLionel Sambuc 
209*0a6a1f1dSLionel Sambuc static int
state_iterate(DB * db,struct conf * c,struct dbinfo * dbi,unsigned int first)210*0a6a1f1dSLionel Sambuc state_iterate(DB *db, struct conf *c, struct dbinfo *dbi, unsigned int first)
211*0a6a1f1dSLionel Sambuc {
212*0a6a1f1dSLionel Sambuc 	int rv;
213*0a6a1f1dSLionel Sambuc 	DBT k, v;
214*0a6a1f1dSLionel Sambuc 
215*0a6a1f1dSLionel Sambuc 	if (db == NULL)
216*0a6a1f1dSLionel Sambuc 		return -1;
217*0a6a1f1dSLionel Sambuc 
218*0a6a1f1dSLionel Sambuc 	first = first ? R_FIRST : R_NEXT;
219*0a6a1f1dSLionel Sambuc 
220*0a6a1f1dSLionel Sambuc 	switch (rv = (*db->seq)(db, &k, &v, first)) {
221*0a6a1f1dSLionel Sambuc 	case 0:
222*0a6a1f1dSLionel Sambuc 		if (state_sizecheck(&k) == -1)
223*0a6a1f1dSLionel Sambuc 			return -1;
224*0a6a1f1dSLionel Sambuc 		memcpy(c, k.data, sizeof(*c));
225*0a6a1f1dSLionel Sambuc 		memcpy(dbi, v.data, sizeof(*dbi));
226*0a6a1f1dSLionel Sambuc 		if (debug > 1)
227*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%s: returns %d", __func__, rv);
228*0a6a1f1dSLionel Sambuc 		return 1;
229*0a6a1f1dSLionel Sambuc 	case 1:
230*0a6a1f1dSLionel Sambuc 		if (debug > 1)
231*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%s: returns %d", __func__, rv);
232*0a6a1f1dSLionel Sambuc 		return 0;
233*0a6a1f1dSLionel Sambuc 	default:
234*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: failed", __func__);
235*0a6a1f1dSLionel Sambuc 		return -1;
236*0a6a1f1dSLionel Sambuc 	}
237*0a6a1f1dSLionel Sambuc }
238*0a6a1f1dSLionel Sambuc 
239*0a6a1f1dSLionel Sambuc #define MAXB 100
240*0a6a1f1dSLionel Sambuc 
241*0a6a1f1dSLionel Sambuc static int
testdb(int skip)242*0a6a1f1dSLionel Sambuc testdb(int skip)
243*0a6a1f1dSLionel Sambuc {
244*0a6a1f1dSLionel Sambuc 	size_t i;
245*0a6a1f1dSLionel Sambuc 	int f;
246*0a6a1f1dSLionel Sambuc 	char flag[MAXB];
247*0a6a1f1dSLionel Sambuc 	DB *db;
248*0a6a1f1dSLionel Sambuc 	struct conf c;
249*0a6a1f1dSLionel Sambuc 	struct dbinfo d;
250*0a6a1f1dSLionel Sambuc 
251*0a6a1f1dSLionel Sambuc 	db = state_open(NULL, O_RDWR|O_CREAT|O_TRUNC, 0600);
252*0a6a1f1dSLionel Sambuc 	if (db == NULL)
253*0a6a1f1dSLionel Sambuc 		DO_ERR("%s: cannot open `%s'", __func__, "foo");
254*0a6a1f1dSLionel Sambuc 
255*0a6a1f1dSLionel Sambuc 	memset(&c, 0, sizeof(c));
256*0a6a1f1dSLionel Sambuc 	memset(&d, 0, sizeof(d));
257*0a6a1f1dSLionel Sambuc 	memset(flag, 0, sizeof(flag));
258*0a6a1f1dSLionel Sambuc 
259*0a6a1f1dSLionel Sambuc 	for (i = 0; i < __arraycount(flag); i++) {
260*0a6a1f1dSLionel Sambuc 		c.c_port = i;
261*0a6a1f1dSLionel Sambuc 		state_put(db, &c, &d);
262*0a6a1f1dSLionel Sambuc 	}
263*0a6a1f1dSLionel Sambuc 
264*0a6a1f1dSLionel Sambuc 	for (f = 1, i = 0; state_iterate(db, &c, &d, f) == 1; f = 0, i++) {
265*0a6a1f1dSLionel Sambuc 		if (debug > 1)
266*0a6a1f1dSLionel Sambuc 			DO_DEBUG("%zu %d\n", i, c.c_port);
267*0a6a1f1dSLionel Sambuc 		if (flag[c.c_port])
268*0a6a1f1dSLionel Sambuc 			DO_WARNX("Already visited %d", c.c_port);
269*0a6a1f1dSLionel Sambuc 		flag[c.c_port] = 1;
270*0a6a1f1dSLionel Sambuc 		if (skip == 0 || c.c_port % skip != 0)
271*0a6a1f1dSLionel Sambuc 			continue;
272*0a6a1f1dSLionel Sambuc 		state_del(db, &c);
273*0a6a1f1dSLionel Sambuc 	}
274*0a6a1f1dSLionel Sambuc 	state_close(db);
275*0a6a1f1dSLionel Sambuc 	for (i = 0; i < __arraycount(flag); i++) {
276*0a6a1f1dSLionel Sambuc 		if (flag[i] == 0)
277*0a6a1f1dSLionel Sambuc 			DO_WARNX("Not visited %zu", i);
278*0a6a1f1dSLionel Sambuc 	}
279*0a6a1f1dSLionel Sambuc 	return 0;
280*0a6a1f1dSLionel Sambuc }
281*0a6a1f1dSLionel Sambuc 
282*0a6a1f1dSLionel Sambuc #ifndef ATF
283*0a6a1f1dSLionel Sambuc int
main(int argc,char * argv[])284*0a6a1f1dSLionel Sambuc main(int argc, char *argv[])
285*0a6a1f1dSLionel Sambuc {
286*0a6a1f1dSLionel Sambuc 	return testdb(6);
287*0a6a1f1dSLionel Sambuc }
288*0a6a1f1dSLionel Sambuc #else
289*0a6a1f1dSLionel Sambuc 
290*0a6a1f1dSLionel Sambuc ATF_TC(test_hash_del_none);
ATF_TC_HEAD(test_hash_del_none,tc)291*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(test_hash_del_none, tc)
292*0a6a1f1dSLionel Sambuc {
293*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting none");
294*0a6a1f1dSLionel Sambuc }
295*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(test_hash_del_none,tc)296*0a6a1f1dSLionel Sambuc ATF_TC_BODY(test_hash_del_none, tc)
297*0a6a1f1dSLionel Sambuc {
298*0a6a1f1dSLionel Sambuc 	testdb(0);
299*0a6a1f1dSLionel Sambuc }
300*0a6a1f1dSLionel Sambuc 
301*0a6a1f1dSLionel Sambuc ATF_TC(test_hash_del_all);
ATF_TC_HEAD(test_hash_del_all,tc)302*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(test_hash_del_all, tc)
303*0a6a1f1dSLionel Sambuc {
304*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting all");
305*0a6a1f1dSLionel Sambuc }
306*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(test_hash_del_all,tc)307*0a6a1f1dSLionel Sambuc ATF_TC_BODY(test_hash_del_all, tc)
308*0a6a1f1dSLionel Sambuc {
309*0a6a1f1dSLionel Sambuc 	testdb(1);
310*0a6a1f1dSLionel Sambuc }
311*0a6a1f1dSLionel Sambuc 
312*0a6a1f1dSLionel Sambuc ATF_TC(test_hash_del_alt);
ATF_TC_HEAD(test_hash_del_alt,tc)313*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(test_hash_del_alt, tc)
314*0a6a1f1dSLionel Sambuc {
315*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables alternating deletets");
316*0a6a1f1dSLionel Sambuc }
317*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(test_hash_del_alt,tc)318*0a6a1f1dSLionel Sambuc ATF_TC_BODY(test_hash_del_alt, tc)
319*0a6a1f1dSLionel Sambuc {
320*0a6a1f1dSLionel Sambuc 	testdb(2);
321*0a6a1f1dSLionel Sambuc }
322*0a6a1f1dSLionel Sambuc 
323*0a6a1f1dSLionel Sambuc ATF_TC(test_hash_del_every_7);
ATF_TC_HEAD(test_hash_del_every_7,tc)324*0a6a1f1dSLionel Sambuc ATF_TC_HEAD(test_hash_del_every_7, tc)
325*0a6a1f1dSLionel Sambuc {
326*0a6a1f1dSLionel Sambuc 	atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting every 7 elements");
327*0a6a1f1dSLionel Sambuc }
328*0a6a1f1dSLionel Sambuc 
ATF_TC_BODY(test_hash_del_every_7,tc)329*0a6a1f1dSLionel Sambuc ATF_TC_BODY(test_hash_del_every_7, tc)
330*0a6a1f1dSLionel Sambuc {
331*0a6a1f1dSLionel Sambuc 	testdb(7);
332*0a6a1f1dSLionel Sambuc }
333*0a6a1f1dSLionel Sambuc 
ATF_TP_ADD_TCS(tp)334*0a6a1f1dSLionel Sambuc ATF_TP_ADD_TCS(tp)
335*0a6a1f1dSLionel Sambuc {
336*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, test_hash_del_none);
337*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, test_hash_del_all);
338*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, test_hash_del_alt);
339*0a6a1f1dSLionel Sambuc 	ATF_TP_ADD_TC(tp, test_hash_del_every_7);
340*0a6a1f1dSLionel Sambuc 
341*0a6a1f1dSLionel Sambuc 	return 0;
342*0a6a1f1dSLionel Sambuc }
343*0a6a1f1dSLionel Sambuc #endif
344