diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-02 20:33:25 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-08-02 20:33:25 +0000 |
commit | 01ffbc46d8d357ba11088d8a2c3a38df856a078d (patch) | |
tree | 3b18fe5b10cfd98e42b9bedfacf10ae79cac0029 /tests | |
parent | 8330c0e65abad8a0ebb6430d2c2de3e534c83a11 (diff) | |
download | gdbm-01ffbc46d8d357ba11088d8a2c3a38df856a078d.tar.gz gdbm-01ffbc46d8d357ba11088d8a2c3a38df856a078d.tar.bz2 |
Add delete tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.cvsignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 11 | ||||
-rw-r--r-- | tests/delete00.at | 39 | ||||
-rw-r--r-- | tests/delete01.at | 31 | ||||
-rw-r--r-- | tests/delete02.at | 28 | ||||
-rw-r--r-- | tests/gtdel.c | 112 | ||||
-rw-r--r-- | tests/gtdump.c | 2 | ||||
-rw-r--r-- | tests/gtfetch.c | 2 | ||||
-rw-r--r-- | tests/testsuite.at | 7 |
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 | |||
5 | Makefile.in | 5 | Makefile.in |
6 | atconfig | 6 | atconfig |
7 | atlocal | 7 | atlocal |
8 | gtdel | ||
8 | gtdump | 9 | gtdump |
9 | gtfetch | 10 | gtfetch |
10 | gtload | 11 | gtload |
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 | ||
46 | TESTSUITE_AT = \ | 46 | TESTSUITE_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 | ||
77 | check_PROGRAMS = \ | 80 | check_PROGRAMS = \ |
81 | gtdel\ | ||
78 | gtdump\ | 82 | gtdump\ |
79 | gtfetch\ | 83 | gtfetch\ |
80 | gtload\ | 84 | gtload\ |
81 | num2word | 85 | num2word |
82 | 86 | ||
83 | INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src | 87 | INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src |
88 | gtdel_LDADD = ../src/libgdbm.la | ||
84 | gtload_LDADD = ../src/libgdbm.la | 89 | gtload_LDADD = ../src/libgdbm.la |
85 | gtdump_LDADD = ../src/libgdbm.la | 90 | gtdump_LDADD = ../src/libgdbm.la |
86 | gtfetch_LDADD = ../src/libgdbm.la | 91 | gtfetch_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 | |||
17 | AT_SETUP([delete a record]) | ||
18 | AT_KEYWORDS([delete delete00.at]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_SORT_PREREQ | ||
22 | num2word 1:10 | gtload test.db | ||
23 | gtdel test.db 8 | ||
24 | gtdump test.db | sort -k1,2 -n | ||
25 | ], | ||
26 | [0], | ||
27 | [1 one | ||
28 | 2 two | ||
29 | 3 three | ||
30 | 4 four | ||
31 | 5 five | ||
32 | 6 six | ||
33 | 7 seven | ||
34 | 9 nine | ||
35 | 10 ten | ||
36 | ]) | ||
37 | |||
38 | AT_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 | |||
17 | AT_SETUP([delete: non existing record]) | ||
18 | AT_KEYWORDS([delete delete01.at]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | AT_SORT_PREREQ | ||
22 | num2word 1:10 | gtload test.db | ||
23 | gtdel test.db 11 | ||
24 | ], | ||
25 | [2], | ||
26 | [], | ||
27 | [gtdel: cannot delete 11: Item not found | ||
28 | ]) | ||
29 | |||
30 | AT_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 | |||
17 | AT_SETUP([delete: all records]) | ||
18 | AT_KEYWORDS([delete delete02.at]) | ||
19 | |||
20 | AT_CHECK([ | ||
21 | num2word 1:10 | gtload test.db | ||
22 | gtdel test.db 1 2 3 4 5 6 7 8 9 10 | ||
23 | gtdump test.db | ||
24 | ], | ||
25 | [0]) | ||
26 | |||
27 | AT_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 | |||
23 | const char * | ||
24 | canonical_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 | |||
38 | int | ||
39 | main (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); | ||