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