Sat Jan 8 05:33:34 2011 UTC ()
Fix and re-enable the delete_btree test case


(pgoyette)
diff -r1.1 -r1.2 src/tests/lib/libc/db/t_db.sh

cvs diff -r1.1 -r1.2 src/tests/lib/libc/db/t_db.sh (expand / switch to unified diff)

--- src/tests/lib/libc/db/t_db.sh 2011/01/07 15:05:58 1.1
+++ src/tests/lib/libc/db/t_db.sh 2011/01/08 05:33:34 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: t_db.sh,v 1.1 2011/01/07 15:05:58 pgoyette Exp $ 1# $NetBSD: t_db.sh,v 1.2 2011/01/08 05:33:34 pgoyette 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#
@@ -449,71 +449,87 @@ alternate_recno_body() @@ -449,71 +449,87 @@ alternate_recno_body()
449} 449}
450 450
451h_delete() 451h_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 printf("%05d: input key %d: %s\n", 120, 120, $0); 
463 printf("seq failed, no such key\n"); 
464 printf("%05d: input key %d: %s\n", 1, 1, $0); 
465 printf("%05d: input key %d: %s\n", 2, 2, $0); 
466 exit; 
467 }' >exp 462 }' >exp
468 463
469 cat exp | 464 cat exp |
470 awk '{ 465 awk '{
471 if (i == 120) 
472 exit; 
473 printf("p\nk%d\nd%s\n", ++i, $0); 466 printf("p\nk%d\nd%s\n", ++i, $0);
474 } 467 }
475 END { 468 END {
476 printf("fR_NEXT\n"); 469 printf("fR_NEXT\n");
477 for (i = 1; i <= 120; ++i) 470 for (i = 1; i <= 120; ++i)
478 printf("s\n"); 471 printf("s\n");
479 printf("fR_CURSOR\ns\nk120\n"); 472 printf("fR_CURSOR\ns\nkXX\n");
480 printf("r\n"); 473 printf("r\n");
481 printf("fR_NEXT\ns\n"); 474 printf("fR_NEXT\ns\n");
482 printf("fR_CURSOR\ns\nk1\n"); 475 printf("fR_CURSOR\ns\nk1\n");
483 printf("r\n"); 476 printf("r\n");
484 printf("fR_FIRST\ns\n"); 477 printf("fR_FIRST\ns\n");
485 }' >in 478 }' >in
486 479
 480 # For btree, the records are ordered by the string representation
 481 # of the key value. So sort the expected output file accordingly,
 482 # and set the seek_last key to the last expected key value.
 483
 484 if [ "$type" = "btree" ] ; then
 485 sed -e 's/kXX/k99/' < in > tmp
 486 mv tmp in
 487 sort -d -k4 < exp > tmp
 488 mv tmp exp
 489 echo $SEVEN_SEVEN |
 490 awk '{
 491 printf("%05d: input key %d: %s\n", 99, 99, $0);
 492 printf("seq failed, no such key\n");
 493 printf("%05d: input key %d: %s\n", 1, 1, $0);
 494 printf("%05d: input key %d: %s\n", 10, 10, $0);
 495 exit;
 496 }' >> exp
 497 else
 498 # For recno, records are ordered by numerical key value. No sort
 499 # is needed, but still need to set proper seek_last key value.
 500 sed -e 's/kXX/k120/' < in > tmp
 501 mv tmp in
 502 echo $SEVEN_SEVEN |
 503 awk '{
 504 printf("%05d: input key %d: %s\n", 120, 120, $0);
 505 printf("seq failed, no such key\n");
 506 printf("%05d: input key %d: %s\n", 1, 1, $0);
 507 printf("%05d: input key %d: %s\n", 2, 2, $0);
 508 exit;
 509 }' >> exp
 510 fi
 511
487 atf_check "$(prog)" -o out $type in 512 atf_check "$(prog)" -o out $type in
488 atf_check -o file:exp cat out 513 atf_check -o file:exp cat out
489} 514}
490 515
491# FIXME: should it actually work? the original test apparently 
492# was supposed to run such test, but didn't 
493atf_test_case delete_btree 516atf_test_case delete_btree
494delete_btree_head() 517delete_btree_head()
495{ 518{
496 atf_set "descr" "Checks removing records in btree database" 519 atf_set "descr" "Checks removing records in btree database"
497} 520}
498delete_btree_body() 521delete_btree_body()
499{ 522{
500# 
501# The delete_btree test was skipped in the original ..../regress test 
502# structure, so noone ever noticed that it didn't work! Disable it for 
503# now, until we correct the generation of in/out files to reflect the 
504# actual collating sequence of key values ("19" comes before "2") 
505# 
506 atf_skip "delete_btreee test case is broken" 
507 h_delete btree 523 h_delete btree
508} 524}
509 525
510atf_test_case delete_recno 526atf_test_case delete_recno
511delete_recno_head() 527delete_recno_head()
512{ 528{
513 atf_set "descr" "Checks removing records in recno database" 529 atf_set "descr" "Checks removing records in recno database"
514} 530}
515delete_recno_body() 531delete_recno_body()
516{ 532{
517 h_delete recno 533 h_delete recno
518} 534}
519 535