aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-02 20:33:25 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-02 20:33:25 +0000
commit01ffbc46d8d357ba11088d8a2c3a38df856a078d (patch)
tree3b18fe5b10cfd98e42b9bedfacf10ae79cac0029 /tests
parent8330c0e65abad8a0ebb6430d2c2de3e534c83a11 (diff)
downloadgdbm-01ffbc46d8d357ba11088d8a2c3a38df856a078d.tar.gz
gdbm-01ffbc46d8d357ba11088d8a2c3a38df856a078d.tar.bz2
Add delete tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/.cvsignore1
-rw-r--r--tests/Makefile.am11
-rw-r--r--tests/delete00.at39
-rw-r--r--tests/delete01.at31
-rw-r--r--tests/delete02.at28
-rw-r--r--tests/gtdel.c112
-rw-r--r--tests/gtdump.c2
-rw-r--r--tests/gtfetch.c2
-rw-r--r--tests/testsuite.at7
9 files changed, 228 insertions, 5 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
index c2e03e5..b611e77 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -5,6 +5,7 @@ Makefile
5Makefile.in 5Makefile.in
6atconfig 6atconfig
7atlocal 7atlocal
8gtdel
8gtdump 9gtdump
9gtfetch 10gtfetch
10gtload 11gtload
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7b6c9ee..dc39cad 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,9 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac $(srcdir)/Makefile
45 45
46TESTSUITE_AT = \ 46TESTSUITE_AT = \
47 create00.at\ 47 create00.at\
48 delete00.at\
49 delete01.at\
50 delete02.at\
48 fetch00.at\ 51 fetch00.at\
49 fetch01.at\ 52 fetch01.at\
50 version.at 53 version.at
@@ -70,17 +73,19 @@ check-local: atconfig atlocal $(TESTSUITE)
70#installcheck-local: 73#installcheck-local:
71# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin 74# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
72 75
73## ------------ ## 76## --------------- ##
74## num2word ## 77## num2word et al. ##
75## ------------ ## 78## --------------- ##
76 79
77check_PROGRAMS = \ 80check_PROGRAMS = \
81 gtdel\
78 gtdump\ 82 gtdump\
79 gtfetch\ 83 gtfetch\
80 gtload\ 84 gtload\
81 num2word 85 num2word
82 86
83INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src 87INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src
88gtdel_LDADD = ../src/libgdbm.la
84gtload_LDADD = ../src/libgdbm.la 89gtload_LDADD = ../src/libgdbm.la
85gtdump_LDADD = ../src/libgdbm.la 90gtdump_LDADD = ../src/libgdbm.la
86gtfetch_LDADD = ../src/libgdbm.la 91gtfetch_LDADD = ../src/libgdbm.la
diff --git a/tests/delete00.at b/tests/delete00.at
new file mode 100644
index 0000000..a64d636
--- /dev/null
+++ b/tests/delete00.at
@@ -0,0 +1,39 @@
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])
18AT_KEYWORDS([delete delete00.at])
19
20AT_CHECK([
21AT_SORT_PREREQ
22num2word 1:10 | gtload test.db
23gtdel test.db 8
24gtdump test.db | sort -k1,2 -n
25],
26[0],
27[1 one
282 two
293 three
304 four
315 five
326 six
337 seven
349 nine
3510 ten
36])
37
38AT_CLEANUP
39
diff --git a/tests/delete01.at b/tests/delete01.at
new file mode 100644
index 0000000..1142d42
--- /dev/null
+++ b/tests/delete01.at
@@ -0,0 +1,31 @@
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: non existing record])
18AT_KEYWORDS([delete delete01.at])
19
20AT_CHECK([
21AT_SORT_PREREQ
22num2word 1:10 | gtload test.db
23gtdel test.db 11
24],
25[2],
26[],
27[gtdel: cannot delete 11: Item not found
28])
29
30AT_CLEANUP
31
diff --git a/tests/delete02.at b/tests/delete02.at
new file mode 100644
index 0000000..9ce4099
--- /dev/null
+++ b/tests/delete02.at
@@ -0,0 +1,28 @@
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: all records])
18AT_KEYWORDS([delete delete02.at])
19
20AT_CHECK([
21num2word 1:10 | gtload test.db
22gtdel test.db 1 2 3 4 5 6 7 8 9 10
23gtdump test.db
24],
25[0])
26
27AT_CLEANUP
28
diff --git a/tests/gtdel.c b/tests/gtdel.c
new file mode 100644
index 0000000..6826532
--- /dev/null
+++ b/tests/gtdel.c
@@ -0,0 +1,112 @@
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 "gdbm.h"
22
23const char *
24canonical_progname (const char *str)
25{
26 const char *p;
27
28 p = strrchr (str, '/');
29 if (p)
30 p++;
31 else
32 p = str;
33 if (strncmp (p, "lt-", 3) == 0)
34 p += 3;
35 return p;
36}
37
38int
39main (int argc, char **argv)
40{
41 const char *progname = canonical_progname (argv[0]);
42 const char *dbname;
43 datum key;
44 int flags = 0;
45 GDBM_FILE dbf;
46 int data_z = 0;
47 int rc = 0;
48
49 while (--argc)
50 {
51 char *arg = *++argv;
52
53 if (strcmp (arg, "-h") == 0)
54 {
55 printf ("usage: %s [-null] [-nolock] [-nommap] [-sync] DBFILE KEY [KEY...]\n",
56 progname);
57 exit (0);
58 }
59 else if (strcmp (arg, "-null") == 0)
60 data_z = 1;
61 else if (strcmp (arg, "-nolock") == 0)
62 flags |= GDBM_NOLOCK;
63 else if (strcmp (arg, "-nommap") == 0)
64 flags |= GDBM_NOMMAP;
65 else if (strcmp (arg, "-sync") == 0)
66 flags |= GDBM_SYNC;
67 else if (strcmp (arg, "--") == 0)
68 {
69 --argc;
70 ++argv;
71 break;
72 }
73 else if (arg[0] == '-')
74 {
75 fprintf (stderr, "%s: unknown option %s\n", progname, arg);
76 exit (1);