Module Name:    src
Committed By:   pgoyette
Date:           Sat Jan  8 05:33:34 UTC 2011

Modified Files:
        src/tests/lib/libc/db: t_db.sh

Log Message:
Fix and re-enable the delete_btree test case


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/db/t_db.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/db/t_db.sh
diff -u src/tests/lib/libc/db/t_db.sh:1.1 src/tests/lib/libc/db/t_db.sh:1.2
--- src/tests/lib/libc/db/t_db.sh:1.1	Fri Jan  7 15:05:58 2011
+++ src/tests/lib/libc/db/t_db.sh	Sat Jan  8 05:33:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: t_db.sh,v 1.1 2011/01/07 15:05:58 pgoyette Exp $
+# $NetBSD: t_db.sh,v 1.2 2011/01/08 05:33:34 pgoyette Exp $
 #
 # Copyright (c) 2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -459,24 +459,17 @@
 	awk '{
 		for (i = 1; i <= 120; ++i)
 			printf("%05d: input key %d: %s\n", i, i, $0);
-		printf("%05d: input key %d: %s\n", 120, 120, $0);
-		printf("seq failed, no such key\n");
-		printf("%05d: input key %d: %s\n", 1, 1, $0);
-		printf("%05d: input key %d: %s\n", 2, 2, $0);
-		exit;
 	}' >exp
 
 	cat exp |
 	awk '{
-		if (i == 120)
-			exit;
 		printf("p\nk%d\nd%s\n", ++i, $0);
 	}
 	END {
 		printf("fR_NEXT\n");
 		for (i = 1; i <= 120; ++i)
 			printf("s\n");
-		printf("fR_CURSOR\ns\nk120\n");
+		printf("fR_CURSOR\ns\nkXX\n");
 		printf("r\n");
 		printf("fR_NEXT\ns\n");
 		printf("fR_CURSOR\ns\nk1\n");
@@ -484,12 +477,42 @@
 		printf("fR_FIRST\ns\n");
 	}' >in
 
+	# For btree, the records are ordered by the string representation
+	# of the key value.  So sort the expected output file accordingly,
+	# and set the seek_last key to the last expected key value.
+
+	if [ "$type" = "btree" ] ; then
+		sed -e 's/kXX/k99/' < in > tmp
+		mv tmp in
+		sort -d -k4 < exp > tmp
+		mv tmp exp
+		echo $SEVEN_SEVEN |
+		awk '{
+			printf("%05d: input key %d: %s\n", 99, 99, $0);
+			printf("seq failed, no such key\n");
+			printf("%05d: input key %d: %s\n", 1, 1, $0);
+			printf("%05d: input key %d: %s\n", 10, 10, $0);
+			exit;
+		}' >> exp
+	else
+	# For recno, records are ordered by numerical key value.  No sort
+	# is needed, but still need to set proper seek_last key value.
+		sed -e 's/kXX/k120/' < in > tmp
+		mv tmp in
+		echo $SEVEN_SEVEN |
+		awk '{
+			printf("%05d: input key %d: %s\n", 120, 120, $0);
+			printf("seq failed, no such key\n");
+			printf("%05d: input key %d: %s\n", 1, 1, $0);
+			printf("%05d: input key %d: %s\n", 2, 2, $0);
+			exit;
+		}' >> exp
+	fi
+
 	atf_check "$(prog)" -o out $type in
 	atf_check -o file:exp cat out
 }
 
-# FIXME: should it actually work? the original test apparently
-# was supposed to run such test, but didn't
 atf_test_case delete_btree
 delete_btree_head()
 {
@@ -497,13 +520,6 @@
 }
 delete_btree_body()
 {
-#
-# The delete_btree test was skipped in the original ..../regress test
-# structure, so noone ever noticed that it didn't work!  Disable it for
-# now, until we correct the generation of in/out files to reflect the
-# actual collating sequence of key values ("19" comes before "2")
-#
-	atf_skip "delete_btreee test case is broken"
 	h_delete btree
 }
 

Reply via email to