1*cdebaff8SEnji Cooper# $NetBSD: t_db.sh,v 1.7 2016/09/24 20:12:33 christos Exp $ 257718be8SEnji Cooper# 357718be8SEnji Cooper# Copyright (c) 2008 The NetBSD Foundation, Inc. 457718be8SEnji Cooper# All rights reserved. 557718be8SEnji Cooper# 657718be8SEnji Cooper# Redistribution and use in source and binary forms, with or without 757718be8SEnji Cooper# modification, are permitted provided that the following conditions 857718be8SEnji Cooper# are met: 957718be8SEnji Cooper# 1. Redistributions of source code must retain the above copyright 1057718be8SEnji Cooper# notice, this list of conditions and the following disclaimer. 1157718be8SEnji Cooper# 2. Redistributions in binary form must reproduce the above copyright 1257718be8SEnji Cooper# notice, this list of conditions and the following disclaimer in the 1357718be8SEnji Cooper# documentation and/or other materials provided with the distribution. 1457718be8SEnji Cooper# 1557718be8SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1657718be8SEnji Cooper# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 1757718be8SEnji Cooper# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1857718be8SEnji Cooper# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 1957718be8SEnji Cooper# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2057718be8SEnji Cooper# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2157718be8SEnji Cooper# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2257718be8SEnji Cooper# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2357718be8SEnji Cooper# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2457718be8SEnji Cooper# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2557718be8SEnji Cooper# POSSIBILITY OF SUCH DAMAGE. 2657718be8SEnji Cooper# 2757718be8SEnji Cooper 28640235e2SEnji Cooperprog_db() 2957718be8SEnji Cooper{ 3057718be8SEnji Cooper echo $(atf_get_srcdir)/h_db 3157718be8SEnji Cooper} 3257718be8SEnji Cooper 33640235e2SEnji Cooperprog_lfsr() 34640235e2SEnji Cooper{ 35640235e2SEnji Cooper echo $(atf_get_srcdir)/h_lfsr 36640235e2SEnji Cooper} 37640235e2SEnji Cooper 3857718be8SEnji Cooperdict() 3957718be8SEnji Cooper{ 4057718be8SEnji Cooper if [ -f /usr/share/dict/words ]; then 4157718be8SEnji Cooper echo /usr/share/dict/words 4257718be8SEnji Cooper elif [ -f /usr/dict/words ]; then 4357718be8SEnji Cooper echo /usr/dict/words 4457718be8SEnji Cooper else 4557718be8SEnji Cooper atf_fail "no dictionary found" 4657718be8SEnji Cooper fi 4757718be8SEnji Cooper} 4857718be8SEnji Cooper 4957718be8SEnji CooperSEVEN_SEVEN="abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg|abcdefg" 5057718be8SEnji Cooper 5157718be8SEnji Cooperatf_test_case small_btree 5257718be8SEnji Coopersmall_btree_head() 5357718be8SEnji Cooper{ 5457718be8SEnji Cooper atf_set "descr" \ 5557718be8SEnji Cooper "Checks btree database using small keys and small data" \ 5657718be8SEnji Cooper "pairs: takes the first hundred entries in the dictionary," \ 5757718be8SEnji Cooper "and makes them be key/data pairs." 5886c9d991SEnji Cooper # Begin FreeBSD 5986c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 6086c9d991SEnji Cooper # End FreeBSD 6157718be8SEnji Cooper} 6257718be8SEnji Coopersmall_btree_body() 6357718be8SEnji Cooper{ 6457718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 6557718be8SEnji Cooper mkdir ${TMPDIR} 6657718be8SEnji Cooper 6757718be8SEnji Cooper sed 200q $(dict) >exp 6857718be8SEnji Cooper 6957718be8SEnji Cooper for i in `sed 200q $(dict)`; do 7057718be8SEnji Cooper echo p 7157718be8SEnji Cooper echo k$i 7257718be8SEnji Cooper echo d$i 7357718be8SEnji Cooper echo g 7457718be8SEnji Cooper echo k$i 7557718be8SEnji Cooper done >in 7657718be8SEnji Cooper 77640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" btree in 7857718be8SEnji Cooper} 7957718be8SEnji Cooper 8057718be8SEnji Cooperatf_test_case small_hash 8157718be8SEnji Coopersmall_hash_head() 8257718be8SEnji Cooper{ 8357718be8SEnji Cooper atf_set "descr" \ 8457718be8SEnji Cooper "Checks hash database using small keys and small data" \ 8557718be8SEnji Cooper "pairs: takes the first hundred entries in the dictionary," \ 8657718be8SEnji Cooper "and makes them be key/data pairs." 8786c9d991SEnji Cooper # Begin FreeBSD 8886c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 8986c9d991SEnji Cooper # End FreeBSD 9057718be8SEnji Cooper} 9157718be8SEnji Coopersmall_hash_body() 9257718be8SEnji Cooper{ 9357718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 9457718be8SEnji Cooper mkdir ${TMPDIR} 9557718be8SEnji Cooper 9657718be8SEnji Cooper sed 200q $(dict) >exp 9757718be8SEnji Cooper 9857718be8SEnji Cooper for i in `sed 200q $(dict)`; do 9957718be8SEnji Cooper echo p 10057718be8SEnji Cooper echo k$i 10157718be8SEnji Cooper echo d$i 10257718be8SEnji Cooper echo g 10357718be8SEnji Cooper echo k$i 10457718be8SEnji Cooper done >in 10557718be8SEnji Cooper 106640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" hash in 10757718be8SEnji Cooper} 10857718be8SEnji Cooper 10957718be8SEnji Cooperatf_test_case small_recno 11057718be8SEnji Coopersmall_recno_head() 11157718be8SEnji Cooper{ 11257718be8SEnji Cooper atf_set "descr" \ 11357718be8SEnji Cooper "Checks recno database using small keys and small data" \ 11457718be8SEnji Cooper "pairs: takes the first hundred entries in the dictionary," \ 11557718be8SEnji Cooper "and makes them be key/data pairs." 11686c9d991SEnji Cooper # Begin FreeBSD 11786c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 11886c9d991SEnji Cooper # End FreeBSD 11957718be8SEnji Cooper} 12057718be8SEnji Coopersmall_recno_body() 12157718be8SEnji Cooper{ 12257718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 12357718be8SEnji Cooper mkdir ${TMPDIR} 12457718be8SEnji Cooper 12557718be8SEnji Cooper sed 200q $(dict) >exp 12657718be8SEnji Cooper 12757718be8SEnji Cooper sed 200q $(dict) | 12857718be8SEnji Cooper awk '{ 12957718be8SEnji Cooper ++i; 13057718be8SEnji Cooper printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 13157718be8SEnji Cooper }' >in 13257718be8SEnji Cooper 133640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" recno in 13457718be8SEnji Cooper} 13557718be8SEnji Cooper 13657718be8SEnji Cooperatf_test_case medium_btree 13757718be8SEnji Coopermedium_btree_head() 13857718be8SEnji Cooper{ 13957718be8SEnji Cooper atf_set "descr" \ 14057718be8SEnji Cooper "Checks btree database using small keys and medium" \ 14157718be8SEnji Cooper "data pairs: takes the first 200 entries in the" \ 14257718be8SEnji Cooper "dictionary, and gives them each a medium size data entry." 14386c9d991SEnji Cooper # Begin FreeBSD 14486c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 14586c9d991SEnji Cooper # End FreeBSD 14657718be8SEnji Cooper} 14757718be8SEnji Coopermedium_btree_body() 14857718be8SEnji Cooper{ 14957718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 15057718be8SEnji Cooper mkdir ${TMPDIR} 15157718be8SEnji Cooper 15257718be8SEnji Cooper mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 15357718be8SEnji Cooper echo $mdata | 15457718be8SEnji Cooper awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp 15557718be8SEnji Cooper 15657718be8SEnji Cooper for i in $(sed 200q $(dict)); do 15757718be8SEnji Cooper echo p 15857718be8SEnji Cooper echo k$i 15957718be8SEnji Cooper echo d$mdata 16057718be8SEnji Cooper echo g 16157718be8SEnji Cooper echo k$i 16257718be8SEnji Cooper done >in 16357718be8SEnji Cooper 164640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" btree in 16557718be8SEnji Cooper} 16657718be8SEnji Cooper 16757718be8SEnji Cooperatf_test_case medium_hash 16857718be8SEnji Coopermedium_hash_head() 16957718be8SEnji Cooper{ 17057718be8SEnji Cooper atf_set "descr" \ 17157718be8SEnji Cooper "Checks hash database using small keys and medium" \ 17257718be8SEnji Cooper "data pairs: takes the first 200 entries in the" \ 17357718be8SEnji Cooper "dictionary, and gives them each a medium size data entry." 17486c9d991SEnji Cooper # Begin FreeBSD 17586c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 17686c9d991SEnji Cooper # End FreeBSD 17757718be8SEnji Cooper} 17857718be8SEnji Coopermedium_hash_body() 17957718be8SEnji Cooper{ 18057718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 18157718be8SEnji Cooper mkdir ${TMPDIR} 18257718be8SEnji Cooper 18357718be8SEnji Cooper mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 18457718be8SEnji Cooper echo $mdata | 18557718be8SEnji Cooper awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp 18657718be8SEnji Cooper 18757718be8SEnji Cooper for i in $(sed 200q $(dict)); do 18857718be8SEnji Cooper echo p 18957718be8SEnji Cooper echo k$i 19057718be8SEnji Cooper echo d$mdata 19157718be8SEnji Cooper echo g 19257718be8SEnji Cooper echo k$i 19357718be8SEnji Cooper done >in 19457718be8SEnji Cooper 195640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" hash in 19657718be8SEnji Cooper} 19757718be8SEnji Cooper 19857718be8SEnji Cooperatf_test_case medium_recno 19957718be8SEnji Coopermedium_recno_head() 20057718be8SEnji Cooper{ 20157718be8SEnji Cooper atf_set "descr" \ 20257718be8SEnji Cooper "Checks recno database using small keys and medium" \ 20357718be8SEnji Cooper "data pairs: takes the first 200 entries in the" \ 20457718be8SEnji Cooper "dictionary, and gives them each a medium size data entry." 20557718be8SEnji Cooper} 20657718be8SEnji Coopermedium_recno_body() 20757718be8SEnji Cooper{ 20857718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 20957718be8SEnji Cooper mkdir ${TMPDIR} 21057718be8SEnji Cooper 21157718be8SEnji Cooper mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 21257718be8SEnji Cooper echo $mdata | 21357718be8SEnji Cooper awk '{ for (i = 1; i < 201; ++i) print $0 }' >exp 21457718be8SEnji Cooper 21557718be8SEnji Cooper echo $mdata | 21657718be8SEnji Cooper awk '{ for (i = 1; i < 201; ++i) 21757718be8SEnji Cooper printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 21857718be8SEnji Cooper }' >in 21957718be8SEnji Cooper 220640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" recno in 22157718be8SEnji Cooper} 22257718be8SEnji Cooper 22357718be8SEnji Cooperatf_test_case big_btree 22457718be8SEnji Cooperbig_btree_head() 22557718be8SEnji Cooper{ 22657718be8SEnji Cooper atf_set "descr" \ 22757718be8SEnji Cooper "Checks btree database using small keys and big data" \ 22857718be8SEnji Cooper "pairs: inserts the programs in /bin with their paths" \ 22957718be8SEnji Cooper "as their keys." 23057718be8SEnji Cooper} 23157718be8SEnji Cooperbig_btree_body() 23257718be8SEnji Cooper{ 23357718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 23457718be8SEnji Cooper mkdir ${TMPDIR} 23557718be8SEnji Cooper 23657718be8SEnji Cooper (find /bin -type f -print | xargs cat) >exp 23757718be8SEnji Cooper 23857718be8SEnji Cooper for psize in 512 16384 65536; do 23957718be8SEnji Cooper echo "checking page size: $psize" 24057718be8SEnji Cooper 24157718be8SEnji Cooper for i in `find /bin -type f -print`; do 24257718be8SEnji Cooper echo p 24357718be8SEnji Cooper echo k$i 24457718be8SEnji Cooper echo D$i 24557718be8SEnji Cooper echo g 24657718be8SEnji Cooper echo k$i 24757718be8SEnji Cooper done >in 24857718be8SEnji Cooper 249640235e2SEnji Cooper atf_check "$(prog_db)" -o out btree in 25057718be8SEnji Cooper cmp -s exp out || atf_fail "test failed for page size: $psize" 25157718be8SEnji Cooper done 25257718be8SEnji Cooper} 25357718be8SEnji Cooper 25457718be8SEnji Cooperatf_test_case big_hash 25557718be8SEnji Cooperbig_hash_head() 25657718be8SEnji Cooper{ 25757718be8SEnji Cooper atf_set "descr" \ 25857718be8SEnji Cooper "Checks hash database using small keys and big data" \ 25957718be8SEnji Cooper "pairs: inserts the programs in /bin with their paths" \ 26057718be8SEnji Cooper "as their keys." 26157718be8SEnji Cooper} 26257718be8SEnji Cooperbig_hash_body() 26357718be8SEnji Cooper{ 26457718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 26557718be8SEnji Cooper mkdir ${TMPDIR} 26657718be8SEnji Cooper 26757718be8SEnji Cooper (find /bin -type f -print | xargs cat) >exp 26857718be8SEnji Cooper 26957718be8SEnji Cooper for i in `find /bin -type f -print`; do 27057718be8SEnji Cooper echo p 27157718be8SEnji Cooper echo k$i 27257718be8SEnji Cooper echo D$i 27357718be8SEnji Cooper echo g 27457718be8SEnji Cooper echo k$i 27557718be8SEnji Cooper done >in 27657718be8SEnji Cooper 277640235e2SEnji Cooper atf_check "$(prog_db)" -o out hash in 27857718be8SEnji Cooper cmp -s exp out || atf_fail "test failed" 27957718be8SEnji Cooper} 28057718be8SEnji Cooper 28157718be8SEnji Cooperatf_test_case big_recno 28257718be8SEnji Cooperbig_recno_head() 28357718be8SEnji Cooper{ 28457718be8SEnji Cooper atf_set "descr" \ 28557718be8SEnji Cooper "Checks recno database using small keys and big data" \ 28657718be8SEnji Cooper "pairs: inserts the programs in /bin with their paths" \ 28757718be8SEnji Cooper "as their keys." 28857718be8SEnji Cooper} 28957718be8SEnji Cooperbig_recno_body() 29057718be8SEnji Cooper{ 29157718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 29257718be8SEnji Cooper mkdir ${TMPDIR} 29357718be8SEnji Cooper 29457718be8SEnji Cooper (find /bin -type f -print | xargs cat) >exp 29557718be8SEnji Cooper 29657718be8SEnji Cooper find /bin -type f -print | 29757718be8SEnji Cooper awk '{ 29857718be8SEnji Cooper ++i; 29957718be8SEnji Cooper printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); 30057718be8SEnji Cooper }' >in 30157718be8SEnji Cooper 30257718be8SEnji Cooper for psize in 512 16384 65536; do 30357718be8SEnji Cooper echo "checking page size: $psize" 30457718be8SEnji Cooper 305640235e2SEnji Cooper atf_check "$(prog_db)" -o out recno in 30657718be8SEnji Cooper cmp -s exp out || atf_fail "test failed for page size: $psize" 30757718be8SEnji Cooper done 30857718be8SEnji Cooper} 30957718be8SEnji Cooper 31057718be8SEnji Cooperatf_test_case random_recno 31157718be8SEnji Cooperrandom_recno_head() 31257718be8SEnji Cooper{ 31357718be8SEnji Cooper atf_set "descr" "Checks recno database using random entries" 31457718be8SEnji Cooper} 31557718be8SEnji Cooperrandom_recno_body() 31657718be8SEnji Cooper{ 31757718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 31857718be8SEnji Cooper mkdir ${TMPDIR} 31957718be8SEnji Cooper 32057718be8SEnji Cooper echo $SEVEN_SEVEN | 32157718be8SEnji Cooper awk '{ 32257718be8SEnji Cooper for (i = 37; i <= 37 + 88 * 17; i += 17) { 32357718be8SEnji Cooper if (i % 41) 32457718be8SEnji Cooper s = substr($0, 1, i % 41); 32557718be8SEnji Cooper else 32657718be8SEnji Cooper s = substr($0, 1); 32757718be8SEnji Cooper printf("input key %d: %s\n", i, s); 32857718be8SEnji Cooper } 32957718be8SEnji Cooper for (i = 1; i <= 15; ++i) { 33057718be8SEnji Cooper if (i % 41) 33157718be8SEnji Cooper s = substr($0, 1, i % 41); 33257718be8SEnji Cooper else 33357718be8SEnji Cooper s = substr($0, 1); 33457718be8SEnji Cooper printf("input key %d: %s\n", i, s); 33557718be8SEnji Cooper } 33657718be8SEnji Cooper for (i = 19234; i <= 19234 + 61 * 27; i += 27) { 33757718be8SEnji Cooper if (i % 41) 33857718be8SEnji Cooper s = substr($0, 1, i % 41); 33957718be8SEnji Cooper else 34057718be8SEnji Cooper s = substr($0, 1); 34157718be8SEnji Cooper printf("input key %d: %s\n", i, s); 34257718be8SEnji Cooper } 34357718be8SEnji Cooper exit 34457718be8SEnji Cooper }' >exp 34557718be8SEnji Cooper 34657718be8SEnji Cooper cat exp | 34757718be8SEnji Cooper awk 'BEGIN { 34857718be8SEnji Cooper i = 37; 34957718be8SEnji Cooper incr = 17; 35057718be8SEnji Cooper } 35157718be8SEnji Cooper { 35257718be8SEnji Cooper printf("p\nk%d\nd%s\n", i, $0); 35357718be8SEnji Cooper if (i == 19234 + 61 * 27) 35457718be8SEnji Cooper exit; 35557718be8SEnji Cooper if (i == 37 + 88 * 17) { 35657718be8SEnji Cooper i = 1; 35757718be8SEnji Cooper incr = 1; 35857718be8SEnji Cooper } else if (i == 15) { 35957718be8SEnji Cooper i = 19234; 36057718be8SEnji Cooper incr = 27; 36157718be8SEnji Cooper } else 36257718be8SEnji Cooper i += incr; 36357718be8SEnji Cooper } 36457718be8SEnji Cooper END { 36557718be8SEnji Cooper for (i = 37; i <= 37 + 88 * 17; i += 17) 36657718be8SEnji Cooper printf("g\nk%d\n", i); 36757718be8SEnji Cooper for (i = 1; i <= 15; ++i) 36857718be8SEnji Cooper printf("g\nk%d\n", i); 36957718be8SEnji Cooper for (i = 19234; i <= 19234 + 61 * 27; i += 27) 37057718be8SEnji Cooper printf("g\nk%d\n", i); 37157718be8SEnji Cooper }' >in 37257718be8SEnji Cooper 373640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" recno in 37457718be8SEnji Cooper} 37557718be8SEnji Cooper 37657718be8SEnji Cooperatf_test_case reverse_recno 37757718be8SEnji Cooperreverse_recno_head() 37857718be8SEnji Cooper{ 37957718be8SEnji Cooper atf_set "descr" "Checks recno database using reverse order entries" 38057718be8SEnji Cooper} 38157718be8SEnji Cooperreverse_recno_body() 38257718be8SEnji Cooper{ 38357718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 38457718be8SEnji Cooper mkdir ${TMPDIR} 38557718be8SEnji Cooper 38657718be8SEnji Cooper echo $SEVEN_SEVEN | 38757718be8SEnji Cooper awk ' { 38857718be8SEnji Cooper for (i = 1500; i; --i) { 38957718be8SEnji Cooper if (i % 34) 39057718be8SEnji Cooper s = substr($0, 1, i % 34); 39157718be8SEnji Cooper else 39257718be8SEnji Cooper s = substr($0, 1); 39357718be8SEnji Cooper printf("input key %d: %s\n", i, s); 39457718be8SEnji Cooper } 39557718be8SEnji Cooper exit; 39657718be8SEnji Cooper }' >exp 39757718be8SEnji Cooper 39857718be8SEnji Cooper cat exp | 39957718be8SEnji Cooper awk 'BEGIN { 40057718be8SEnji Cooper i = 1500; 40157718be8SEnji Cooper } 40257718be8SEnji Cooper { 40357718be8SEnji Cooper printf("p\nk%d\nd%s\n", i, $0); 40457718be8SEnji Cooper --i; 40557718be8SEnji Cooper } 40657718be8SEnji Cooper END { 40757718be8SEnji Cooper for (i = 1500; i; --i) 40857718be8SEnji Cooper printf("g\nk%d\n", i); 40957718be8SEnji Cooper }' >in 41057718be8SEnji Cooper 411640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" recno in 41257718be8SEnji Cooper} 41357718be8SEnji Cooper 41457718be8SEnji Cooperatf_test_case alternate_recno 41557718be8SEnji Cooperalternate_recno_head() 41657718be8SEnji Cooper{ 41757718be8SEnji Cooper atf_set "descr" "Checks recno database using alternating order entries" 41857718be8SEnji Cooper} 41957718be8SEnji Cooperalternate_recno_body() 42057718be8SEnji Cooper{ 42157718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 42257718be8SEnji Cooper mkdir ${TMPDIR} 42357718be8SEnji Cooper 42457718be8SEnji Cooper echo $SEVEN_SEVEN | 42557718be8SEnji Cooper awk ' { 42657718be8SEnji Cooper for (i = 1; i < 1200; i += 2) { 42757718be8SEnji Cooper if (i % 34) 42857718be8SEnji Cooper s = substr($0, 1, i % 34); 42957718be8SEnji Cooper else 43057718be8SEnji Cooper s = substr($0, 1); 43157718be8SEnji Cooper printf("input key %d: %s\n", i, s); 43257718be8SEnji Cooper } 43357718be8SEnji Cooper for (i = 2; i < 1200; i += 2) { 43457718be8SEnji Cooper if (i % 34) 43557718be8SEnji Cooper s = substr($0, 1, i % 34); 43657718be8SEnji Cooper else 43757718be8SEnji Cooper s = substr($0, 1); 43857718be8SEnji Cooper printf("input key %d: %s\n", i, s); 43957718be8SEnji Cooper } 44057718be8SEnji Cooper exit; 44157718be8SEnji Cooper }' >exp 44257718be8SEnji Cooper 44357718be8SEnji Cooper cat exp | 44457718be8SEnji Cooper awk 'BEGIN { 44557718be8SEnji Cooper i = 1; 44657718be8SEnji Cooper even = 0; 44757718be8SEnji Cooper } 44857718be8SEnji Cooper { 44957718be8SEnji Cooper printf("p\nk%d\nd%s\n", i, $0); 45057718be8SEnji Cooper i += 2; 45157718be8SEnji Cooper if (i >= 1200) { 45257718be8SEnji Cooper if (even == 1) 45357718be8SEnji Cooper exit; 45457718be8SEnji Cooper even = 1; 45557718be8SEnji Cooper i = 2; 45657718be8SEnji Cooper } 45757718be8SEnji Cooper } 45857718be8SEnji Cooper END { 45957718be8SEnji Cooper for (i = 1; i < 1200; ++i) 46057718be8SEnji Cooper printf("g\nk%d\n", i); 46157718be8SEnji Cooper }' >in 46257718be8SEnji Cooper 463640235e2SEnji Cooper atf_check "$(prog_db)" -o out recno in 46457718be8SEnji Cooper 46557718be8SEnji Cooper sort -o exp exp 46657718be8SEnji Cooper sort -o out out 46757718be8SEnji Cooper 46857718be8SEnji Cooper cmp -s exp out || atf_fail "test failed" 46957718be8SEnji Cooper} 47057718be8SEnji Cooper 47157718be8SEnji Cooperh_delete() 47257718be8SEnji Cooper{ 47357718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 47457718be8SEnji Cooper mkdir ${TMPDIR} 47557718be8SEnji Cooper 47657718be8SEnji Cooper type=$1 47757718be8SEnji Cooper 47857718be8SEnji Cooper echo $SEVEN_SEVEN | 47957718be8SEnji Cooper awk '{ 48057718be8SEnji Cooper for (i = 1; i <= 120; ++i) 48157718be8SEnji Cooper printf("%05d: input key %d: %s\n", i, i, $0); 48257718be8SEnji Cooper }' >exp 48357718be8SEnji Cooper 48457718be8SEnji Cooper cat exp | 48557718be8SEnji Cooper awk '{ 48657718be8SEnji Cooper printf("p\nk%d\nd%s\n", ++i, $0); 48757718be8SEnji Cooper } 48857718be8SEnji Cooper END { 48957718be8SEnji Cooper printf("fR_NEXT\n"); 49057718be8SEnji Cooper for (i = 1; i <= 120; ++i) 49157718be8SEnji Cooper printf("s\n"); 49257718be8SEnji Cooper printf("fR_CURSOR\ns\nkXX\n"); 49357718be8SEnji Cooper printf("r\n"); 49457718be8SEnji Cooper printf("fR_NEXT\ns\n"); 49557718be8SEnji Cooper printf("fR_CURSOR\ns\nk1\n"); 49657718be8SEnji Cooper printf("r\n"); 49757718be8SEnji Cooper printf("fR_FIRST\ns\n"); 49857718be8SEnji Cooper }' >in 49957718be8SEnji Cooper 50057718be8SEnji Cooper # For btree, the records are ordered by the string representation 50157718be8SEnji Cooper # of the key value. So sort the expected output file accordingly, 50257718be8SEnji Cooper # and set the seek_last key to the last expected key value. 50357718be8SEnji Cooper 50457718be8SEnji Cooper if [ "$type" = "btree" ] ; then 50557718be8SEnji Cooper sed -e 's/kXX/k99/' < in > tmp 50657718be8SEnji Cooper mv tmp in 50757718be8SEnji Cooper sort -d -k4 < exp > tmp 50857718be8SEnji Cooper mv tmp exp 50957718be8SEnji Cooper echo $SEVEN_SEVEN | 51057718be8SEnji Cooper awk '{ 51157718be8SEnji Cooper printf("%05d: input key %d: %s\n", 99, 99, $0); 51257718be8SEnji Cooper printf("seq failed, no such key\n"); 51357718be8SEnji Cooper printf("%05d: input key %d: %s\n", 1, 1, $0); 51457718be8SEnji Cooper printf("%05d: input key %d: %s\n", 10, 10, $0); 51557718be8SEnji Cooper exit; 51657718be8SEnji Cooper }' >> exp 51757718be8SEnji Cooper else 51857718be8SEnji Cooper # For recno, records are ordered by numerical key value. No sort 51957718be8SEnji Cooper # is needed, but still need to set proper seek_last key value. 52057718be8SEnji Cooper sed -e 's/kXX/k120/' < in > tmp 52157718be8SEnji Cooper mv tmp in 52257718be8SEnji Cooper echo $SEVEN_SEVEN | 52357718be8SEnji Cooper awk '{ 52457718be8SEnji Cooper printf("%05d: input key %d: %s\n", 120, 120, $0); 52557718be8SEnji Cooper printf("seq failed, no such key\n"); 52657718be8SEnji Cooper printf("%05d: input key %d: %s\n", 1, 1, $0); 52757718be8SEnji Cooper printf("%05d: input key %d: %s\n", 2, 2, $0); 52857718be8SEnji Cooper exit; 52957718be8SEnji Cooper }' >> exp 53057718be8SEnji Cooper fi 53157718be8SEnji Cooper 532640235e2SEnji Cooper atf_check "$(prog_db)" -o out $type in 53357718be8SEnji Cooper atf_check -o file:exp cat out 53457718be8SEnji Cooper} 53557718be8SEnji Cooper 53657718be8SEnji Cooperatf_test_case delete_btree 53757718be8SEnji Cooperdelete_btree_head() 53857718be8SEnji Cooper{ 53957718be8SEnji Cooper atf_set "descr" "Checks removing records in btree database" 54057718be8SEnji Cooper} 54157718be8SEnji Cooperdelete_btree_body() 54257718be8SEnji Cooper{ 54357718be8SEnji Cooper h_delete btree 54457718be8SEnji Cooper} 54557718be8SEnji Cooper 54657718be8SEnji Cooperatf_test_case delete_recno 54757718be8SEnji Cooperdelete_recno_head() 54857718be8SEnji Cooper{ 54957718be8SEnji Cooper atf_set "descr" "Checks removing records in recno database" 55057718be8SEnji Cooper} 55157718be8SEnji Cooperdelete_recno_body() 55257718be8SEnji Cooper{ 55357718be8SEnji Cooper h_delete recno 55457718be8SEnji Cooper} 55557718be8SEnji Cooper 55657718be8SEnji Cooperh_repeated() 55757718be8SEnji Cooper{ 558*cdebaff8SEnji Cooper local type="$1" 55957718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 56057718be8SEnji Cooper mkdir ${TMPDIR} 56157718be8SEnji Cooper 56257718be8SEnji Cooper echo "" | 56357718be8SEnji Cooper awk 'BEGIN { 56457718be8SEnji Cooper for (i = 1; i <= 10; ++i) { 56557718be8SEnji Cooper printf("p\nkkey1\nD/bin/sh\n"); 56657718be8SEnji Cooper printf("p\nkkey2\nD/bin/csh\n"); 56757718be8SEnji Cooper if (i % 8 == 0) { 56857718be8SEnji Cooper printf("c\nkkey2\nD/bin/csh\n"); 56957718be8SEnji Cooper printf("c\nkkey1\nD/bin/sh\n"); 57057718be8SEnji Cooper printf("e\t%d of 10 (comparison)\n", i); 57157718be8SEnji Cooper } else 57257718be8SEnji Cooper printf("e\t%d of 10 \n", i); 57357718be8SEnji Cooper printf("r\nkkey1\nr\nkkey2\n"); 57457718be8SEnji Cooper } 57557718be8SEnji Cooper }' >in 57657718be8SEnji Cooper 577*cdebaff8SEnji Cooper $(prog_db) $type in 57857718be8SEnji Cooper} 57957718be8SEnji Cooper 58057718be8SEnji Cooperatf_test_case repeated_btree 58157718be8SEnji Cooperrepeated_btree_head() 58257718be8SEnji Cooper{ 58357718be8SEnji Cooper atf_set "descr" \ 58457718be8SEnji Cooper "Checks btree database with repeated small keys and" \ 58557718be8SEnji Cooper "big data pairs. Makes sure that overflow pages are reused" 58657718be8SEnji Cooper} 58757718be8SEnji Cooperrepeated_btree_body() 58857718be8SEnji Cooper{ 58957718be8SEnji Cooper h_repeated btree 59057718be8SEnji Cooper} 59157718be8SEnji Cooper 59257718be8SEnji Cooperatf_test_case repeated_hash 59357718be8SEnji Cooperrepeated_hash_head() 59457718be8SEnji Cooper{ 59557718be8SEnji Cooper atf_set "descr" \ 59657718be8SEnji Cooper "Checks hash database with repeated small keys and" \ 59757718be8SEnji Cooper "big data pairs. Makes sure that overflow pages are reused" 59857718be8SEnji Cooper} 59957718be8SEnji Cooperrepeated_hash_body() 60057718be8SEnji Cooper{ 60157718be8SEnji Cooper h_repeated hash 60257718be8SEnji Cooper} 60357718be8SEnji Cooper 60457718be8SEnji Cooperatf_test_case duplicate_btree 60557718be8SEnji Cooperduplicate_btree_head() 60657718be8SEnji Cooper{ 60757718be8SEnji Cooper atf_set "descr" "Checks btree database with duplicate keys" 60857718be8SEnji Cooper} 60957718be8SEnji Cooperduplicate_btree_body() 61057718be8SEnji Cooper{ 61157718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 61257718be8SEnji Cooper mkdir ${TMPDIR} 61357718be8SEnji Cooper 61457718be8SEnji Cooper echo $SEVEN_SEVEN | 61557718be8SEnji Cooper awk '{ 61657718be8SEnji Cooper for (i = 1; i <= 543; ++i) 61757718be8SEnji Cooper printf("%05d: input key %d: %s\n", i, i, $0); 61857718be8SEnji Cooper exit; 61957718be8SEnji Cooper }' >exp 62057718be8SEnji Cooper 62157718be8SEnji Cooper cat exp | 62257718be8SEnji Cooper awk '{ 62357718be8SEnji Cooper if (i++ % 2) 62457718be8SEnji Cooper printf("p\nkduplicatekey\nd%s\n", $0); 62557718be8SEnji Cooper else 62657718be8SEnji Cooper printf("p\nkunique%dkey\nd%s\n", i, $0); 62757718be8SEnji Cooper } 62857718be8SEnji Cooper END { 62957718be8SEnji Cooper printf("o\n"); 63057718be8SEnji Cooper }' >in 63157718be8SEnji Cooper 632640235e2SEnji Cooper atf_check -o file:exp -x "$(prog_db) -iflags=1 btree in | sort" 63357718be8SEnji Cooper} 63457718be8SEnji Cooper 63557718be8SEnji Cooperh_cursor_flags() 63657718be8SEnji Cooper{ 637*cdebaff8SEnji Cooper local type=$1 63857718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 63957718be8SEnji Cooper mkdir ${TMPDIR} 64057718be8SEnji Cooper 64157718be8SEnji Cooper echo $SEVEN_SEVEN | 64257718be8SEnji Cooper awk '{ 64357718be8SEnji Cooper for (i = 1; i <= 20; ++i) 64457718be8SEnji Cooper printf("%05d: input key %d: %s\n", i, i, $0); 64557718be8SEnji Cooper exit; 64657718be8SEnji Cooper }' >exp 64757718be8SEnji Cooper 64857718be8SEnji Cooper # Test that R_CURSOR doesn't succeed before cursor initialized 64957718be8SEnji Cooper cat exp | 65057718be8SEnji Cooper awk '{ 65157718be8SEnji Cooper if (i == 10) 65257718be8SEnji Cooper exit; 65357718be8SEnji Cooper printf("p\nk%d\nd%s\n", ++i, $0); 65457718be8SEnji Cooper } 65557718be8SEnji Cooper END { 65657718be8SEnji Cooper printf("fR_CURSOR\nr\n"); 65757718be8SEnji Cooper printf("eR_CURSOR SHOULD HAVE FAILED\n"); 65857718be8SEnji Cooper }' >in 65957718be8SEnji Cooper 660640235e2SEnji Cooper atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in 66157718be8SEnji Cooper atf_check -s ne:0 test -s out 66257718be8SEnji Cooper 66357718be8SEnji Cooper cat exp | 66457718be8SEnji Cooper awk '{ 66557718be8SEnji Cooper if (i == 10) 66657718be8SEnji Cooper exit; 66757718be8SEnji Cooper printf("p\nk%d\nd%s\n", ++i, $0); 66857718be8SEnji Cooper } 66957718be8SEnji Cooper END { 67057718be8SEnji Cooper printf("fR_CURSOR\np\nk1\ndsome data\n"); 67157718be8SEnji Cooper printf("eR_CURSOR SHOULD HAVE FAILED\n"); 67257718be8SEnji Cooper }' >in 67357718be8SEnji Cooper 674640235e2SEnji Cooper atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in 67557718be8SEnji Cooper atf_check -s ne:0 test -s out 67657718be8SEnji Cooper} 67757718be8SEnji Cooper 67857718be8SEnji Cooperatf_test_case cursor_flags_btree 67957718be8SEnji Coopercursor_flags_btree_head() 68057718be8SEnji Cooper{ 68157718be8SEnji Cooper atf_set "descr" \ 68257718be8SEnji Cooper "Checks use of cursor flags without initialization in btree database" 68357718be8SEnji Cooper} 68457718be8SEnji Coopercursor_flags_btree_body() 68557718be8SEnji Cooper{ 68657718be8SEnji Cooper h_cursor_flags btree 68757718be8SEnji Cooper} 68857718be8SEnji Cooper 68957718be8SEnji Cooperatf_test_case cursor_flags_recno 69057718be8SEnji Coopercursor_flags_recno_head() 69157718be8SEnji Cooper{ 69257718be8SEnji Cooper atf_set "descr" \ 69357718be8SEnji Cooper "Checks use of cursor flags without initialization in recno database" 69457718be8SEnji Cooper} 69557718be8SEnji Coopercursor_flags_recno_body() 69657718be8SEnji Cooper{ 69757718be8SEnji Cooper h_cursor_flags recno 69857718be8SEnji Cooper} 69957718be8SEnji Cooper 70057718be8SEnji Cooperatf_test_case reverse_order_recno 70157718be8SEnji Cooperreverse_order_recno_head() 70257718be8SEnji Cooper{ 70357718be8SEnji Cooper atf_set "descr" "Checks reverse order inserts in recno database" 70457718be8SEnji Cooper} 70557718be8SEnji Cooperreverse_order_recno_body() 70657718be8SEnji Cooper{ 70757718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 70857718be8SEnji Cooper mkdir ${TMPDIR} 70957718be8SEnji Cooper 71057718be8SEnji Cooper echo $SEVEN_SEVEN | 71157718be8SEnji Cooper awk '{ 71257718be8SEnji Cooper for (i = 1; i <= 779; ++i) 71357718be8SEnji Cooper printf("%05d: input key %d: %s\n", i, i, $0); 71457718be8SEnji Cooper exit; 71557718be8SEnji Cooper }' >exp 71657718be8SEnji Cooper 71757718be8SEnji Cooper cat exp | 71857718be8SEnji Cooper awk '{ 71957718be8SEnji Cooper if (i == 0) { 72057718be8SEnji Cooper i = 1; 72157718be8SEnji Cooper printf("p\nk1\nd%s\n", $0); 72257718be8SEnji Cooper printf("%s\n", "fR_IBEFORE"); 72357718be8SEnji Cooper } else 72457718be8SEnji Cooper printf("p\nk1\nd%s\n", $0); 72557718be8SEnji Cooper } 72657718be8SEnji Cooper END { 72757718be8SEnji Cooper printf("or\n"); 72857718be8SEnji Cooper }' >in 72957718be8SEnji Cooper 730640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" recno in 73157718be8SEnji Cooper} 73257718be8SEnji Cooper 73357718be8SEnji Cooperatf_test_case small_page_btree 73457718be8SEnji Coopersmall_page_btree_head() 73557718be8SEnji Cooper{ 73657718be8SEnji Cooper atf_set "descr" \ 73757718be8SEnji Cooper "Checks btree database with lots of keys and small page" \ 73857718be8SEnji Cooper "size: takes the first 20000 entries in the dictionary," \ 73957718be8SEnji Cooper "reverses them, and gives them each a small size data" \ 74057718be8SEnji Cooper "entry. Uses a small page size to make sure the btree" \ 74157718be8SEnji Cooper "split code gets hammered." 74286c9d991SEnji Cooper # Begin FreeBSD 74386c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 74486c9d991SEnji Cooper # End FreeBSD 74557718be8SEnji Cooper} 74657718be8SEnji Coopersmall_page_btree_body() 74757718be8SEnji Cooper{ 74857718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 74957718be8SEnji Cooper mkdir ${TMPDIR} 75057718be8SEnji Cooper 75157718be8SEnji Cooper mdata=abcdefghijklmnopqrstuvwxy 75257718be8SEnji Cooper echo $mdata | 75357718be8SEnji Cooper awk '{ for (i = 1; i < 20001; ++i) print $0 }' >exp 75457718be8SEnji Cooper 75557718be8SEnji Cooper for i in `sed 20000q $(dict) | rev`; do 75657718be8SEnji Cooper echo p 75757718be8SEnji Cooper echo k$i 75857718be8SEnji Cooper echo d$mdata 75957718be8SEnji Cooper echo g 76057718be8SEnji Cooper echo k$i 76157718be8SEnji Cooper done >in 76257718be8SEnji Cooper 763640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" -i psize=512 btree in 76457718be8SEnji Cooper} 76557718be8SEnji Cooper 76657718be8SEnji Cooperh_byte_orders() 76757718be8SEnji Cooper{ 76857718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 76957718be8SEnji Cooper mkdir ${TMPDIR} 77057718be8SEnji Cooper 77157718be8SEnji Cooper type=$1 77257718be8SEnji Cooper 77357718be8SEnji Cooper sed 50q $(dict) >exp 77457718be8SEnji Cooper for order in 1234 4321; do 77557718be8SEnji Cooper for i in `sed 50q $(dict)`; do 77657718be8SEnji Cooper echo p 77757718be8SEnji Cooper echo k$i 77857718be8SEnji Cooper echo d$i 779*cdebaff8SEnji Cooper echo S 78057718be8SEnji Cooper echo g 78157718be8SEnji Cooper echo k$i 78257718be8SEnji Cooper done >in 78357718be8SEnji Cooper 784640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" -ilorder=$order -f byte.file $type in 78557718be8SEnji Cooper 78657718be8SEnji Cooper for i in `sed 50q $(dict)`; do 78757718be8SEnji Cooper echo g 78857718be8SEnji Cooper echo k$i 78957718be8SEnji Cooper done >in 79057718be8SEnji Cooper 791640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" -s -ilorder=$order -f byte.file $type in 79257718be8SEnji Cooper done 79357718be8SEnji Cooper} 79457718be8SEnji Cooper 79557718be8SEnji Cooperatf_test_case byte_orders_btree 79657718be8SEnji Cooperbyte_orders_btree_head() 79757718be8SEnji Cooper{ 79857718be8SEnji Cooper atf_set "descr" "Checks btree database using differing byte orders" 79986c9d991SEnji Cooper # Begin FreeBSD 80086c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 80186c9d991SEnji Cooper # End FreeBSD 80257718be8SEnji Cooper} 80357718be8SEnji Cooperbyte_orders_btree_body() 80457718be8SEnji Cooper{ 80557718be8SEnji Cooper h_byte_orders btree 80657718be8SEnji Cooper} 80757718be8SEnji Cooper 80857718be8SEnji Cooperatf_test_case byte_orders_hash 80957718be8SEnji Cooperbyte_orders_hash_head() 81057718be8SEnji Cooper{ 81157718be8SEnji Cooper atf_set "descr" "Checks hash database using differing byte orders" 81257718be8SEnji Cooper} 81357718be8SEnji Cooperbyte_orders_hash_body() 81457718be8SEnji Cooper{ 81557718be8SEnji Cooper h_byte_orders hash 81657718be8SEnji Cooper} 81757718be8SEnji Cooper 81857718be8SEnji Cooperh_bsize_ffactor() 81957718be8SEnji Cooper{ 82057718be8SEnji Cooper bsize=$1 82157718be8SEnji Cooper ffactor=$2 82257718be8SEnji Cooper 82357718be8SEnji Cooper echo "bucketsize $bsize, fill factor $ffactor" 824640235e2SEnji Cooper atf_check -o file:exp "$(prog_db)" "-ibsize=$bsize,\ 82557718be8SEnji Cooperffactor=$ffactor,nelem=25000,cachesize=65536" hash in 82657718be8SEnji Cooper} 82757718be8SEnji Cooper 82857718be8SEnji Cooperatf_test_case bsize_ffactor 82957718be8SEnji Cooperbsize_ffactor_head() 83057718be8SEnji Cooper{ 831640235e2SEnji Cooper atf_set "timeout" "1800" 83257718be8SEnji Cooper atf_set "descr" "Checks hash database with various" \ 83357718be8SEnji Cooper "bucketsizes and fill factors" 83486c9d991SEnji Cooper # Begin FreeBSD 83586c9d991SEnji Cooper atf_set "require.files" /usr/share/dict/words 83686c9d991SEnji Cooper # End FreeBSD 83757718be8SEnji Cooper} 83857718be8SEnji Cooperbsize_ffactor_body() 83957718be8SEnji Cooper{ 84057718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 84157718be8SEnji Cooper mkdir ${TMPDIR} 84257718be8SEnji Cooper 84357718be8SEnji Cooper echo $SEVEN_SEVEN | 84457718be8SEnji Cooper awk '{ 84557718be8SEnji Cooper for (i = 1; i <= 10000; ++i) { 84657718be8SEnji Cooper if (i % 34) 84757718be8SEnji Cooper s = substr($0, 1, i % 34); 84857718be8SEnji Cooper else 84957718be8SEnji Cooper s = substr($0, 1); 85057718be8SEnji Cooper printf("%s\n", s); 85157718be8SEnji Cooper } 85257718be8SEnji Cooper exit; 85357718be8SEnji Cooper 85457718be8SEnji Cooper }' >exp 85557718be8SEnji Cooper 85657718be8SEnji Cooper sed 10000q $(dict) | 85757718be8SEnji Cooper awk 'BEGIN { 85857718be8SEnji Cooper ds="'$SEVEN_SEVEN'" 85957718be8SEnji Cooper } 86057718be8SEnji Cooper { 86157718be8SEnji Cooper if (++i % 34) 86257718be8SEnji Cooper s = substr(ds, 1, i % 34); 86357718be8SEnji Cooper else 86457718be8SEnji Cooper s = substr(ds, 1); 86557718be8SEnji Cooper printf("p\nk%s\nd%s\n", $0, s); 86657718be8SEnji Cooper }' >in 86757718be8SEnji Cooper 86857718be8SEnji Cooper sed 10000q $(dict) | 86957718be8SEnji Cooper awk '{ 87057718be8SEnji Cooper ++i; 87157718be8SEnji Cooper printf("g\nk%s\n", $0); 87257718be8SEnji Cooper }' >>in 87357718be8SEnji Cooper 87457718be8SEnji Cooper h_bsize_ffactor 256 11 87557718be8SEnji Cooper h_bsize_ffactor 256 14 87657718be8SEnji Cooper h_bsize_ffactor 256 21 87757718be8SEnji Cooper 87857718be8SEnji Cooper h_bsize_ffactor 512 21 87957718be8SEnji Cooper h_bsize_ffactor 512 28 88057718be8SEnji Cooper h_bsize_ffactor 512 43 88157718be8SEnji Cooper 88257718be8SEnji Cooper h_bsize_ffactor 1024 43 88357718be8SEnji Cooper h_bsize_ffactor 1024 57 88457718be8SEnji Cooper h_bsize_ffactor 1024 85 88557718be8SEnji Cooper 88657718be8SEnji Cooper h_bsize_ffactor 2048 85 88757718be8SEnji Cooper h_bsize_ffactor 2048 114 88857718be8SEnji Cooper h_bsize_ffactor 2048 171 88957718be8SEnji Cooper 89057718be8SEnji Cooper h_bsize_ffactor 4096 171 89157718be8SEnji Cooper h_bsize_ffactor 4096 228 89257718be8SEnji Cooper h_bsize_ffactor 4096 341 89357718be8SEnji Cooper 89457718be8SEnji Cooper h_bsize_ffactor 8192 341 89557718be8SEnji Cooper h_bsize_ffactor 8192 455 89657718be8SEnji Cooper h_bsize_ffactor 8192 683 897640235e2SEnji Cooper 898640235e2SEnji Cooper h_bsize_ffactor 16384 341 899640235e2SEnji Cooper h_bsize_ffactor 16384 455 900640235e2SEnji Cooper h_bsize_ffactor 16384 683 901640235e2SEnji Cooper 902640235e2SEnji Cooper h_bsize_ffactor 32768 341 903640235e2SEnji Cooper h_bsize_ffactor 32768 455 904640235e2SEnji Cooper h_bsize_ffactor 32768 683 905640235e2SEnji Cooper 9066b7b162bSEnji Cooper # Begin FreeBSD 9076b7b162bSEnji Cooper if false; then 9086b7b162bSEnji Cooper # End FreeBSD 909640235e2SEnji Cooper h_bsize_ffactor 65536 341 910640235e2SEnji Cooper h_bsize_ffactor 65536 455 911640235e2SEnji Cooper h_bsize_ffactor 65536 683 9126b7b162bSEnji Cooper # Begin FreeBSD 9136b7b162bSEnji Cooper fi 9146b7b162bSEnji Cooper # End FreeBSD 91557718be8SEnji Cooper} 91657718be8SEnji Cooper 917640235e2SEnji Cooper# This tests 64K block size addition/removal 91857718be8SEnji Cooperatf_test_case four_char_hash 91957718be8SEnji Cooperfour_char_hash_head() 92057718be8SEnji Cooper{ 92157718be8SEnji Cooper atf_set "descr" \ 92257718be8SEnji Cooper "Checks hash database with 4 char key and" \ 92357718be8SEnji Cooper "value insert on a 65536 bucket size" 92457718be8SEnji Cooper} 92557718be8SEnji Cooperfour_char_hash_body() 92657718be8SEnji Cooper{ 92757718be8SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 92857718be8SEnji Cooper mkdir ${TMPDIR} 92957718be8SEnji Cooper 93057718be8SEnji Cooper cat >in <<EOF 93157718be8SEnji Cooperp 93257718be8SEnji Cooperk1234 93357718be8SEnji Cooperd1234 93457718be8SEnji Cooperr 93557718be8SEnji Cooperk1234 93657718be8SEnji CooperEOF 93757718be8SEnji Cooper 93843d55325SEnji Cooper # Begin FreeBSD 93943d55325SEnji Cooper if true; then 940640235e2SEnji Cooper atf_check "$(prog_db)" -i bsize=32768 hash in 94143d55325SEnji Cooper else 94243d55325SEnji Cooper # End FreeBSD 943640235e2SEnji Cooper atf_check "$(prog_db)" -i bsize=65536 hash in 94443d55325SEnji Cooper # Begin FreeBSD 94543d55325SEnji Cooper fi 94643d55325SEnji Cooper # End FreeBSD 94757718be8SEnji Cooper} 94857718be8SEnji Cooper 949640235e2SEnji Cooper 950640235e2SEnji Cooperatf_test_case bsize_torture 951640235e2SEnji Cooperbsize_torture_head() 952640235e2SEnji Cooper{ 953640235e2SEnji Cooper atf_set "timeout" "36000" 954640235e2SEnji Cooper atf_set "descr" "Checks hash database with various bucket sizes" 955640235e2SEnji Cooper} 956640235e2SEnji Cooperbsize_torture_body() 957640235e2SEnji Cooper{ 958640235e2SEnji Cooper TMPDIR="$(pwd)/db_dir"; export TMPDIR 959640235e2SEnji Cooper mkdir ${TMPDIR} 9606b7b162bSEnji Cooper # Begin FreeBSD 9616b7b162bSEnji Cooper # 9626b7b162bSEnji Cooper # db(3) doesn't support 64kB bucket sizes 9636b7b162bSEnji Cooper for i in 2048 4096 8192 16384 32768 # 65536 9646b7b162bSEnji Cooper # End FreeBSD 965640235e2SEnji Cooper do 966640235e2SEnji Cooper atf_check "$(prog_lfsr)" $i 967640235e2SEnji Cooper done 968640235e2SEnji Cooper} 969640235e2SEnji Cooper 970*cdebaff8SEnji Cooperatf_test_case btree_weird_page_split 971*cdebaff8SEnji Cooperbtree_weird_page_split_head() 972*cdebaff8SEnji Cooper{ 973*cdebaff8SEnji Cooper atf_set "descr" \ 974*cdebaff8SEnji Cooper "Test for a weird page split condition where an insertion " \ 975*cdebaff8SEnji Cooper "into index 0 of a page that would cause the new item to " \ 976*cdebaff8SEnji Cooper "be the only item on the left page results in index 0 of " \ 977*cdebaff8SEnji Cooper "the right page being erroneously skipped; this only " \ 978*cdebaff8SEnji Cooper "happens with one particular key+data length for each page size." 979*cdebaff8SEnji Cooper} 980*cdebaff8SEnji Cooperbtree_weird_page_split_body() 981*cdebaff8SEnji Cooper{ 982*cdebaff8SEnji Cooper for psize in 512 1024 2048 4096 8192; do 983*cdebaff8SEnji Cooper echo " page size $psize" 984*cdebaff8SEnji Cooper kdsizes=`awk 'BEGIN { 985*cdebaff8SEnji Cooper psize = '$psize'; hsize = int(psize/2); 986*cdebaff8SEnji Cooper for (kdsize = hsize-40; kdsize <= hsize; kdsize++) { 987*cdebaff8SEnji Cooper print kdsize; 988*cdebaff8SEnji Cooper } 989*cdebaff8SEnji Cooper }' /dev/null` 990*cdebaff8SEnji Cooper 991*cdebaff8SEnji Cooper # Use a series of keylen+datalen values in the right 992*cdebaff8SEnji Cooper # neighborhood to find the one that triggers the bug. 993*cdebaff8SEnji Cooper # We could compute the exact size that triggers the 994*cdebaff8SEnji Cooper # bug but this additional fuzz may be useful. 995*cdebaff8SEnji Cooper 996*cdebaff8SEnji Cooper # Insert keys in reverse order to maximize the chances 997*cdebaff8SEnji Cooper # for a split on index 0. 998*cdebaff8SEnji Cooper 999*cdebaff8SEnji Cooper for kdsize in $kdsizes; do 1000*cdebaff8SEnji Cooper awk 'BEGIN { 1001*cdebaff8SEnji Cooper kdsize = '$kdsize'; 1002*cdebaff8SEnji Cooper for (i = 8; i-- > 0; ) { 1003*cdebaff8SEnji Cooper s = sprintf("a%03d:%09d", i, kdsize); 1004*cdebaff8SEnji Cooper for (j = 0; j < kdsize-20; j++) { 1005*cdebaff8SEnji Cooper s = s "x"; 1006*cdebaff8SEnji Cooper } 1007*cdebaff8SEnji Cooper printf("p\nka%03d\nd%s\n", i, s); 1008*cdebaff8SEnji Cooper } 1009*cdebaff8SEnji Cooper print "o"; 1010*cdebaff8SEnji Cooper }' /dev/null > in 1011*cdebaff8SEnji Cooper sed -n 's/^d//p' in | sort > exp 1012*cdebaff8SEnji Cooper atf_check -o file:exp \ 1013*cdebaff8SEnji Cooper "$(prog_db)" -i psize=$psize btree in 1014*cdebaff8SEnji Cooper done 1015*cdebaff8SEnji Cooper done 1016*cdebaff8SEnji Cooper} 1017*cdebaff8SEnji Cooper 1018*cdebaff8SEnji Cooper# Extremely tricky test attempting to replicate some unusual database 1019*cdebaff8SEnji Cooper# corruption seen in the field: pieces of the database becoming 1020*cdebaff8SEnji Cooper# inaccessible to random access, sequential access, or both. The 1021*cdebaff8SEnji Cooper# hypothesis is that at least some of these are triggered by the bug 1022*cdebaff8SEnji Cooper# in page splits on index 0 with a particular exact keylen+datalen. 1023*cdebaff8SEnji Cooper# (See Test 40.) For psize=4096, this size is exactly 2024. 1024*cdebaff8SEnji Cooper 1025*cdebaff8SEnji Cooper# The order of operations here relies on very specific knowledge of 1026*cdebaff8SEnji Cooper# the internals of the btree access method in order to place records 1027*cdebaff8SEnji Cooper# at specific offsets in a page and to create certain keys on internal 1028*cdebaff8SEnji Cooper# pages. The to-be-split page immediately prior to the bug-triggering 1029*cdebaff8SEnji Cooper# split has the following properties: 1030*cdebaff8SEnji Cooper# 1031*cdebaff8SEnji Cooper# * is not the leftmost leaf page 1032*cdebaff8SEnji Cooper# * key on the parent page is compares less than the key of the item 1033*cdebaff8SEnji Cooper# on index 0 1034*cdebaff8SEnji Cooper# * triggering record's key also compares greater than the key on the 1035*cdebaff8SEnji Cooper# parent page 1036*cdebaff8SEnji Cooper 1037*cdebaff8SEnji Cooper# Additionally, we prime the mpool LRU chain so that the head page on 1038*cdebaff8SEnji Cooper# the chain has the following properties: 1039*cdebaff8SEnji Cooper# 1040*cdebaff8SEnji Cooper# * record at index 0 is located where it will not get overwritten by 1041*cdebaff8SEnji Cooper# items written to the right-hand page during the split 1042*cdebaff8SEnji Cooper# * key of the record at index 0 compares less than the key of the 1043*cdebaff8SEnji Cooper# bug-triggering record 1044*cdebaff8SEnji Cooper 1045*cdebaff8SEnji Cooper# If the page-split bug exists, this test appears to create a database 1046*cdebaff8SEnji Cooper# where some records are inaccessible to a search, but still remain in 1047*cdebaff8SEnji Cooper# the file and are accessible by sequential traversal. At least one 1048*cdebaff8SEnji Cooper# record gets duplicated out of sequence. 1049*cdebaff8SEnji Cooper 1050*cdebaff8SEnji Cooperatf_test_case btree_tricky_page_split 1051*cdebaff8SEnji Cooperbtree_tricky_page_split_head() 1052*cdebaff8SEnji Cooper{ 1053*cdebaff8SEnji Cooper atf_set "descr" \ 1054*cdebaff8SEnji Cooper "btree: no unsearchables due to page split on index 0" 1055*cdebaff8SEnji Cooper} 1056*cdebaff8SEnji Cooperbtree_tricky_page_split_body() 1057*cdebaff8SEnji Cooper{ 1058*cdebaff8SEnji Cooper list=`(for i in a b c d; do 1059*cdebaff8SEnji Cooper for j in 990 998 999; do 1060*cdebaff8SEnji Cooper echo g ${i}${j} 1024 1061*cdebaff8SEnji Cooper done 1062*cdebaff8SEnji Cooper done; 1063*cdebaff8SEnji Cooper echo g y997 2014 1064*cdebaff8SEnji Cooper for i in y z; do 1065*cdebaff8SEnji Cooper for j in 998 999; do 1066*cdebaff8SEnji Cooper echo g ${i}${j} 1024 1067*cdebaff8SEnji Cooper done 1068*cdebaff8SEnji Cooper done)` 1069*cdebaff8SEnji Cooper # Exact number for trigger condition accounts for newlines 1070*cdebaff8SEnji Cooper # retained by dbtest with -ofile but not without; we use 1071*cdebaff8SEnji Cooper # -ofile, so count newlines. keylen=5,datalen=5+2014 for 1072*cdebaff8SEnji Cooper # psize=4096 here. 1073*cdebaff8SEnji Cooper (cat - <<EOF 1074*cdebaff8SEnji Cooperp z999 1024 1075*cdebaff8SEnji Cooperp z998 1024 1076*cdebaff8SEnji Cooperp y999 1024 1077*cdebaff8SEnji Cooperp y990 1024 1078*cdebaff8SEnji Cooperp d999 1024 1079*cdebaff8SEnji Cooperp d990 1024 1080*cdebaff8SEnji Cooperp c999 1024 1081*cdebaff8SEnji Cooperp c990 1024 1082*cdebaff8SEnji Cooperp b999 1024 1083*cdebaff8SEnji Cooperp b990 1024 1084*cdebaff8SEnji Cooperp a999 1024 1085*cdebaff8SEnji Cooperp a990 1024 1086*cdebaff8SEnji Cooperp y998 1024 1087*cdebaff8SEnji Cooperr y990 1088*cdebaff8SEnji Cooperp d998 1024 1089*cdebaff8SEnji Cooperp d990 1024 1090*cdebaff8SEnji Cooperp c998 1024 1091*cdebaff8SEnji Cooperp c990 1024 1092*cdebaff8SEnji Cooperp b998 1024 1093*cdebaff8SEnji Cooperp b990 1024 1094*cdebaff8SEnji Cooperp a998 1024 1095*cdebaff8SEnji Cooperp a990 1024 1096*cdebaff8SEnji Cooperp y997 2014 1097*cdebaff8SEnji CooperS 1098*cdebaff8SEnji Coopero 1099*cdebaff8SEnji CooperEOF 1100*cdebaff8SEnji Cooper echo "$list") | 1101*cdebaff8SEnji Cooper # awk script input: 1102*cdebaff8SEnji Cooper # {p|g|r} key [datasize] 1103*cdebaff8SEnji Cooper awk '/^[pgr]/{ 1104*cdebaff8SEnji Cooper printf("%s\nk%s\n", $1, $2); 1105*cdebaff8SEnji Cooper } 1106*cdebaff8SEnji Cooper /^p/{ 1107*cdebaff8SEnji Cooper s = $2; 1108*cdebaff8SEnji Cooper for (i = 0; i < $3; i++) { 1109*cdebaff8SEnji Cooper s = s "x"; 1110*cdebaff8SEnji Cooper } 1111*cdebaff8SEnji Cooper printf("d%s\n", s); 1112*cdebaff8SEnji Cooper } 1113*cdebaff8SEnji Cooper !/^[pgr]/{ 1114*cdebaff8SEnji Cooper print $0; 1115*cdebaff8SEnji Cooper }' > in 1116*cdebaff8SEnji Cooper (echo "$list"; echo "$list") | awk '{ 1117*cdebaff8SEnji Cooper s = $2; 1118*cdebaff8SEnji Cooper for (i = 0; i < $3; i++) { 1119*cdebaff8SEnji Cooper s = s "x"; 1120*cdebaff8SEnji Cooper } 1121*cdebaff8SEnji Cooper print s; 1122*cdebaff8SEnji Cooper }' > exp 1123*cdebaff8SEnji Cooper atf_check -o file:exp \ 1124*cdebaff8SEnji Cooper "$(prog_db)" -i psize=4096 btree in 1125*cdebaff8SEnji Cooper} 1126*cdebaff8SEnji Cooper 1127*cdebaff8SEnji Cooper# Begin FreeBSD 1128*cdebaff8SEnji Cooperif false; then 1129*cdebaff8SEnji Cooper# End FreeBSD 1130*cdebaff8SEnji Cooperatf_test_case btree_recursive_traversal 1131*cdebaff8SEnji Cooperbtree_recursive_traversal_head() 1132*cdebaff8SEnji Cooper{ 1133*cdebaff8SEnji Cooper atf_set "descr" \ 1134*cdebaff8SEnji Cooper "btree: Test for recursive traversal successfully " \ 1135*cdebaff8SEnji Cooper "retrieving records that are inaccessible to normal " \ 1136*cdebaff8SEnji Cooper "sequential 'sibling-link' traversal. This works by " \ 1137*cdebaff8SEnji Cooper "unlinking a few leaf pages but leaving their parent " \ 1138*cdebaff8SEnji Cooper "links intact. To verify that the unlink actually makes " \ 1139*cdebaff8SEnji Cooper "records inaccessible, the test first uses 'o' to do a " \ 1140*cdebaff8SEnji Cooper "normal sequential traversal, followed by 'O' to do a " \ 1141*cdebaff8SEnji Cooper "recursive traversal." 1142*cdebaff8SEnji Cooper} 1143*cdebaff8SEnji Cooperbtree_recursive_traversal_body() 1144*cdebaff8SEnji Cooper{ 1145*cdebaff8SEnji Cooper fill="abcdefghijklmnopqrstuvwxyzy" 1146*cdebaff8SEnji Cooper script='{ 1147*cdebaff8SEnji Cooper for (i = 0; i < 20000; i++) { 1148*cdebaff8SEnji Cooper printf("p\nkAA%05d\nd%05d%s\n", i, i, $0); 1149*cdebaff8SEnji Cooper } 1150*cdebaff8SEnji Cooper print "u"; 1151*cdebaff8SEnji Cooper print "u"; 1152*cdebaff8SEnji Cooper print "u"; 1153*cdebaff8SEnji Cooper print "u"; 1154*cdebaff8SEnji Cooper }' 1155*cdebaff8SEnji Cooper (echo $fill | awk "$script"; echo o) > in1 1156*cdebaff8SEnji Cooper echo $fill | 1157*cdebaff8SEnji Cooper awk '{ 1158*cdebaff8SEnji Cooper for (i = 0; i < 20000; i++) { 1159*cdebaff8SEnji Cooper if (i >= 5 && i <= 40) 1160*cdebaff8SEnji Cooper continue; 1161*cdebaff8SEnji Cooper printf("%05d%s\n", i, $0); 1162*cdebaff8SEnji Cooper } 1163*cdebaff8SEnji Cooper }' > exp1 1164*cdebaff8SEnji Cooper atf_check -o file:exp1 \ 1165*cdebaff8SEnji Cooper "$(prog_db)" -i psize=512 btree in1 1166*cdebaff8SEnji Cooper echo $fill | 1167*cdebaff8SEnji Cooper awk '{ 1168*cdebaff8SEnji Cooper for (i = 0; i < 20000; i++) { 1169*cdebaff8SEnji Cooper printf("%05d%s\n", i, $0); 1170*cdebaff8SEnji Cooper } 1171*cdebaff8SEnji Cooper }' > exp2 1172*cdebaff8SEnji Cooper (echo $fill | awk "$script"; echo O) > in2 1173*cdebaff8SEnji Cooper atf_check -o file:exp2 \ 1174*cdebaff8SEnji Cooper "$(prog_db)" -i psize=512 btree in2 1175*cdebaff8SEnji Cooper} 1176*cdebaff8SEnji Cooper# Begin FreeBSD 1177*cdebaff8SEnji Cooperfi 1178*cdebaff8SEnji Cooper# End FreeBSD 1179*cdebaff8SEnji Cooper 1180*cdebaff8SEnji Cooperatf_test_case btree_byteswap_unaligned_access_bksd 1181*cdebaff8SEnji Cooperbtree_byteswap_unaligned_access_bksd_head() 1182*cdebaff8SEnji Cooper{ 1183*cdebaff8SEnji Cooper atf_set "descr" \ 1184*cdebaff8SEnji Cooper "btree: big key, small data, byteswap unaligned access" 1185*cdebaff8SEnji Cooper} 1186*cdebaff8SEnji Cooperbtree_byteswap_unaligned_access_bksd_body() 1187*cdebaff8SEnji Cooper{ 1188*cdebaff8SEnji Cooper (echo foo; echo bar) | 1189*cdebaff8SEnji Cooper awk '{ 1190*cdebaff8SEnji Cooper s = $0 1191*cdebaff8SEnji Cooper for (i = 0; i < 488; i++) { 1192*cdebaff8SEnji Cooper s = s "x"; 1193*cdebaff8SEnji Cooper } 1194*cdebaff8SEnji Cooper printf("p\nk%s\ndx\n", s); 1195*cdebaff8SEnji Cooper }' > in 1196*cdebaff8SEnji Cooper for order in 1234 4321; do 1197*cdebaff8SEnji Cooper atf_check \ 1198*cdebaff8SEnji Cooper "$(prog_db)" -o out -i psize=512,lorder=$order btree in 1199*cdebaff8SEnji Cooper done 1200*cdebaff8SEnji Cooper} 1201*cdebaff8SEnji Cooper 1202*cdebaff8SEnji Cooperatf_test_case btree_byteswap_unaligned_access_skbd 1203*cdebaff8SEnji Cooperbtree_byteswap_unaligned_access_skbd_head() 1204*cdebaff8SEnji Cooper{ 1205*cdebaff8SEnji Cooper atf_set "descr" \ 1206*cdebaff8SEnji Cooper "btree: small key, big data, byteswap unaligned access" 1207*cdebaff8SEnji Cooper} 1208*cdebaff8SEnji Cooperbtree_byteswap_unaligned_access_skbd_body() 1209*cdebaff8SEnji Cooper{ 1210*cdebaff8SEnji Cooper # 484 = 512 - 20 (header) - 7 ("foo1234") - 1 (newline) 1211*cdebaff8SEnji Cooper (echo foo1234; echo bar1234) | 1212*cdebaff8SEnji Cooper awk '{ 1213*cdebaff8SEnji Cooper s = $0 1214*cdebaff8SEnji Cooper for (i = 0; i < 484; i++) { 1215*cdebaff8SEnji Cooper s = s "x"; 1216*cdebaff8SEnji Cooper } 1217*cdebaff8SEnji Cooper printf("p\nk%s\nd%s\n", $0, s); 1218*cdebaff8SEnji Cooper }' > in 1219*cdebaff8SEnji Cooper for order in 1234 4321; do 1220*cdebaff8SEnji Cooper atf_check \ 1221*cdebaff8SEnji Cooper "$(prog_db)" -o out -i psize=512,lorder=$order btree in 1222*cdebaff8SEnji Cooper done 1223*cdebaff8SEnji Cooper} 1224*cdebaff8SEnji Cooper 1225*cdebaff8SEnji Cooperatf_test_case btree_known_byte_order 1226*cdebaff8SEnji Cooperbtree_known_byte_order_head() 1227*cdebaff8SEnji Cooper{ 1228*cdebaff8SEnji Cooper atf_set "descr" \ 1229*cdebaff8SEnji Cooper "btree: small key, big data, known byte order" 1230*cdebaff8SEnji Cooper} 1231*cdebaff8SEnji Cooperbtree_known_byte_order_body() 1232*cdebaff8SEnji Cooper{ 1233*cdebaff8SEnji Cooper local a="-i psize=512,lorder=" 1234*cdebaff8SEnji Cooper 1235*cdebaff8SEnji Cooper (echo foo1234; echo bar1234) | 1236*cdebaff8SEnji Cooper awk '{ 1237*cdebaff8SEnji Cooper s = $0 1238*cdebaff8SEnji Cooper for (i = 0; i < 484; i++) { 1239*cdebaff8SEnji Cooper s = s "x"; 1240*cdebaff8SEnji Cooper } 1241*cdebaff8SEnji Cooper printf("%s\n", s); 1242*cdebaff8SEnji Cooper }' > exp 1243*cdebaff8SEnji Cooper (echo foo1234; echo bar1234) | 1244*cdebaff8SEnji Cooper awk '{ 1245*cdebaff8SEnji Cooper s = $0 1246*cdebaff8SEnji Cooper for (i = 0; i < 484; i++) { 1247*cdebaff8SEnji Cooper s = s "x"; 1248*cdebaff8SEnji Cooper } 1249*cdebaff8SEnji Cooper printf("p\nk%s\nd%s\n", $0, s); 1250*cdebaff8SEnji Cooper }' > in1 1251*cdebaff8SEnji Cooper for order in 1234 4321; do 1252*cdebaff8SEnji Cooper atf_check \ 1253*cdebaff8SEnji Cooper "$(prog_db)" -f out.$order $a$order btree in1 1254*cdebaff8SEnji Cooper done 1255*cdebaff8SEnji Cooper (echo g; echo kfoo1234; echo g; echo kbar1234) > in2 1256*cdebaff8SEnji Cooper for order in 1234 4321; do 1257*cdebaff8SEnji Cooper atf_check -o file:exp \ 1258*cdebaff8SEnji Cooper "$(prog_db)" -s -f out.$order $a$order btree in2 1259*cdebaff8SEnji Cooper done 1260*cdebaff8SEnji Cooper} 1261*cdebaff8SEnji Cooper 126257718be8SEnji Cooperatf_init_test_cases() 126357718be8SEnji Cooper{ 126457718be8SEnji Cooper atf_add_test_case small_btree 126557718be8SEnji Cooper atf_add_test_case small_hash 126657718be8SEnji Cooper atf_add_test_case small_recno 126757718be8SEnji Cooper atf_add_test_case medium_btree 126857718be8SEnji Cooper atf_add_test_case medium_hash 126957718be8SEnji Cooper atf_add_test_case medium_recno 127057718be8SEnji Cooper atf_add_test_case big_btree 127157718be8SEnji Cooper atf_add_test_case big_hash 127257718be8SEnji Cooper atf_add_test_case big_recno 127357718be8SEnji Cooper atf_add_test_case random_recno 127457718be8SEnji Cooper atf_add_test_case reverse_recno 127557718be8SEnji Cooper atf_add_test_case alternate_recno 127657718be8SEnji Cooper atf_add_test_case delete_btree 127757718be8SEnji Cooper atf_add_test_case delete_recno 127857718be8SEnji Cooper atf_add_test_case repeated_btree 127957718be8SEnji Cooper atf_add_test_case repeated_hash 128057718be8SEnji Cooper atf_add_test_case duplicate_btree 128157718be8SEnji Cooper atf_add_test_case cursor_flags_btree 128257718be8SEnji Cooper atf_add_test_case cursor_flags_recno 128357718be8SEnji Cooper atf_add_test_case reverse_order_recno 128457718be8SEnji Cooper atf_add_test_case small_page_btree 128557718be8SEnji Cooper atf_add_test_case byte_orders_btree 128657718be8SEnji Cooper atf_add_test_case byte_orders_hash 128757718be8SEnji Cooper atf_add_test_case bsize_ffactor 128857718be8SEnji Cooper atf_add_test_case four_char_hash 1289640235e2SEnji Cooper atf_add_test_case bsize_torture 1290*cdebaff8SEnji Cooper atf_add_test_case btree_weird_page_split 1291*cdebaff8SEnji Cooper atf_add_test_case btree_tricky_page_split 1292*cdebaff8SEnji Cooper # Begin FreeBSD 1293*cdebaff8SEnji Cooper if false; then 1294*cdebaff8SEnji Cooper # End FreeBSD 1295*cdebaff8SEnji Cooper atf_add_test_case btree_recursive_traversal 1296*cdebaff8SEnji Cooper # Begin FreeBSD 1297*cdebaff8SEnji Cooper fi 1298*cdebaff8SEnji Cooper # End FreeBSD 1299*cdebaff8SEnji Cooper atf_add_test_case btree_byteswap_unaligned_access_bksd 1300*cdebaff8SEnji Cooper atf_add_test_case btree_byteswap_unaligned_access_skbd 1301*cdebaff8SEnji Cooper atf_add_test_case btree_known_byte_order 130257718be8SEnji Cooper} 1303