xref: /minix/tests/lib/libc/db/t_db.sh (revision 0a6a1f1d)
1# $NetBSD: t_db.sh,v 1.5 2015/02/26 13:00:26 martin Exp $
2#
3# Copyright (c) 2008 The NetBSD Foundation, Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26#
27
28prog()
29{
30	echo $(atf_get_srcdir)/h_db
31}
32
33dict()
34{
35	if [ -f /usr/share/dict/words ]; then
36		echo /usr/share/dict/words
37	elif [ -f /usr/dict/words ]; then
38		echo /usr/dict/words
39	else
40		atf_fail "no dictionary found"
41	fi
42}
43
44SEVEN_SEVEN="abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg"
45
46atf_test_case small_btree
47small_btree_head()
48{
49	atf_set "descr" \
50		"Checks btree database using small keys and small data" \
51		"pairs: takes the first hundred entries in the dictionary," \
52		"and makes them be key/data pairs."
53}
54small_btree_body()
55{
56	TMPDIR="$(pwd)/db_dir"; export TMPDIR
57	mkdir ${TMPDIR}
58
59	sed 200q $(dict) >exp
60
61	for i in `sed 200q $(dict)`; do
62		echo p
63		echo k$i
64		echo d$i
65		echo g
66		echo k$i
67	done >in
68
69	atf_check -o file:exp "$(prog)" btree in
70}
71
72atf_test_case small_hash
73small_hash_head()
74{
75	atf_set "descr" \
76		"Checks hash database using small keys and small data" \
77		"pairs: takes the first hundred entries in the dictionary," \
78		"and makes them be key/data pairs."
79}
80small_hash_body()
81{
82	TMPDIR="$(pwd)/db_dir"; export TMPDIR
83	mkdir ${TMPDIR}
84
85	sed 200q $(dict) >exp
86
87	for i in `sed 200q $(dict)`; do
88		echo p
89		echo k$i
90		echo d$i
91		echo g
92		echo k$i
93	done >in
94
95	atf_check -o file:exp "$(prog)" hash in
96}
97
98atf_test_case small_recno
99small_recno_head()
100{
101	atf_set "descr" \
102		"Checks recno database using small keys and small data" \
103		"pairs: takes the first hundred entries in the dictionary," \
104		"and makes them be key/data pairs."
105}
106small_recno_body()
107{
108	TMPDIR="$(pwd)/db_dir"; export TMPDIR
109	mkdir ${TMPDIR}
110
111	sed 200q $(dict) >exp
112
113	sed 200q $(dict) |
114	awk '{
115		++i;
116		printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
117	}' >in
118
119	atf_check -o file:exp "$(prog)" recno in
120}
121
122atf_test_case medium_btree
123medium_btree_head()
124{
125	atf_set "descr" \
126		"Checks btree database using small keys and medium" \
127		"data pairs: takes the first 200 entries in the" \
128		"dictionary, and gives them each a medium size data entry."
129}
130medium_btree_body()
131{
132	TMPDIR="$(pwd)/db_dir"; export TMPDIR
133	mkdir ${TMPDIR}
134
135	mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
136	echo $mdata |
137	awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp
138
139	for i in $(sed 200q $(dict)); do
140		echo p
141		echo k$i
142		echo d$mdata
143		echo g
144		echo k$i
145	done >in
146
147	atf_check -o file:exp "$(prog)" btree in
148}
149
150atf_test_case medium_hash
151medium_hash_head()
152{
153	atf_set "descr" \
154		"Checks hash database using small keys and medium" \
155		"data pairs: takes the first 200 entries in the" \
156		"dictionary, and gives them each a medium size data entry."
157}
158medium_hash_body()
159{
160	TMPDIR="$(pwd)/db_dir"; export TMPDIR
161	mkdir ${TMPDIR}
162
163	mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
164	echo $mdata |
165	awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp
166
167	for i in $(sed 200q $(dict)); do
168		echo p
169		echo k$i
170		echo d$mdata
171		echo g
172		echo k$i
173	done >in
174
175	atf_check -o file:exp "$(prog)" hash in
176}
177
178atf_test_case medium_recno
179medium_recno_head()
180{
181	atf_set "descr" \
182		"Checks recno database using small keys and medium" \
183		"data pairs: takes the first 200 entries in the" \
184		"dictionary, and gives them each a medium size data entry."
185}
186medium_recno_body()
187{
188	TMPDIR="$(pwd)/db_dir"; export TMPDIR
189	mkdir ${TMPDIR}
190
191	mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
192	echo $mdata |
193	awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp
194
195	echo $mdata |
196	awk '{  for (i = 1; i < 201; ++i)
197		printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
198	}' >in
199
200	atf_check -o file:exp "$(prog)" recno in
201}
202
203atf_test_case big_btree
204big_btree_head()
205{
206	atf_set "descr" \
207		"Checks btree database using small keys and big data" \
208		"pairs: inserts the programs in /bin with their paths" \
209		"as their keys."
210}
211big_btree_body()
212{
213	TMPDIR="$(pwd)/db_dir"; export TMPDIR
214	mkdir ${TMPDIR}
215
216	(find /bin -type f -print | xargs cat) >exp
217
218	for psize in 512 16384 65536; do
219		echo "checking page size: $psize"
220
221		for i in `find /bin -type f -print`; do
222			echo p
223			echo k$i
224			echo D$i
225			echo g
226			echo k$i
227		done >in
228
229		atf_check "$(prog)" -o out btree in
230		cmp -s exp out || atf_fail "test failed for page size: $psize"
231	done
232}
233
234atf_test_case big_hash
235big_hash_head()
236{
237	atf_set "descr" \
238		"Checks hash database using small keys and big data" \
239		"pairs: inserts the programs in /bin with their paths" \
240		"as their keys."
241}
242big_hash_body()
243{
244	TMPDIR="$(pwd)/db_dir"; export TMPDIR
245	mkdir ${TMPDIR}
246
247	(find /bin -type f -print | xargs cat) >exp
248
249	for i in `find /bin -type f -print`; do
250		echo p
251		echo k$i
252		echo D$i
253		echo g
254		echo k$i
255	done >in
256
257	atf_check "$(prog)" -o out hash in
258	cmp -s exp out || atf_fail "test failed"
259}
260
261atf_test_case big_recno
262big_recno_head()
263{
264	atf_set "descr" \
265		"Checks recno database using small keys and big data" \
266		"pairs: inserts the programs in /bin with their paths" \
267		"as their keys."
268}
269big_recno_body()
270{
271	TMPDIR="$(pwd)/db_dir"; export TMPDIR
272	mkdir ${TMPDIR}
273
274	(find /bin -type f -print | xargs cat) >exp
275
276	find /bin -type f -print |
277	awk '{
278		++i;
279		printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i);
280	}' >in
281
282	for psize in 512 16384 65536; do
283		echo "checking page size: $psize"
284
285		atf_check "$(prog)" -o out recno in
286		cmp -s exp out || atf_fail "test failed for page size: $psize"
287	done
288}
289
290atf_test_case random_recno
291random_recno_head()
292{
293	atf_set "descr" "Checks recno database using random entries"
294}
295random_recno_body()
296{
297	TMPDIR="$(pwd)/db_dir"; export TMPDIR
298	mkdir ${TMPDIR}
299
300	echo $SEVEN_SEVEN |
301	awk '{
302		for (i = 37; i <= 37 + 88 * 17; i += 17) {
303			if (i % 41)
304				s = substr($0, 1, i % 41);
305			else
306				s = substr($0, 1);
307			printf("input key %d: %s\n", i, s);
308		}
309		for (i = 1; i <= 15; ++i) {
310			if (i % 41)
311				s = substr($0, 1, i % 41);
312			else
313				s = substr($0, 1);
314			printf("input key %d: %s\n", i, s);
315		}
316		for (i = 19234; i <= 19234 + 61 * 27; i += 27) {
317			if (i % 41)
318				s = substr($0, 1, i % 41);
319			else
320				s = substr($0, 1);
321			printf("input key %d: %s\n", i, s);
322		}
323		exit
324	}' >exp
325
326	cat exp |
327	awk 'BEGIN {
328			i = 37;
329			incr = 17;
330		}
331		{
332			printf("p\nk%d\nd%s\n", i, $0);
333			if (i == 19234 + 61 * 27)
334				exit;
335			if (i == 37 + 88 * 17) {
336				i = 1;
337				incr = 1;
338			} else if (i == 15) {
339				i = 19234;
340				incr = 27;
341			} else
342				i += incr;
343		}
344		END {
345			for (i = 37; i <= 37 + 88 * 17; i += 17)
346				printf("g\nk%d\n", i);
347			for (i = 1; i <= 15; ++i)
348				printf("g\nk%d\n", i);
349			for (i = 19234; i <= 19234 + 61 * 27; i += 27)
350				printf("g\nk%d\n", i);
351		}' >in
352
353	atf_check -o file:exp "$(prog)" recno in
354}
355
356atf_test_case reverse_recno
357reverse_recno_head()
358{
359	atf_set "descr" "Checks recno database using reverse order entries"
360}
361reverse_recno_body()
362{
363	TMPDIR="$(pwd)/db_dir"; export TMPDIR
364	mkdir ${TMPDIR}
365
366	echo $SEVEN_SEVEN |
367	awk ' {
368		for (i = 1500; i; --i) {
369			if (i % 34)
370				s = substr($0, 1, i % 34);
371			else
372				s = substr($0, 1);
373			printf("input key %d: %s\n", i, s);
374		}
375		exit;
376	}' >exp
377
378	cat exp |
379	awk 'BEGIN {
380			i = 1500;
381		}
382		{
383			printf("p\nk%d\nd%s\n", i, $0);
384			--i;
385		}
386		END {
387			for (i = 1500; i; --i)
388				printf("g\nk%d\n", i);
389		}' >in
390
391	atf_check -o file:exp "$(prog)" recno in
392}
393
394atf_test_case alternate_recno
395alternate_recno_head()
396{
397	atf_set "descr" "Checks recno database using alternating order entries"
398}
399alternate_recno_body()
400{
401	TMPDIR="$(pwd)/db_dir"; export TMPDIR
402	mkdir ${TMPDIR}
403
404	echo $SEVEN_SEVEN |
405	awk ' {
406		for (i = 1; i < 1200; i += 2) {
407			if (i % 34)
408				s = substr($0, 1, i % 34);
409			else
410				s = substr($0, 1);
411			printf("input key %d: %s\n", i, s);
412		}
413		for (i = 2; i < 1200; i += 2) {
414			if (i % 34)
415				s = substr($0, 1, i % 34);
416			else
417				s = substr($0, 1);
418			printf("input key %d: %s\n", i, s);
419		}
420		exit;
421	}' >exp
422
423	cat exp |
424	awk 'BEGIN {
425			i = 1;
426			even = 0;
427		}
428		{
429			printf("p\nk%d\nd%s\n", i, $0);
430			i += 2;
431			if (i >= 1200) {
432				if (even == 1)
433					exit;
434				even = 1;
435				i = 2;
436			}
437		}
438		END {
439			for (i = 1; i < 1200; ++i)
440				printf("g\nk%d\n", i);
441		}' >in
442
443	atf_check "$(prog)" -o out recno in
444
445	sort -o exp exp
446	sort -o out out
447
448	cmp -s exp out || atf_fail "test failed"
449}
450
451h_delete()
452{
453	TMPDIR="$(pwd)/db_dir"; export TMPDIR
454	mkdir ${TMPDIR}
455
456	type=$1
457
458	echo $SEVEN_SEVEN |
459	awk '{
460		for (i = 1; i <= 120; ++i)
461			printf("%05d: input key %d: %s\n", i, i, $0);
462	}' >exp
463
464	cat exp |
465	awk '{
466		printf("p\nk%d\nd%s\n", ++i, $0);
467	}
468	END {
469		printf("fR_NEXT\n");
470		for (i = 1; i <= 120; ++i)
471			printf("s\n");
472		printf("fR_CURSOR\ns\nkXX\n");
473		printf("r\n");
474		printf("fR_NEXT\ns\n");
475		printf("fR_CURSOR\ns\nk1\n");
476		printf("r\n");
477		printf("fR_FIRST\ns\n");
478	}' >in
479
480	# For btree, the records are ordered by the string representation
481	# of the key value.  So sort the expected output file accordingly,
482	# and set the seek_last key to the last expected key value.
483
484	if [ "$type" = "btree" ] ; then
485		sed -e 's/kXX/k99/' < in > tmp
486		mv tmp in
487		sort -d -k4 < exp > tmp
488		mv tmp exp
489		echo $SEVEN_SEVEN |
490		awk '{
491			printf("%05d: input key %d: %s\n", 99, 99, $0);
492			printf("seq failed, no such key\n");
493			printf("%05d: input key %d: %s\n", 1, 1, $0);
494			printf("%05d: input key %d: %s\n", 10, 10, $0);
495			exit;
496		}' >> exp
497	else
498	# For recno, records are ordered by numerical key value.  No sort
499	# is needed, but still need to set proper seek_last key value.
500		sed -e 's/kXX/k120/' < in > tmp
501		mv tmp in
502		echo $SEVEN_SEVEN |
503		awk '{
504			printf("%05d: input key %d: %s\n", 120, 120, $0);
505			printf("seq failed, no such key\n");
506			printf("%05d: input key %d: %s\n", 1, 1, $0);
507			printf("%05d: input key %d: %s\n", 2, 2, $0);
508			exit;
509		}' >> exp
510	fi
511
512	atf_check "$(prog)" -o out $type in
513	atf_check -o file:exp cat out
514}
515
516atf_test_case delete_btree
517delete_btree_head()
518{
519	atf_set "descr" "Checks removing records in btree database"
520}
521delete_btree_body()
522{
523	h_delete btree
524}
525
526atf_test_case delete_recno
527delete_recno_head()
528{
529	atf_set "descr" "Checks removing records in recno database"
530}
531delete_recno_body()
532{
533	h_delete recno
534}
535
536h_repeated()
537{
538	TMPDIR="$(pwd)/db_dir"; export TMPDIR
539	mkdir ${TMPDIR}
540
541	echo "" |
542	awk 'BEGIN {
543		for (i = 1; i <= 10; ++i) {
544			printf("p\nkkey1\nD/bin/sh\n");
545			printf("p\nkkey2\nD/bin/csh\n");
546			if (i % 8 == 0) {
547				printf("c\nkkey2\nD/bin/csh\n");
548				printf("c\nkkey1\nD/bin/sh\n");
549				printf("e\t%d of 10 (comparison)\n", i);
550			} else
551				printf("e\t%d of 10             \n", i);
552			printf("r\nkkey1\nr\nkkey2\n");
553		}
554	}' >in
555
556	$(prog) btree in
557}
558
559atf_test_case repeated_btree
560repeated_btree_head()
561{
562	atf_set "descr" \
563		"Checks btree database with repeated small keys and" \
564		"big data pairs. Makes sure that overflow pages are reused"
565}
566repeated_btree_body()
567{
568	h_repeated btree
569}
570
571atf_test_case repeated_hash
572repeated_hash_head()
573{
574	atf_set "descr" \
575		"Checks hash database with repeated small keys and" \
576		"big data pairs. Makes sure that overflow pages are reused"
577}
578repeated_hash_body()
579{
580	h_repeated hash
581}
582
583atf_test_case duplicate_btree
584duplicate_btree_head()
585{
586	atf_set "descr" "Checks btree database with duplicate keys"
587}
588duplicate_btree_body()
589{
590	TMPDIR="$(pwd)/db_dir"; export TMPDIR
591	mkdir ${TMPDIR}
592
593	echo $SEVEN_SEVEN |
594	awk '{
595		for (i = 1; i <= 543; ++i)
596			printf("%05d: input key %d: %s\n", i, i, $0);
597		exit;
598	}' >exp
599
600	cat exp |
601	awk '{
602		if (i++ % 2)
603			printf("p\nkduplicatekey\nd%s\n", $0);
604		else
605			printf("p\nkunique%dkey\nd%s\n", i, $0);
606	}
607	END {
608			printf("o\n");
609	}' >in
610
611	atf_check -o file:exp -x "$(prog) -iflags=1 btree in | sort"
612}
613
614h_cursor_flags()
615{
616	TMPDIR="$(pwd)/db_dir"; export TMPDIR
617	mkdir ${TMPDIR}
618
619	type=$1
620
621	echo $SEVEN_SEVEN |
622	awk '{
623		for (i = 1; i <= 20; ++i)
624			printf("%05d: input key %d: %s\n", i, i, $0);
625		exit;
626	}' >exp
627
628	# Test that R_CURSOR doesn't succeed before cursor initialized
629	cat exp |
630	awk '{
631		if (i == 10)
632			exit;
633		printf("p\nk%d\nd%s\n", ++i, $0);
634	}
635	END {
636		printf("fR_CURSOR\nr\n");
637		printf("eR_CURSOR SHOULD HAVE FAILED\n");
638	}' >in
639
640	atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in
641	atf_check -s ne:0 test -s out
642
643	cat exp |
644	awk '{
645		if (i == 10)
646			exit;
647		printf("p\nk%d\nd%s\n", ++i, $0);
648	}
649	END {
650		printf("fR_CURSOR\np\nk1\ndsome data\n");
651		printf("eR_CURSOR SHOULD HAVE FAILED\n");
652	}' >in
653
654	atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in
655	atf_check -s ne:0 test -s out
656}
657
658atf_test_case cursor_flags_btree
659cursor_flags_btree_head()
660{
661	atf_set "descr" \
662		"Checks use of cursor flags without initialization in btree database"
663}
664cursor_flags_btree_body()
665{
666	h_cursor_flags btree
667}
668
669atf_test_case cursor_flags_recno
670cursor_flags_recno_head()
671{
672	atf_set "descr" \
673		"Checks use of cursor flags without initialization in recno database"
674}
675cursor_flags_recno_body()
676{
677	h_cursor_flags recno
678}
679
680atf_test_case reverse_order_recno
681reverse_order_recno_head()
682{
683	atf_set "descr" "Checks reverse order inserts in recno database"
684}
685reverse_order_recno_body()
686{
687	TMPDIR="$(pwd)/db_dir"; export TMPDIR
688	mkdir ${TMPDIR}
689
690	echo $SEVEN_SEVEN |
691	awk '{
692		for (i = 1; i <= 779; ++i)
693			printf("%05d: input key %d: %s\n", i, i, $0);
694		exit;
695	}' >exp
696
697	cat exp |
698	awk '{
699		if (i == 0) {
700			i = 1;
701			printf("p\nk1\nd%s\n", $0);
702			printf("%s\n", "fR_IBEFORE");
703		} else
704			printf("p\nk1\nd%s\n", $0);
705	}
706	END {
707			printf("or\n");
708	}' >in
709
710	atf_check -o file:exp "$(prog)" recno in
711}
712
713atf_test_case small_page_btree
714small_page_btree_head()
715{
716	atf_set "descr" \
717		"Checks btree database with lots of keys and small page" \
718		"size: takes the first 20000 entries in the dictionary," \
719		"reverses them, and gives them each a small size data" \
720		"entry. Uses a small page size to make sure the btree" \
721		"split code gets hammered."
722}
723small_page_btree_body()
724{
725	TMPDIR="$(pwd)/db_dir"; export TMPDIR
726	mkdir ${TMPDIR}
727
728	mdata=abcdefghijklmnopqrstuvwxy
729	echo $mdata |
730	awk '{ for (i = 1; i < 20001; ++i) print $0 }' >exp
731
732	for i in `sed 20000q $(dict) | rev`; do
733		echo p
734		echo k$i
735		echo d$mdata
736		echo g
737		echo k$i
738	done >in
739
740	atf_check -o file:exp "$(prog)" -i psize=512 btree in
741}
742
743h_byte_orders()
744{
745	TMPDIR="$(pwd)/db_dir"; export TMPDIR
746	mkdir ${TMPDIR}
747
748	type=$1
749
750	sed 50q $(dict) >exp
751	for order in 1234 4321; do
752		for i in `sed 50q $(dict)`; do
753			echo p
754			echo k$i
755			echo d$i
756			echo g
757			echo k$i
758		done >in
759
760		atf_check -o file:exp "$(prog)" -ilorder=$order -f byte.file $type in
761
762		for i in `sed 50q $(dict)`; do
763			echo g
764			echo k$i
765		done >in
766
767		atf_check -o file:exp "$(prog)" -s -ilorder=$order -f byte.file $type in
768	done
769}
770
771atf_test_case byte_orders_btree
772byte_orders_btree_head()
773{
774	atf_set "descr" "Checks btree database using differing byte orders"
775}
776byte_orders_btree_body()
777{
778	h_byte_orders btree
779}
780
781atf_test_case byte_orders_hash
782byte_orders_hash_head()
783{
784	atf_set "descr" "Checks hash database using differing byte orders"
785}
786byte_orders_hash_body()
787{
788	h_byte_orders hash
789}
790
791h_bsize_ffactor()
792{
793	bsize=$1
794	ffactor=$2
795
796	echo "bucketsize $bsize, fill factor $ffactor"
797	atf_check -o file:exp "$(prog)" "-ibsize=$bsize,\
798ffactor=$ffactor,nelem=25000,cachesize=65536" hash in
799}
800
801atf_test_case bsize_ffactor
802bsize_ffactor_head()
803{
804	atf_set "timeout" "1800"
805	atf_set "descr" "Checks hash database with various" \
806					"bucketsizes and fill factors"
807}
808bsize_ffactor_body()
809{
810	TMPDIR="$(pwd)/db_dir"; export TMPDIR
811	mkdir ${TMPDIR}
812
813	echo $SEVEN_SEVEN |
814	awk '{
815		for (i = 1; i <= 10000; ++i) {
816			if (i % 34)
817				s = substr($0, 1, i % 34);
818			else
819				s = substr($0, 1);
820			printf("%s\n", s);
821		}
822		exit;
823
824	}' >exp
825
826	sed 10000q $(dict) |
827	awk 'BEGIN {
828		ds="'$SEVEN_SEVEN'"
829	}
830	{
831		if (++i % 34)
832			s = substr(ds, 1, i % 34);
833		else
834			s = substr(ds, 1);
835		printf("p\nk%s\nd%s\n", $0, s);
836	}' >in
837
838	sed 10000q $(dict) |
839	awk '{
840		++i;
841		printf("g\nk%s\n", $0);
842	}' >>in
843
844	h_bsize_ffactor 256 11
845	h_bsize_ffactor 256 14
846	h_bsize_ffactor 256 21
847
848	h_bsize_ffactor 512 21
849	h_bsize_ffactor 512 28
850	h_bsize_ffactor 512 43
851
852	h_bsize_ffactor 1024 43
853	h_bsize_ffactor 1024 57
854	h_bsize_ffactor 1024 85
855
856	h_bsize_ffactor 2048 85
857	h_bsize_ffactor 2048 114
858	h_bsize_ffactor 2048 171
859
860	h_bsize_ffactor 4096 171
861	h_bsize_ffactor 4096 228
862	h_bsize_ffactor 4096 341
863
864	h_bsize_ffactor 8192 341
865	h_bsize_ffactor 8192 455
866	h_bsize_ffactor 8192 683
867}
868
869# FIXME: what does it test?
870atf_test_case four_char_hash
871four_char_hash_head()
872{
873	atf_set "descr" \
874		"Checks hash database with 4 char key and" \
875		"value insert on a 65536 bucket size"
876}
877four_char_hash_body()
878{
879	TMPDIR="$(pwd)/db_dir"; export TMPDIR
880	mkdir ${TMPDIR}
881
882	cat >in <<EOF
883p
884k1234
885d1234
886r
887k1234
888EOF
889
890	atf_check "$(prog)" -i bsize=65536 hash in
891}
892
893atf_init_test_cases()
894{
895	atf_add_test_case small_btree
896	atf_add_test_case small_hash
897	atf_add_test_case small_recno
898	atf_add_test_case medium_btree
899	atf_add_test_case medium_hash
900	atf_add_test_case medium_recno
901	atf_add_test_case big_btree
902	atf_add_test_case big_hash
903	atf_add_test_case big_recno
904	atf_add_test_case random_recno
905	atf_add_test_case reverse_recno
906	atf_add_test_case alternate_recno
907	atf_add_test_case delete_btree
908	atf_add_test_case delete_recno
909	atf_add_test_case repeated_btree
910	atf_add_test_case repeated_hash
911	atf_add_test_case duplicate_btree
912	atf_add_test_case cursor_flags_btree
913	atf_add_test_case cursor_flags_recno
914	atf_add_test_case reverse_order_recno
915	atf_add_test_case small_page_btree
916	atf_add_test_case byte_orders_btree
917	atf_add_test_case byte_orders_hash
918	atf_add_test_case bsize_ffactor
919	atf_add_test_case four_char_hash
920}
921