aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-05 11:32:27 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-05 11:32:27 +0000
commit02f5d1c3e066af4ef00085a433f37d9a6d1a636f (patch)
tree9f88e92606662ce08f6fb78320358b41618198ea
parent92a4099a3c02a200c4ee8d776808fa9dc0f9978c (diff)
downloadgdbm-02f5d1c3e066af4ef00085a433f37d9a6d1a636f.tar.gz
gdbm-02f5d1c3e066af4ef00085a433f37d9a6d1a636f.tar.bz2
New files.
-rw-r--r--tests/.cvsignore4
-rw-r--r--tests/dbmcreate00.at30
-rw-r--r--tests/dbmdel00.at40
-rw-r--r--tests/dbmdel01.at32
-rw-r--r--tests/dbmdel02.at29
-rw-r--r--tests/dtdel.c96
-rw-r--r--tests/dtdump.c97
-rw-r--r--tests/dtload.c151
-rw-r--r--tests/progname.h32
9 files changed, 511 insertions, 0 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
index de9d411..8950eb4 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -5,6 +5,10 @@ Makefile
5Makefile.in 5Makefile.in
6atconfig 6atconfig
7atlocal 7atlocal
8dtdel
9dtdump
10dtfetch
11dtload
8gtdel 12gtdel
9gtdump 13gtdump
10gtfetch 14gtfetch
diff --git a/tests/dbmcreate00.at b/tests/dbmcreate00.at
new file mode 100644
index 0000000..157bd35
--- /dev/null
+++ b/tests/dbmcreate00.at
@@ -0,0 +1,30 @@
1# This file is part of GDBM. -*- autoconf -*-
2# Copyright (C) 2011 Free Software Foundation, Inc.
3#
4# GDBM is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# GDBM is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16
17AT_SETUP([create database: dbm interface])
18AT_KEYWORDS([dbm create create00 dbmcreate00])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22AT_SORT_PREREQ
23num2word 1:1000 > input
24dtload test < input
25dtdump test | sort -k1,2 -n > output
26diff -u input output
27])
28
29AT_CLEANUP
30
diff --git a/tests/dbmdel00.at b/tests/dbmdel00.at
new file mode 100644
index 0000000..8ff08dc
--- /dev/null
+++ b/tests/dbmdel00.at
@@ -0,0 +1,40 @@
1# This file is part of GDBM. -*- autoconf -*-
2# Copyright (C) 2011 Free Software Foundation, Inc.
3#
4# GDBM is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# GDBM is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16
17AT_SETUP([delete a record (dbm)])
18AT_KEYWORDS([dbm delete delete00 dbmdel00])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22AT_SORT_PREREQ
23num2word 1:10 | dtload test
24dtdel test 8
25dtdump test | sort -k1,2 -n
26],
27[0],
28[1 one
292 two
303 three
314 four
325 five
336 six
347 seven
359 nine
3610 ten
37])
38
39AT_CLEANUP
40
diff --git a/tests/dbmdel01.at b/tests/dbmdel01.at
new file mode 100644
index 0000000..1b537a1
--- /dev/null
+++ b/tests/dbmdel01.at
@@ -0,0 +1,32 @@
1# This file is part of GDBM. -*- autoconf -*-
2# Copyright (C) 2011 Free Software Foundation, Inc.
3#
4# GDBM is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# GDBM is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16
17AT_SETUP([delete (dbm): non existing record])
18AT_KEYWORDS([dbm delete delete01 dbmdel01])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22AT_SORT_PREREQ
23num2word 1:10 | dtload test
24dtdel test 11
25],
26[2],
27[],
28[dtdel: cannot delete 11: Item not found
29])
30
31AT_CLEANUP
32
diff --git a/tests/dbmdel02.at b/tests/dbmdel02.at
new file mode 100644
index 0000000..9b08974
--- /dev/null
+++ b/tests/dbmdel02.at
@@ -0,0 +1,29 @@
1# This file is part of GDBM. -*- autoconf -*-
2# Copyright (C) 2011 Free Software Foundation, Inc.
3#
4# GDBM is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# GDBM is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16
17AT_SETUP([delete (dbm): all records])
18AT_KEYWORDS([dbm delete delete02 dbmdel02])
19
20AT_CHECK([
21AT_COMPAT_PREREQ
22num2word 1:10 | dtload test
23dtdel test 1 2 3 4 5 6 7 8 9 10
24dtdump test
25],
26[0])
27
28AT_CLEANUP
29
diff --git a/tests/dtdel.c b/tests/dtdel.c
new file mode 100644
index 0000000..b7d0112
--- /dev/null
+++ b/tests/dtdel.c
@@ -0,0 +1,96 @@
1/* This file is part of GDBM test suite.
2 Copyright (C) 2011 Free Software Foundation, Inc.
3
4 GDBM is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 GDBM is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with GDBM. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "autoconf.h"
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
21#include "dbm.h"
22#include "progname.h"
23
24int
25main (int argc, char **argv)
26{
27 const char *progname = canonical_progname (argv[0]);
28 char *dbname;
29 datum key;
30 int flags = 0;
31 int data_z = 0;
32 int rc = 0;
33
34 while (--argc)
35 {
36 char *arg = *++argv;
37
38 if (strcmp (arg, "-h") == 0)
39 {
40 printf ("usage: %s [-null] [-nolock] [-nommap] [-sync] DBFILE KEY [KEY...]\n",
41 progname);
42 exit (0);
43 }
44 else if (strcmp (arg, "-null") == 0)
45 data_z = 1;
46 else if (strcmp (arg, "-nolock") == 0)
47 flags |= GDBM_NOLOCK;
48 else if (strcmp (arg, "-nommap") == 0)
49 flags |= GDBM_NOMMAP;
50 else if (strcmp (arg, "-sync") == 0)
51 flags |= GDBM_SYNC;
52 else if (strcmp (arg, "--") == 0)
53 {
54 --argc;
55 ++argv;
56 break;
57 }
58 else if (arg[0] == '-')
59 {
60 fprintf (stderr, "%s: unknown option %s\n", progname, arg);
61 exit (1);
62 }
63 else
64 break;
65 }
66
67 if (argc < 2)
68 {
69 fprintf (stderr, "%s: wrong arguments\n", progname);
70 exit (1);
71 }
72 dbname = *argv;
73
74 if (dbminit (dbname))
75 {
76 fprintf (stderr, "dbminit failed\n");
77 exit (1);
78 }
79
80 while (--argc)
81 {