Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/lib/libc The db test has been atf-ified
details: https://anonhg.NetBSD.org/src/rev/c36d38d88ad3
branches: trunk
changeset: 760560:c36d38d88ad3
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Fri Jan 07 15:08:40 2011 +0000
description:
The db test has been atf-ified
diffstat:
regress/lib/libc/Makefile | 4 +-
regress/lib/libc/db/Makefile | 37 --
regress/lib/libc/db/README | 68 ----
regress/lib/libc/db/dbtest.c | 731 -------------------------------------------
regress/lib/libc/db/run.test | 709 -----------------------------------------
5 files changed, 2 insertions(+), 1547 deletions(-)
diffs (truncated from 1573 to 300 lines):
diff -r 09eb17f1d7e5 -r c36d38d88ad3 regress/lib/libc/Makefile
--- a/regress/lib/libc/Makefile Fri Jan 07 15:06:37 2011 +0000
+++ b/regress/lib/libc/Makefile Fri Jan 07 15:08:40 2011 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.75 2011/01/07 02:51:38 pgoyette Exp $
+# $NetBSD: Makefile,v 1.76 2011/01/07 15:08:40 pgoyette Exp $
-SUBDIR+= citrus db divrem getaddrinfo int_fmtio locale regex rpc
+SUBDIR+= citrus divrem getaddrinfo int_fmtio locale regex rpc
.include <bsd.own.mk>
.include <bsd.sys.mk>
diff -r 09eb17f1d7e5 -r c36d38d88ad3 regress/lib/libc/db/Makefile
--- a/regress/lib/libc/db/Makefile Fri Jan 07 15:06:37 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-# $NetBSD: Makefile,v 1.19 2009/01/24 22:11:45 christos Exp $
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
-NOMAN= # defined
-WARNS=4
-
-PROG= dbtest
-.if defined(LOCALLIBC)
-SRCS= dbtest.c
-SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c
-SRCS+= hash_page.c ndbm.c ndbmdatum.c
-SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c
-SRCS+= bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c
-SRCS+= bt_utils.c
-SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c
-SRCS+= rec_search.c rec_seq.c rec_utils.c
-SRCS+= db.c
-SRCS+= mpool.c
-.PATH.c: /usr/src/lib/libc/db/hash
-.PATH.c: /usr/src/lib/libc/db/btree
-.PATH.c: /usr/src/lib/libc/db/recno
-.PATH.c: /usr/src/lib/libc/db/mpool
-.PATH.c: /usr/src/lib/libc/db/db
-
-# add -DSTATISTICS to CPPFLAGS to get usage statistics. Note that
-# for this to work, libc must be compiled with -DSTATISTICS as well
-CPPFLAGS+= -g -D__DBINTERFACE_PRIVATE
-CPPFLAGS+= -I/usr/src/lib/libc/include
-CPPFLAGS+= -DDEBUG -DSTATISTICS -DHASH_STATISTICS
-CPPFLAGS+= -DDEBUG1 -DDEBUG2 -DDEBUG3 -DDEBUG4 -DDEBUG5 -DDIAGNOSTIC
-.endif
-CLEANFILES+= t1 t2 t3
-
-regress: dbtest
- ${HOST_SH} ${.CURDIR}/run.test
-
-.include <bsd.prog.mk>
diff -r 09eb17f1d7e5 -r c36d38d88ad3 regress/lib/libc/db/README
--- a/regress/lib/libc/db/README Fri Jan 07 15:06:37 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-# $NetBSD: README,v 1.5 1996/05/03 21:54:19 cgd Exp $
-# @(#)README 8.8 (Berkeley) 7/31/94
-
-To run the tests, enter "make regress".
-
-Fairly large files (the command files) are built in this directory during
-the test runs, and even larger files (the database files) are created in
-"/var/tmp". If the latter directory doesn't exist, set the environmental
-variable TMPDIR to a directory where the files can be built.
-
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-The script file consists of lines with an initial character which is
-the command for that line, or an initial character indicating a key
-or data entry for a previous command.
-
-Legal command characters are as follows:
-
-c: compare a record
- + must be followed by [kK][dD]; the data value in the database
- associated with the specified key is compared to the specified
- data value.
-e: echo a string
- + writes out the rest of the line into the output file; if the
- last character is not a carriage-return, a newline is appended.
-f: set the flags for the next command
- + no value zero's the flags
-g: do a get command
- + must be followed by [kK]
- + writes out the retrieved data DBT.
-o [r]: dump [reverse]
- + dump the database out, if 'r' is set, in reverse order.
-p: do a put command
- + must be followed by [kK][dD]
-r: do a del command
- + must be followed by [kK] unless R_CURSOR flag set.
-S: sync the database
-s: do a seq command
- + must be followed by [kK] if R_CURSOR flag set.
- + writes out the retrieved data DBT.
-
-Legal key/data characters are as follows:
-
-D [file]: data file
- + set the current data value to the contents of the file
-d [data]:
- + set the current key value to the contents of the line.
-K [file]: key file
- + set the current key value to the contents of the file
-k [data]:
- + set the current key value to the contents of the line.
-
-Blank lines, lines with leading white space, and lines with leading
-hash marks (#) are ignored.
-
-Options to dbtest are as follows:
-
- -d: Set the DB_LOCK flag.
- -f: Use the file argument as the database file.
- -i: Use the rest of the argument to set elements in the info
- structure. If the type is btree, then "-i cachesize=10240"
- will set BTREEINFO.cachesize to 10240.
- -o: The rest of the argument is the output file instead of
- using stdout.
- -s: Don't delete the database file before opening it, i.e.
- use the database file from a previous run.
-
-Dbtest requires two arguments, the type of access "hash", "recno"
-or "btree", and the script name or "-" to indicate stdin.
diff -r 09eb17f1d7e5 -r c36d38d88ad3 regress/lib/libc/db/dbtest.c
--- a/regress/lib/libc/db/dbtest.c Fri Jan 07 15:06:37 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,731 +0,0 @@
-/* $NetBSD: dbtest.c,v 1.18 2009/01/25 17:00:09 nonaka Exp $ */
-
-/*-
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
- The Regents of the University of California. All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
-#else
-__RCSID("$NetBSD: dbtest.c,v 1.18 2009/01/25 17:00:09 nonaka Exp $");
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <err.h>
-#include <db.h>
-
-enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
-
-static void compare(DBT *, DBT *);
-static DBTYPE dbtype(const char *);
-static void dump(DB *, int);
-static void get(DB *, DBT *);
-static void getdata(DB *, DBT *, DBT *);
-static void put(DB *, DBT *, DBT *);
-static void rem(DB *, DBT *);
-static const char *sflags(int);
-static void synk(DB *);
-static void *rfile(char *, size_t *);
-static void seq(DB *, DBT *);
-static u_int setflags(char *);
-static void *setinfo(DBTYPE, char *);
-static void usage(void) __attribute__((__noreturn__));
-static void *xcopy(void *, size_t);
-static void chkcmd(enum S);
-static void chkdata(enum S);
-static void chkkey(enum S);
-
-#ifdef STATISTICS
-extern void __bt_stat(DB *);
-#endif
-
-static DBTYPE type; /* Database type. */
-static void *infop; /* Iflags. */
-static size_t lineno; /* Current line in test script. */
-static u_int flags; /* Current DB flags. */
-static int ofd = STDOUT_FILENO; /* Standard output fd. */
-
-static DB *XXdbp; /* Global for gdb. */
-static size_t XXlineno; /* Fast breakpoint for gdb. */
-
-int
-main(int argc, char *argv[])
-{
- extern int optind;
- extern char *optarg;
- enum S command = COMMAND, state;
- DB *dbp;
- DBT data, key, keydata;
- size_t len;
- int ch, oflags, sflag;
- char *fname, *infoarg, *p, *t, buf[8 * 1024];
- bool unlink_dbfile;
-
- infoarg = NULL;
- fname = NULL;
- unlink_dbfile = false;
- oflags = O_CREAT | O_RDWR;
- sflag = 0;
- while ((ch = getopt(argc, argv, "f:i:lo:s")) != -1)
- switch (ch) {
- case 'f':
- fname = optarg;
- break;
- case 'i':
- infoarg = optarg;
- break;
- case 'l':
- oflags |= DB_LOCK;
- break;
- case 'o':
- if ((ofd = open(optarg,
- O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
- err(1, "Cannot create `%s'", optarg);
- break;
- case 's':
- sflag = 1;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 2)
- usage();
-
- /* Set the type. */
- type = dbtype(*argv++);
-
- /* Open the descriptor file. */
- if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL)
- err(1, "Cannot reopen `%s'", *argv);
-
- /* Set up the db structure as necessary. */
- if (infoarg == NULL)
- infop = NULL;
- else
- for (p = strtok(infoarg, ",\t "); p != NULL;
- p = strtok(0, ",\t "))
- if (*p != '\0')
- infop = setinfo(type, p);
-
- /*
- * Open the DB. Delete any preexisting copy, you almost never
- * want it around, and it often screws up tests.
- */
- if (fname == NULL) {
- const char *q = getenv("TMPDIR");
- if (q == NULL)
- q = "/var/tmp";
- (void)snprintf(buf, sizeof(buf), "%s/__dbtest", q);
- fname = buf;
- (void)unlink(buf);
- unlink_dbfile = true;
- } else if (!sflag)
- (void)unlink(fname);
Home |
Main Index |
Thread Index |
Old Index